Skip to content

Commit 947aa55

Browse files
zsolfacebook-github-bot
authored andcommitted
sh_test: add a constraint_overrides attr
Reviewed By: itamaro Differential Revision: D63920254 fbshipit-source-id: e34519c8d25e7b27f984c58c7f8213adb8d8423e
1 parent a6079ab commit 947aa55

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

prelude/rules_impl.bzl

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,11 @@ def _cxx_python_extension_attrs():
266266
})
267267
return res
268268

269+
def _constraint_overrides_attr():
270+
return {
271+
"constraint_overrides": attrs.list(attrs.string(), default = []),
272+
}
273+
269274
# Attrs common between python binary/test
270275
def _python_executable_attrs():
271276
cxx_binary_attrs = {k: v for k, v in cxx_rules.cxx_binary.attrs.items()}
@@ -279,14 +284,15 @@ def _python_executable_attrs():
279284
if key not in python_executable_attrs
280285
}
281286

287+
updated_attrs.update(_constraint_overrides_attr())
288+
282289
# allow non-default value for the args below
283290
updated_attrs.update({
284291
"anonymous_link_groups": attrs.bool(default = False),
285292
"binary_linker_flags": attrs.list(attrs.arg(anon_target_compatible = True), default = []),
286293
"bolt_flags": attrs.list(attrs.arg(), default = []),
287294
"bolt_profile": attrs.option(attrs.source(), default = None),
288295
"compiler_flags": attrs.list(attrs.arg(), default = []),
289-
"constraint_overrides": attrs.list(attrs.string(), default = []),
290296
"cxx_main": attrs.source(default = "prelude//python/tools:embedded_main.cpp"),
291297
"distributed_thinlto_partial_split_dwarf": attrs.bool(default = False),
292298
"enable_distributed_thinlto": attrs.bool(default = False),
@@ -356,7 +362,7 @@ def _python_test_attrs():
356362
return test_attrs
357363

358364
def _cxx_binary_and_test_attrs():
359-
return {
365+
ret = {
360366
"anonymous_link_groups": attrs.bool(default = False),
361367
"auto_link_groups": attrs.bool(default = False),
362368
# Linker flags that only apply to the executable link, used for link
@@ -365,7 +371,6 @@ def _cxx_binary_and_test_attrs():
365371
"binary_linker_flags": attrs.list(attrs.arg(anon_target_compatible = True), default = []),
366372
"bolt_flags": attrs.list(attrs.arg(), default = []),
367373
"bolt_profile": attrs.option(attrs.source(), default = None),
368-
"constraint_overrides": attrs.list(attrs.string(), default = []),
369374
# These flags will only be used to instrument a target
370375
# when coverage for that target is enabled by a header
371376
# selected for coverage either in the target or in one
@@ -385,6 +390,8 @@ def _cxx_binary_and_test_attrs():
385390
"_cxx_hacks": attrs.dep(default = "prelude//cxx/tools:cxx_hacks"),
386391
"_cxx_toolchain": toolchains_common.cxx(),
387392
}
393+
ret.update(_constraint_overrides_attr())
394+
return ret
388395

389396
NativeLinkStrategy = ["separate", "native", "merged"]
390397
StripLibparStrategy = ["full", "extract", "none"]
@@ -641,7 +648,7 @@ inlined_extra_attributes = {
641648
"_unzip_tool": attrs.default_only(attrs.exec_dep(providers = [RunInfo], default = "prelude//zip_file/tools:unzip")),
642649
},
643650
"rust_test": {},
644-
"sh_test": {},
651+
"sh_test": _constraint_overrides_attr(),
645652
"windows_resource": {
646653
"_cxx_toolchain": toolchains_common.cxx(),
647654
},
@@ -681,6 +688,7 @@ transitions = {
681688
"go_test": go_test_transition,
682689
"python_binary": constraint_overrides_transition,
683690
"python_test": constraint_overrides_transition,
691+
"sh_test": constraint_overrides_transition,
684692
}
685693

686694
toolchain_rule_names = [

0 commit comments

Comments
 (0)