mirror of https://github.com/bazelbuild/rules_cc
Make enabled_features functionally equivalent to cc_feature(..., enabled=True)
BEGIN_PUBLIC Make enabled_features functionally equivalent to cc_feature(..., enabled=True) This should allow you to disable an enabled feature elsewhere in the toolchain. Fixes #233 END_PUBLIC PiperOrigin-RevId: 666318466 Change-Id: I0b820cb2033d4ce8b141ff74dcd6516b8157c2b4
This commit is contained in:
parent
84fceed887
commit
3a62fd3f5b
|
@ -99,7 +99,7 @@ def _convert_args_sequence(args_sequence):
|
|||
|
||||
return struct(flag_sets = flag_sets, env_sets = env_sets)
|
||||
|
||||
def convert_feature(feature):
|
||||
def convert_feature(feature, enabled = False):
|
||||
if feature.external:
|
||||
return None
|
||||
|
||||
|
@ -107,7 +107,7 @@ def convert_feature(feature):
|
|||
|
||||
return legacy_feature(
|
||||
name = feature.name,
|
||||
enabled = feature.enabled,
|
||||
enabled = enabled or feature.enabled,
|
||||
flag_sets = args.flag_sets,
|
||||
env_sets = args.env_sets,
|
||||
implies = sorted([ft.name for ft in feature.implies.to_list()]),
|
||||
|
@ -150,14 +150,17 @@ def convert_toolchain(toolchain):
|
|||
A struct containing parameters suitable to pass to
|
||||
cc_common.create_cc_toolchain_config_info.
|
||||
"""
|
||||
features = [convert_feature(feature) for feature in toolchain.features]
|
||||
features = [
|
||||
convert_feature(feature, enabled = feature in toolchain.enabled_features)
|
||||
for feature in toolchain.features
|
||||
]
|
||||
features.append(convert_feature(FeatureInfo(
|
||||
# We reserve names starting with implied_by. This ensures we don't
|
||||
# conflict with the name of a feature the user creates.
|
||||
name = "implied_by_always_enabled",
|
||||
enabled = True,
|
||||
args = ArgsListInfo(args = toolchain.args),
|
||||
implies = depset([ft for ft in toolchain.enabled_features]),
|
||||
implies = depset([]),
|
||||
requires_any_of = [],
|
||||
mutually_exclusive = [],
|
||||
external = False,
|
||||
|
|
|
@ -187,7 +187,7 @@ def _toolchain_collects_files_test(env, targets):
|
|||
env.expect.that_collection(legacy.features).contains_exactly([
|
||||
legacy_feature(
|
||||
name = "simple_feature",
|
||||
enabled = False,
|
||||
enabled = True,
|
||||
flag_sets = [legacy_flag_set(
|
||||
actions = ["c_compile"],
|
||||
flag_groups = [
|
||||
|
@ -208,7 +208,6 @@ def _toolchain_collects_files_test(env, targets):
|
|||
legacy_feature(
|
||||
name = "implied_by_always_enabled",
|
||||
enabled = True,
|
||||
implies = ["simple_feature"],
|
||||
flag_sets = [legacy_flag_set(
|
||||
actions = ["c_compile"],
|
||||
flag_groups = [
|
||||
|
|
Loading…
Reference in New Issue