From 4eb87c196279ae4745428db260dde2155c7433e2 Mon Sep 17 00:00:00 2001 From: cpeyser Date: Mon, 13 Nov 2017 07:53:18 -0800 Subject: Allow an action_config to be activated by default. PiperOrigin-RevId: 175531318 --- .../devtools/build/lib/rules/cpp/CcCommon.java | 2 +- .../build/lib/rules/cpp/CcToolchainFeatures.java | 20 +++++++++++--------- .../build/lib/rules/objc/CompilationSupport.java | 4 ++-- 3 files changed, 14 insertions(+), 12 deletions(-) (limited to 'src/main/java/com/google/devtools') diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcCommon.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcCommon.java index 8ae89de3f6..f760e243d1 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcCommon.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcCommon.java @@ -610,7 +610,7 @@ public final class CcCommon { ImmutableSet.of( toolchain.getCompilationMode().toString(), getHostOrNonHostFeature(ruleContext)), DEFAULT_FEATURES, - toolchain.getFeatures().getDefaultFeatures(), + toolchain.getFeatures().getDefaultFeaturesAndActionConfigs(), ruleContext.getFeatures())) { if (!unsupportedFeatures.contains(feature)) { requestedFeatures.add(feature); diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchainFeatures.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchainFeatures.java index 770b7e04fc..679d2c2b38 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchainFeatures.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchainFeatures.java @@ -1835,8 +1835,8 @@ public class CcToolchainFeatures implements Serializable { */ private final ImmutableMultimap requiredBy; - private final ImmutableList defaultFeatures; - + private final ImmutableList defaultSelectables; + /** * A cache of feature selection results, so we do not recalculate the feature selection for all * actions. @@ -1862,23 +1862,26 @@ public class CcToolchainFeatures implements Serializable { // Also build a map from action -> action_config, for use in tool lookups ImmutableMap.Builder actionConfigsByActionName = ImmutableMap.builder(); - ImmutableList.Builder defaultFeaturesBuilder = ImmutableList.builder(); + ImmutableList.Builder defaultSelectablesBuilder = ImmutableList.builder(); for (CToolchain.Feature toolchainFeature : toolchain.getFeatureList()) { Feature feature = new Feature(toolchainFeature); selectablesBuilder.add(feature); selectablesByName.put(feature.getName(), feature); if (toolchainFeature.getEnabled()) { - defaultFeaturesBuilder.add(feature.getName()); + defaultSelectablesBuilder.add(feature.getName()); } } - this.defaultFeatures = defaultFeaturesBuilder.build(); - + for (CToolchain.ActionConfig toolchainActionConfig : toolchain.getActionConfigList()) { ActionConfig actionConfig = new ActionConfig(toolchainActionConfig); selectablesBuilder.add(actionConfig); selectablesByName.put(actionConfig.getName(), actionConfig); actionConfigsByActionName.put(actionConfig.getActionName(), actionConfig); + if (toolchainActionConfig.getEnabled()) { + defaultSelectablesBuilder.add(actionConfig.getName()); + } } + this.defaultSelectables = defaultSelectablesBuilder.build(); this.selectables = selectablesBuilder.build(); this.selectablesByName = ImmutableMap.copyOf(selectablesByName); @@ -2036,9 +2039,8 @@ public class CcToolchainFeatures implements Serializable { return new FeatureSelection(featureSpecification).run(); } - /** Returns the list of features that specify themselves as enabled by default. */ - public ImmutableList getDefaultFeatures() { - return defaultFeatures; + public ImmutableList getDefaultFeaturesAndActionConfigs() { + return defaultSelectables; } /** diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/CompilationSupport.java b/src/main/java/com/google/devtools/build/lib/rules/objc/CompilationSupport.java index 65b5e1d63f..d789bc0b84 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/CompilationSupport.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/CompilationSupport.java @@ -389,7 +389,7 @@ public class CompilationSupport { boolean isHost = ruleContext.getConfiguration().isHostConfiguration(); ImmutableSet.Builder activatedCrosstoolSelectables = ImmutableSet.builder() - .addAll(ccToolchain.getFeatures().getDefaultFeatures()) + .addAll(ccToolchain.getFeatures().getDefaultFeaturesAndActionConfigs()) .addAll(ACTIVATED_ACTIONS) .addAll( ruleContext @@ -442,7 +442,7 @@ public class CompilationSupport { activatedCrosstoolSelectables.addAll(ruleContext.getFeatures()); try { - return toolchain + return ccToolchain .getFeatures() .getFeatureConfiguration( FeatureSpecification.create( -- cgit v1.2.3