mirror of https://github.com/bazelbuild/rules_cc
Allow creation of sentinel features in rule-based toolchains
BEGIN_PUBLIC Makes the `args` attribute of `cc_feature` optional so that users may declare sentinel features that do not have any inherent arguments. END_PUBLIC PiperOrigin-RevId: 646545838 Change-Id: I470a496aec951608f21cc8ea693387c5b551c8a9
This commit is contained in:
parent
9ff1d1b6fd
commit
280d3ad603
|
@ -125,7 +125,6 @@ Example:
|
||||||
doc = """Whether or not this feature is enabled by default.""",
|
doc = """Whether or not this feature is enabled by default.""",
|
||||||
),
|
),
|
||||||
"args": attr.label_list(
|
"args": attr.label_list(
|
||||||
mandatory = True,
|
|
||||||
doc = """Args that, when expanded, implement this feature.""",
|
doc = """Args that, when expanded, implement this feature.""",
|
||||||
providers = [ArgsListInfo],
|
providers = [ArgsListInfo],
|
||||||
),
|
),
|
||||||
|
|
|
@ -109,6 +109,13 @@ util.helper_target(
|
||||||
overrides = ":builtin_feature",
|
overrides = ":builtin_feature",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
util.helper_target(
|
||||||
|
cc_feature,
|
||||||
|
name = "sentinel_feature",
|
||||||
|
enabled = True,
|
||||||
|
feature_name = "sentinel_feature_name",
|
||||||
|
)
|
||||||
|
|
||||||
analysis_test_suite(
|
analysis_test_suite(
|
||||||
name = "test_suite",
|
name = "test_suite",
|
||||||
targets = TARGETS,
|
targets = TARGETS,
|
||||||
|
|
|
@ -37,6 +37,12 @@ visibility("private")
|
||||||
|
|
||||||
_C_COMPILE_FILE = "tests/rule_based_toolchain/testdata/file1"
|
_C_COMPILE_FILE = "tests/rule_based_toolchain/testdata/file1"
|
||||||
|
|
||||||
|
def _sentinel_feature_test(env, targets):
|
||||||
|
sentinel_feature = env.expect.that_target(targets.sentinel_feature).provider(FeatureInfo)
|
||||||
|
sentinel_feature.name().equals("sentinel_feature_name")
|
||||||
|
sentinel_feature.args().args().contains_exactly([])
|
||||||
|
sentinel_feature.enabled().equals(True)
|
||||||
|
|
||||||
def _simple_feature_test(env, targets):
|
def _simple_feature_test(env, targets):
|
||||||
simple = env.expect.that_target(targets.simple).provider(FeatureInfo)
|
simple = env.expect.that_target(targets.simple).provider(FeatureInfo)
|
||||||
simple.name().equals("feature_name")
|
simple.name().equals("feature_name")
|
||||||
|
@ -154,6 +160,7 @@ TARGETS = [
|
||||||
":mutual_exclusion_feature",
|
":mutual_exclusion_feature",
|
||||||
":overrides",
|
":overrides",
|
||||||
":requires",
|
":requires",
|
||||||
|
":sentinel_feature",
|
||||||
":simple",
|
":simple",
|
||||||
":simple2",
|
":simple2",
|
||||||
":transitive_constraint",
|
":transitive_constraint",
|
||||||
|
@ -161,6 +168,7 @@ TARGETS = [
|
||||||
|
|
||||||
# @unsorted-dict-items
|
# @unsorted-dict-items
|
||||||
TESTS = {
|
TESTS = {
|
||||||
|
"sentinel_feature_test": _sentinel_feature_test,
|
||||||
"simple_feature_test": _simple_feature_test,
|
"simple_feature_test": _simple_feature_test,
|
||||||
"feature_collects_requirements_test": _feature_collects_requirements_test,
|
"feature_collects_requirements_test": _feature_collects_requirements_test,
|
||||||
"feature_collects_implies_test": _feature_collects_implies_test,
|
"feature_collects_implies_test": _feature_collects_implies_test,
|
||||||
|
|
Loading…
Reference in New Issue