aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java
diff options
context:
space:
mode:
authorGravatar cpeyser <cpeyser@google.com>2017-11-13 07:53:18 -0800
committerGravatar Copybara-Service <copybara-piper@google.com>2017-11-13 07:54:40 -0800
commit4eb87c196279ae4745428db260dde2155c7433e2 (patch)
tree857d0ef8e35b2eacee9bea1064024973e9d663c4 /src/main/java
parent16c64e41f664c6d4c913f5f68e113748a78169a6 (diff)
Allow an action_config to be activated by default.
PiperOrigin-RevId: 175531318
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/cpp/CcCommon.java2
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchainFeatures.java20
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/objc/CompilationSupport.java4
3 files changed, 14 insertions, 12 deletions
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<CrosstoolSelectable, CrosstoolSelectable> requiredBy;
- private final ImmutableList<String> defaultFeatures;
-
+ private final ImmutableList<String> 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<String, ActionConfig> actionConfigsByActionName = ImmutableMap.builder();
- ImmutableList.Builder<String> defaultFeaturesBuilder = ImmutableList.builder();
+ ImmutableList.Builder<String> 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<String> getDefaultFeatures() {
- return defaultFeatures;
+ public ImmutableList<String> 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<String> activatedCrosstoolSelectables =
ImmutableSet.<String>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(