Skip to content

Commit

Permalink
sh_test: add a constraint_overrides attr
Browse files Browse the repository at this point in the history
Reviewed By: itamaro

Differential Revision: D63920254

fbshipit-source-id: e34519c8d25e7b27f984c58c7f8213adb8d8423e
  • Loading branch information
zsol authored and facebook-github-bot committed Oct 9, 2024
1 parent a6079ab commit 947aa55
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions prelude/rules_impl.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,11 @@ def _cxx_python_extension_attrs():
})
return res

def _constraint_overrides_attr():
return {
"constraint_overrides": attrs.list(attrs.string(), default = []),
}

# Attrs common between python binary/test
def _python_executable_attrs():
cxx_binary_attrs = {k: v for k, v in cxx_rules.cxx_binary.attrs.items()}
Expand All @@ -279,14 +284,15 @@ def _python_executable_attrs():
if key not in python_executable_attrs
}

updated_attrs.update(_constraint_overrides_attr())

# allow non-default value for the args below
updated_attrs.update({
"anonymous_link_groups": attrs.bool(default = False),
"binary_linker_flags": attrs.list(attrs.arg(anon_target_compatible = True), default = []),
"bolt_flags": attrs.list(attrs.arg(), default = []),
"bolt_profile": attrs.option(attrs.source(), default = None),
"compiler_flags": attrs.list(attrs.arg(), default = []),
"constraint_overrides": attrs.list(attrs.string(), default = []),
"cxx_main": attrs.source(default = "prelude//python/tools:embedded_main.cpp"),
"distributed_thinlto_partial_split_dwarf": attrs.bool(default = False),
"enable_distributed_thinlto": attrs.bool(default = False),
Expand Down Expand Up @@ -356,7 +362,7 @@ def _python_test_attrs():
return test_attrs

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

NativeLinkStrategy = ["separate", "native", "merged"]
StripLibparStrategy = ["full", "extract", "none"]
Expand Down Expand Up @@ -641,7 +648,7 @@ inlined_extra_attributes = {
"_unzip_tool": attrs.default_only(attrs.exec_dep(providers = [RunInfo], default = "prelude//zip_file/tools:unzip")),
},
"rust_test": {},
"sh_test": {},
"sh_test": _constraint_overrides_attr(),
"windows_resource": {
"_cxx_toolchain": toolchains_common.cxx(),
},
Expand Down Expand Up @@ -681,6 +688,7 @@ transitions = {
"go_test": go_test_transition,
"python_binary": constraint_overrides_transition,
"python_test": constraint_overrides_transition,
"sh_test": constraint_overrides_transition,
}

toolchain_rule_names = [
Expand Down

0 comments on commit 947aa55

Please sign in to comment.