|
| 1 | +commit 27500d1eaa0e8e0f8c53b8ff5a0b9772417cdb3b |
| 2 | +Author: Gary Guo < [email protected]> |
| 3 | +Date: Fri Feb 14 15:18:37 2025 +0000 |
| 4 | + |
| 5 | + Propagate cc_library defines to clang |
| 6 | + |
| 7 | +diff --git a/extensions/bindgen/private/bindgen.bzl b/extensions/bindgen/private/bindgen.bzl |
| 8 | +index 6fa53571..1ebe104c 100644 |
| 9 | +--- a/extensions/bindgen/private/bindgen.bzl |
| 10 | ++++ b/extensions/bindgen/private/bindgen.bzl |
| 11 | +@@ -307,6 +307,10 @@ def _rust_bindgen_impl(ctx): |
| 12 | + open_arg = True |
| 13 | + continue |
| 14 | + |
| 15 | ++ # Propagated defines should be made visible to clang |
| 16 | ++ for define in ctx.attr.cc_lib[CcInfo].compilation_context.defines.to_list(): |
| 17 | ++ args.add("-D" + define) |
| 18 | ++ |
| 19 | + _, _, linker_env = get_linker_and_args(ctx, "bin", cc_toolchain, feature_configuration, None) |
| 20 | + env.update(**linker_env) |
| 21 | + |
| 22 | +diff --git a/extensions/bindgen/test/integration/simple/BUILD.bazel b/extensions/bindgen/test/integration/simple/BUILD.bazel |
| 23 | +index 0a1162b1..c52e8272 100644 |
| 24 | +--- a/extensions/bindgen/test/integration/simple/BUILD.bazel |
| 25 | ++++ b/extensions/bindgen/test/integration/simple/BUILD.bazel |
| 26 | +@@ -11,5 +11,6 @@ cc_library( |
| 27 | + name = "simple", |
| 28 | + srcs = ["simple.cc"], |
| 29 | + hdrs = ["simple.h"], |
| 30 | ++ defines = ["SIMPLE_DEFINE=1"], |
| 31 | + visibility = ["//test/integration:__pkg__"], |
| 32 | + ) |
| 33 | +diff --git a/extensions/bindgen/test/integration/simple/simple.h b/extensions/bindgen/test/integration/simple/simple.h |
| 34 | +index a7ca3f43..d68c739a 100644 |
| 35 | +--- a/extensions/bindgen/test/integration/simple/simple.h |
| 36 | ++++ b/extensions/bindgen/test/integration/simple/simple.h |
| 37 | +@@ -9,8 +9,12 @@ |
| 38 | + |
| 39 | + #include <stdint.h> |
| 40 | + |
| 41 | ++#ifdef SIMPLE_DEFINE |
| 42 | ++ |
| 43 | + static const int64_t SIMPLE_VALUE = 42; |
| 44 | + |
| 45 | ++#endif |
| 46 | ++ |
| 47 | + EXTERN_C const int64_t simple_function(); |
| 48 | + |
| 49 | + static inline int64_t simple_static_function() { return 84; } |
| 50 | + |
0 commit comments