Skip to content

Commit 9b9efed

Browse files
keithcopybara-github
authored andcommitted
Add cc_import.defines to rules_cc.
Prerequisite for merging the rest of #25690 PiperOrigin-RevId: 826546324 Change-Id: Ie0a1d60c0db5453815c083c3b7c09ea4ebd94aea
1 parent 5a09443 commit 9b9efed

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

cc/private/rules_impl/cc_import.bzl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ def _cc_import_impl(ctx):
170170
includes = cc_helper.system_include_dirs(ctx, additional_make_variable_substitutions),
171171
name = ctx.label.name,
172172
strip_include_prefix = ctx.attr.strip_include_prefix,
173+
defines = cc_helper.defines(ctx, {}),
173174
)
174175

175176
this_cc_info = CcInfo(compilation_context = compilation_context, linking_context = linking_context)
@@ -436,6 +437,16 @@ most build rules</a>."""),
436437
allow_files = True,
437438
flags = ["SKIP_CONSTRAINTS_OVERRIDE"],
438439
),
440+
"defines": attr.string_list(doc = """
441+
List of defines to add to the compile line of this and all dependent targets.
442+
Subject to <a href="${link make-variables}">"Make" variable</a> substitution and
443+
<a href="${link common-definitions#sh-tokenization}">Bourne shell tokenization</a>.
444+
Each string, which must consist of a single Bourne shell token,
445+
is prepended with <code>-D</code> and added to the compile command line to this target,
446+
as well as to every rule that depends on it. Be very careful, since this may have
447+
far-reaching effects -- the defines are added to every target that depends on
448+
this target.
449+
"""),
439450
"_use_auto_exec_groups": attr.bool(default = True),
440451
}, # buildifier: disable=unsorted-dict-items
441452
provides = [CcInfo],

0 commit comments

Comments
 (0)