aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/rules/cpp
diff options
context:
space:
mode:
authorGravatar rosica <rosica@google.com>2018-06-19 03:12:10 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-06-19 03:13:29 -0700
commitf179ab8d66a0588fa8f4e152ae762c444a5db87c (patch)
treeb55e5f82b6e52c5a4b8b17a9613f7d3e6ebfd374 /src/main/java/com/google/devtools/build/lib/rules/cpp
parent4ad6969021e16746672d3fcf95b6cdf8cb6c43f2 (diff)
Add fields to CcToolchainFeatures.Feature and CcToolchainFeatures.ActionConfig that are needed for FeatureConfiguration creation
In the future CcToolchainFeatures will not be created from a CToolchain but from a CrosstoolInfo provider that will encapsule all relevant information from the CROSSTOOL. Feature and ActionConfig classes need to carry all the information that is currently obtained from CToolchain. Work towards issue #5380 RELNOTES: None. PiperOrigin-RevId: 201147336
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules/cpp')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchainFeatures.java78
1 files changed, 70 insertions, 8 deletions
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 18c64003aa..4b3f04c23e 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
@@ -687,7 +687,11 @@ public class CcToolchainFeatures implements Serializable {
private final String name;
private final ImmutableList<FlagSet> flagSets;
private final ImmutableList<EnvSet> envSets;
-
+ private final boolean enabled;
+ private final ImmutableList<ImmutableSet<String>> requires;
+ private final ImmutableList<String> implies;
+ private final ImmutableList<String> provides;
+
private Feature(CToolchain.Feature feature) throws InvalidConfigurationException {
this.name = feature.getName();
ImmutableList.Builder<FlagSet> flagSetBuilder = ImmutableList.builder();
@@ -701,14 +705,35 @@ public class CcToolchainFeatures implements Serializable {
envSetBuilder.add(new EnvSet(flagSet));
}
this.envSets = envSetBuilder.build();
+ this.enabled = feature.getEnabled();
+
+ ImmutableList.Builder<ImmutableSet<String>> requiresBuilder = ImmutableList.builder();
+ for (CToolchain.FeatureSet requiresFeatureSet : feature.getRequiresList()) {
+ ImmutableSet<String> featureSet = ImmutableSet.copyOf(requiresFeatureSet.getFeatureList());
+ requiresBuilder.add(featureSet);
+ }
+ this.requires = requiresBuilder.build();
+ this.implies = ImmutableList.copyOf(feature.getImpliesList());
+ this.provides = ImmutableList.copyOf(feature.getProvidesList());
}
@AutoCodec.Instantiator
@VisibleForSerialization
- Feature(String name, ImmutableList<FlagSet> flagSets, ImmutableList<EnvSet> envSets) {
+ Feature(
+ String name,
+ ImmutableList<FlagSet> flagSets,
+ ImmutableList<EnvSet> envSets,
+ boolean enabled,
+ ImmutableList<ImmutableSet<String>> requires,
+ ImmutableList<String> implies,
+ ImmutableList<String> provides) {
this.name = name;
this.flagSets = flagSets;
this.envSets = envSets;
+ this.enabled = enabled;
+ this.requires = requires;
+ this.implies = implies;
+ this.provides = provides;
}
@Override
@@ -748,14 +773,34 @@ public class CcToolchainFeatures implements Serializable {
Feature that = (Feature) object;
return name.equals(that.name)
&& Iterables.elementsEqual(flagSets, that.flagSets)
- && Iterables.elementsEqual(envSets, that.envSets);
+ && Iterables.elementsEqual(envSets, that.envSets)
+ && Iterables.elementsEqual(requires, that.requires)
+ && Iterables.elementsEqual(implies, that.implies)
+ && Iterables.elementsEqual(provides, that.provides)
+ && enabled == that.enabled;
}
return false;
}
@Override
public int hashCode() {
- return Objects.hash(name, flagSets, envSets);
+ return Objects.hash(name, flagSets, envSets, requires, implies, provides, enabled);
+ }
+
+ boolean isEnabled() {
+ return enabled;
+ }
+
+ public ImmutableList<ImmutableSet<String>> getRequires() {
+ return requires;
+ }
+
+ public ImmutableList<String> getImplies() {
+ return implies;
+ }
+
+ public ImmutableList<String> getProvides() {
+ return provides;
}
}
@@ -840,6 +885,8 @@ public class CcToolchainFeatures implements Serializable {
private final String actionName;
private final ImmutableList<Tool> tools;
private final ImmutableList<FlagSet> flagSets;
+ private final boolean enabled;
+ private final ImmutableList<String> implies;
private ActionConfig(CToolchain.ActionConfig actionConfig, PathFragment crosstoolTop)
throws InvalidConfigurationException {
@@ -870,6 +917,9 @@ public class CcToolchainFeatures implements Serializable {
flagSetBuilder.add(new FlagSet(flagSet, ImmutableSet.of(actionName)));
}
this.flagSets = flagSetBuilder.build();
+
+ this.enabled = actionConfig.getEnabled();
+ this.implies = ImmutableList.copyOf(actionConfig.getImpliesList());
}
@AutoCodec.Instantiator
@@ -878,11 +928,15 @@ public class CcToolchainFeatures implements Serializable {
String configName,
String actionName,
ImmutableList<Tool> tools,
- ImmutableList<FlagSet> flagSets) {
+ ImmutableList<FlagSet> flagSets,
+ boolean enabled,
+ ImmutableList<String> implies) {
this.configName = configName;
this.actionName = actionName;
this.tools = tools;
this.flagSets = flagSets;
+ this.enabled = enabled;
+ this.implies = implies;
}
@Override
@@ -929,6 +983,14 @@ public class CcToolchainFeatures implements Serializable {
actionName, variables, enabledFeatureNames, expander, commandLine);
}
}
+
+ boolean isEnabled() {
+ return enabled;
+ }
+
+ public ImmutableList<String> getImplies() {
+ return implies;
+ }
}
/** A description of how artifacts of a certain type are named. */
@@ -1045,7 +1107,7 @@ public class CcToolchainFeatures implements Serializable {
/** @return the command line for the given {@code action}. */
public List<String> getCommandLine(String action, CcToolchainVariables variables) {
- return getCommandLine(action, variables, null);
+ return getCommandLine(action, variables, /* expander= */ null);
}
public List<String> getCommandLine(
@@ -1230,7 +1292,7 @@ public class CcToolchainFeatures implements Serializable {
Feature feature = new Feature(toolchainFeature);
selectablesBuilder.add(feature);
selectablesByName.put(feature.getName(), feature);
- if (toolchainFeature.getEnabled()) {
+ if (feature.isEnabled()) {
defaultSelectablesBuilder.add(feature.getName());
}
}
@@ -1240,7 +1302,7 @@ public class CcToolchainFeatures implements Serializable {
selectablesBuilder.add(actionConfig);
selectablesByName.put(actionConfig.getName(), actionConfig);
actionConfigsByActionName.put(actionConfig.getActionName(), actionConfig);
- if (toolchainActionConfig.getEnabled()) {
+ if (actionConfig.isEnabled()) {
defaultSelectablesBuilder.add(actionConfig.getName());
}
}