@@ -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