rs_bindings_from_cc: Expand make variables in user copts. PiperOrigin-RevId: 574469615 Change-Id: I24544283212d136a2de7dc208f5af85d01c87629
diff --git a/rs_bindings_from_cc/bazel_support/compile_cc.bzl b/rs_bindings_from_cc/bazel_support/compile_cc.bzl index 5de5538..468d793 100644 --- a/rs_bindings_from_cc/bazel_support/compile_cc.bzl +++ b/rs_bindings_from_cc/bazel_support/compile_cc.bzl
@@ -32,6 +32,11 @@ """ cc_info = cc_common.merge_cc_infos(cc_infos = cc_infos) + user_copts = [] + for copt in getattr(attr, "copts", []): + # ctx.expand_make_variables is deprecated, but its replacement ctx.var does not suffice. + user_copts.append(ctx.expand_make_variables("copts", copt, {})) + (compilation_context, compilation_outputs) = cc_common.compile( name = src.basename, actions = ctx.actions, @@ -39,7 +44,7 @@ cc_toolchain = cc_toolchain, srcs = [src], additional_inputs = extra_cc_compilation_action_inputs, - user_compile_flags = attr.copts if hasattr(attr, "copts") else [], + user_compile_flags = user_copts, compilation_contexts = [cc_info.compilation_context], )