diff --git a/bazel/build.bzl b/bazel/build.bzl index e77f5e93967c9..91a4a1e47018d 100644 --- a/bazel/build.bzl +++ b/bazel/build.bzl @@ -7,7 +7,7 @@ making behavior changes across the entire build. load("@rules_cc//cc:cc_binary.bzl", "cc_binary") load("@rules_cc//cc:cc_library.bzl", "cc_library") -load(":internal.bzl", "antithesis_deps", "redpanda_copts") +load(":internal.bzl", "antithesis_deps", "redpanda_copts", "redpanda_implicit_deps") # buildifier: disable=function-docstring-args def redpanda_cc_library( @@ -35,7 +35,7 @@ def redpanda_cc_library( local_defines = local_defines, visibility = visibility, include_prefix = include_prefix, - implementation_deps = implementation_deps, + implementation_deps = implementation_deps + redpanda_implicit_deps(), deps = deps, copts = redpanda_copts() + copts, tags = tags, @@ -64,7 +64,7 @@ def redpanda_cc_binary( defines = defines, local_defines = local_defines, visibility = visibility, - deps = deps + antithesis_deps(), + deps = deps + antithesis_deps() + redpanda_implicit_deps(), testonly = testonly, copts = redpanda_copts() + copts, linkopts = linkopts, diff --git a/bazel/internal.bzl b/bazel/internal.bzl index fa5fb6acb9088..146a7b3831366 100644 --- a/bazel/internal.bzl +++ b/bazel/internal.bzl @@ -17,9 +17,18 @@ def redpanda_copts(): copts.append("-Wextra") copts.append("-Wno-missing-field-initializers") copts.append("-Wimplicit-fallthrough") + copts.append("-include") + copts.append("base/ptree_ban.h") return copts +def redpanda_implicit_deps(): + """ + Deps that must be present on every redpanda C++ target so that + the headers force-included via redpanda_copts() are visible. + """ + return ["//src/v/base:ptree_ban"] + def antithesis_deps(): """Conditional deps for Antithesis coverage instrumentation.""" return select({ diff --git a/bazel/test.bzl b/bazel/test.bzl index da9c18f28f5cc..9208ff47675c6 100644 --- a/bazel/test.bzl +++ b/bazel/test.bzl @@ -10,7 +10,7 @@ load("@rules_cc//cc:cc_binary.bzl", "cc_binary") load("@rules_cc//cc:cc_library.bzl", "cc_library") load("@rules_cc//cc:cc_test.bzl", "cc_test") load("@rules_python//python:defs.bzl", "py_binary", "py_test") -load(":internal.bzl", "antithesis_deps", "redpanda_copts") +load(":internal.bzl", "antithesis_deps", "redpanda_copts", "redpanda_implicit_deps") def _reactor_args(): """Returns additional reactor args for all reactor-using tests and benchmarks.""" @@ -164,7 +164,7 @@ def _redpanda_cc_test( timeout = timeout, srcs = srcs, defines = defines, - deps = deps + test_deps, + deps = deps + test_deps + redpanda_implicit_deps(), copts = redpanda_copts(), args = args, features = [ @@ -206,7 +206,7 @@ def _redpanda_cc_fuzz_test( timeout = timeout, srcs = srcs, defines = defines, - deps = deps + test_deps, + deps = deps + test_deps + redpanda_implicit_deps(), copts = redpanda_copts(), args = custom_args, features = [ @@ -354,7 +354,7 @@ def redpanda_cc_btest_no_seastar( "//src/v/test_utils:boost_result_redirect", "//src/v/test_utils:boost_test_hooks", "@boost//:test.so", - ] + deps + test_deps, + ] + deps + test_deps + redpanda_implicit_deps(), data = test_data, env = test_env, ) @@ -377,7 +377,7 @@ def redpanda_test_cc_library( local_defines = local_defines, visibility = visibility, include_prefix = native.package_name().removeprefix("src/v/"), - implementation_deps = implementation_deps, + implementation_deps = implementation_deps + redpanda_implicit_deps(), deps = deps, copts = redpanda_copts(), testonly = True, @@ -472,7 +472,7 @@ def redpanda_cc_bench( name = binary_name, srcs = srcs, defines = defines, - deps = deps + test_deps, + deps = deps + test_deps + redpanda_implicit_deps(), testonly = True, copts = redpanda_copts(), features = [ diff --git a/src/v/base/BUILD b/src/v/base/BUILD index bff2c57ef7917..63effba0795fb 100644 --- a/src/v/base/BUILD +++ b/src/v/base/BUILD @@ -1,5 +1,13 @@ +load("@rules_cc//cc:cc_library.bzl", "cc_library") load("//bazel:build.bzl", "redpanda_cc_library") +cc_library( + name = "ptree_ban", + hdrs = ["ptree_ban.h"], + include_prefix = "base", + visibility = ["//visibility:public"], +) + redpanda_cc_library( name = "base", srcs = [ diff --git a/src/v/base/ptree_ban.h b/src/v/base/ptree_ban.h new file mode 100644 index 0000000000000..f5ef6ce3deb3a --- /dev/null +++ b/src/v/base/ptree_ban.h @@ -0,0 +1,44 @@ +/* + * Copyright 2026 Redpanda Data, Inc. + * + * Use of this software is governed by the Business Source License + * included in the file licenses/BSL.md + * + * As of the Change Date specified in that file, in accordance with + * the Business Source License, use of this software will be governed + * by the Apache License, Version 2.0 + */ + +#pragma once + +#include + +namespace seastar { +template +class basic_sstring; +} // namespace seastar + +namespace boost::property_tree { + +template +struct translator_between; + +template< + typename Ch, + typename Traits, + typename Alloc, + typename CharT, + typename Size, + Size MaxSize, + bool NulTerminate> +struct translator_between< + std::basic_string, + ::seastar::basic_sstring> { + static_assert( + false, + "boost::property_tree::ptree::get silently returns " + "the default for non-empty trees because seastar::sstring lacks a " + "stream extractor. Use std::string and convert at the call site."); +}; + +} // namespace boost::property_tree