Add cc_import.defines to rules_cc.
Prerequisite for merging the rest of #25690
PiperOrigin-RevId: 826546324
Change-Id: Ie0a1d60c0db5453815c083c3b7c09ea4ebd94aea
diff --git a/cc/private/rules_impl/cc_import.bzl b/cc/private/rules_impl/cc_import.bzl
index 4c71d26..4457a6c 100644
--- a/cc/private/rules_impl/cc_import.bzl
+++ b/cc/private/rules_impl/cc_import.bzl
@@ -170,6 +170,7 @@
includes = cc_helper.system_include_dirs(ctx, additional_make_variable_substitutions),
name = ctx.label.name,
strip_include_prefix = ctx.attr.strip_include_prefix,
+ defines = cc_helper.defines(ctx, {}),
)
this_cc_info = CcInfo(compilation_context = compilation_context, linking_context = linking_context)
@@ -436,6 +437,16 @@
allow_files = True,
flags = ["SKIP_CONSTRAINTS_OVERRIDE"],
),
+ "defines": attr.string_list(doc = """
+List of defines to add to the compile line of this and all dependent targets.
+Subject to <a href="${link make-variables}">"Make" variable</a> substitution and
+<a href="${link common-definitions#sh-tokenization}">Bourne shell tokenization</a>.
+Each string, which must consist of a single Bourne shell token,
+is prepended with <code>-D</code> and added to the compile command line to this target,
+as well as to every rule that depends on it. Be very careful, since this may have
+far-reaching effects -- the defines are added to every target that depends on
+this target.
+"""),
"_use_auto_exec_groups": attr.bool(default = True),
}, # buildifier: disable=unsorted-dict-items
provides = [CcInfo],