diff --git a/cc/toolchains/impl/legacy_converter.bzl b/cc/toolchains/impl/legacy_converter.bzl index db2b6e6..1d74d88 100644 --- a/cc/toolchains/impl/legacy_converter.bzl +++ b/cc/toolchains/impl/legacy_converter.bzl @@ -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, diff --git a/tests/rule_based_toolchain/toolchain_config/toolchain_config_test.bzl b/tests/rule_based_toolchain/toolchain_config/toolchain_config_test.bzl index a550c50..29ab9ab 100644 --- a/tests/rule_based_toolchain/toolchain_config/toolchain_config_test.bzl +++ b/tests/rule_based_toolchain/toolchain_config/toolchain_config_test.bzl @@ -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 = [