aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchainFeatures.java
diff options
context:
space:
mode:
authorGravatar Googler <noreply@google.com>2016-08-23 15:36:49 +0000
committerGravatar John Cater <jcater@google.com>2016-08-23 22:57:59 +0000
commitb6fd4ed25b6201eaaabb14c389c02819184ad4a6 (patch)
tree280e7d87dd6455377a0817c56ab2e6d8b9de1474 /src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchainFeatures.java
parent1077038d02a4151e156622076896eca1e4f28726 (diff)
Prune .pcm files based on the results of include scanning.
Basically, take the set of headers found by #include scanning and check what modules they are coming from. If a module provides at least one of the required headers, it is required as are all of its dependent modules (because of the way modules are implemented). Only use the actually required modules as compilation inputs and as flags handed in on the command line. Also move the logic to calculate top-level modules from the analysis phase into the execution phase. In the long run, we might be able to completely remove this logic now, but for now, we want to be able to quickly switch between the old and the new behavior. Thus, pruning of modules is now guarded on a feature prune_module_headers. -- MOS_MIGRATED_REVID=131058820
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchainFeatures.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchainFeatures.java19
1 files changed, 14 insertions, 5 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 02f1f950a3..bcb97ce22d 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
@@ -26,6 +26,7 @@ import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
+import com.google.common.collect.Maps;
import com.google.devtools.build.lib.analysis.config.InvalidConfigurationException;
import com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable;
import com.google.devtools.build.lib.vfs.PathFragment;
@@ -871,8 +872,8 @@ public class CcToolchainFeatures implements Serializable {
* Builder for {@code Variables}.
*/
public static class Builder {
- private final ImmutableMap.Builder<String, String> variables = ImmutableMap.builder();
- private final ImmutableMap.Builder<String, Sequence> expandables = ImmutableMap.builder();
+ private final Map<String, String> variables = Maps.newLinkedHashMap();
+ private final Map<String, Sequence> expandables = Maps.newLinkedHashMap();
/**
* Add a variable that expands {@code name} to {@code value}.
@@ -899,6 +900,15 @@ public class CcToolchainFeatures implements Serializable {
}
/**
+ * Adds all variables to this builder.
+ */
+ public Builder addAll(Variables variables) {
+ this.variables.putAll(variables.variables);
+ this.expandables.putAll(variables.sequenceVariables);
+ return this;
+ }
+
+ /**
* Add a variable that expands a flag group containing a reference to {@code name} for each
* entry in {@code values}.
*/
@@ -914,7 +924,7 @@ public class CcToolchainFeatures implements Serializable {
* @return a new {@Variables} object.
*/
Variables build() {
- return new Variables(variables.build(), expandables.build());
+ return new Variables(ImmutableMap.copyOf(variables), ImmutableMap.copyOf(expandables));
}
}
@@ -932,7 +942,7 @@ public class CcToolchainFeatures implements Serializable {
interface View {
/**
- * Returns all bounds variables in the current view.
+ * Returns all bound variables in the current view.
*/
Map<String, String> getVariables();
@@ -1250,7 +1260,6 @@ public class CcToolchainFeatures implements Serializable {
*
* @param toolchain the toolchain configuration as specified by the user.
* @throws InvalidConfigurationException if the configuration has logical errors.
- * @throws ArtifactNamePatternNotProvidedException
*/
@VisibleForTesting
public CcToolchainFeatures(CToolchain toolchain) throws InvalidConfigurationException {