File tree Expand file tree Collapse file tree 3 files changed +30
-0
lines changed
tests/builtins_bzl/cc/cc_static_library/test Expand file tree Collapse file tree 3 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -165,6 +165,7 @@ def _cc_import_impl(ctx):
165165 public_hdrs = ctx .files .hdrs ,
166166 includes = ctx .attr .includes ,
167167 name = ctx .label .name ,
168+ defines = cc_helper .defines (ctx , {}),
168169 )
169170
170171 this_cc_info = CcInfo (compilation_context = compilation_context , linking_context = linking_context )
@@ -416,6 +417,16 @@ most build rules</a>."""),
416417 allow_files = True ,
417418 flags = ["SKIP_CONSTRAINTS_OVERRIDE" ],
418419 ),
420+ "defines" : attr .string_list (doc = """
421+ List of defines to add to the compile line of this and all dependent targets.
422+ Subject to <a href="${link make-variables}">"Make" variable</a> substitution and
423+ <a href="${link common-definitions#sh-tokenization}">Bourne shell tokenization</a>.
424+ Each string, which must consist of a single Bourne shell token,
425+ is prepended with <code>-D</code> and added to the compile command line to this target,
426+ as well as to every rule that depends on it. Be very careful, since this may have
427+ far-reaching effects -- the defines are added to every target that depends on
428+ this target.
429+ """ ),
419430 "_use_auto_exec_groups" : attr .bool (default = True ),
420431 },
421432 provides = [CcInfo ],
Original file line number Diff line number Diff line change @@ -47,6 +47,18 @@ cc_test(
4747 deps = [":static_import"],
4848)
4949
50+ cc_import(
51+ name = "lib_with_define",
52+ defines = ["IMPORT_DEFINE"],
53+ static_library = ":lib_only",
54+ )
55+
56+ cc_test(
57+ name = "define_test",
58+ srcs = ["require_define.cc"],
59+ deps = [":lib_with_define"],
60+ )
61+
5062sh_test(
5163 name = "cc_static_library_integration_test",
5264 srcs = [
Original file line number Diff line number Diff line change 1+ #ifndef IMPORT_DEFINE
2+ #error "Missing expected IMPORT_DEFINE"
3+ #endif
4+
5+ int main () {
6+ return 0 ;
7+ }
You can’t perform that action at this time.
0 commit comments