aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/rules
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/cpp/CcCommon.java5
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchainFeatures.java20
2 files changed, 19 insertions, 6 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 1c7d0d1e99..8e58a103fc 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
@@ -535,9 +535,10 @@ public final class CcCommon {
ImmutableSet.Builder<String> requestedFeatures = ImmutableSet.builder();
for (String feature :
Iterables.concat(
- ImmutableSet.of(toolchain.getCompilationMode().toString()),
- ImmutableSet.of(getHostOrNonHostFeature(ruleContext)),
+ ImmutableSet.of(
+ toolchain.getCompilationMode().toString(), getHostOrNonHostFeature(ruleContext)),
DEFAULT_FEATURES,
+ toolchain.getFeatures().getDefaultFeatures(),
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 47a9fa667e..f9295c684a 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
@@ -1820,13 +1820,15 @@ public class CcToolchainFeatures implements Serializable {
* was disabled.
*/
private final ImmutableMultimap<CrosstoolSelectable, CrosstoolSelectable> requiredBy;
+
+ private final ImmutableList<String> defaultFeatures;
/**
- * A cache of feature selection results, so we do not recalculate the feature selection for
- * all actions.
+ * A cache of feature selection results, so we do not recalculate the feature selection for all
+ * actions.
*/
- private transient LoadingCache<Collection<String>, FeatureConfiguration>
- configurationCache = buildConfigurationCache();
+ private transient LoadingCache<Collection<String>, FeatureConfiguration> configurationCache =
+ buildConfigurationCache();
/**
* Constructs the feature configuration from a {@code CToolchain} protocol buffer.
@@ -1846,11 +1848,16 @@ 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();
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());
+ }
}
+ this.defaultFeatures = defaultFeaturesBuilder.build();
for (CToolchain.ActionConfig toolchainActionConfig : toolchain.getActionConfigList()) {
ActionConfig actionConfig = new ActionConfig(toolchainActionConfig);
@@ -2006,6 +2013,11 @@ public class CcToolchainFeatures implements Serializable {
return getFeatureConfiguration(Arrays.asList(requestedFeatures));
}
+ /** Returns the list of features that specify themselves as enabled by default. */
+ public ImmutableList<String> getDefaultFeatures() {
+ return defaultFeatures;
+ }
+
/**
* @return the selectable with the given {@code name}.
*