aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/analysis/RuleContext.java
diff options
context:
space:
mode:
authorGravatar lberki <lberki@google.com>2017-07-13 12:25:47 +0200
committerGravatar László Csomor <laszlocsomor@google.com>2017-07-14 10:49:19 +0200
commit3c1c8e9cb2d73657422c59872c53b55febf5f5d1 (patch)
tree6ba5ffa5a75c3dd7eb33ea0e280e227679314157 /src/main/java/com/google/devtools/build/lib/analysis/RuleContext.java
parent7ced4c04b0f93ad0952e98f1c279406975f7011c (diff)
Add a toolchains= attribute to *_binary, *_test, cc_library and extra_action rules to declare which Make variables they need.
The idea is that they would depend on the future java_runtime_alias / cc_toolchain_alias and similar rules and thus Bazel will know which Make variables they actually need instead of pulling in the whole BuildConfiguration and also making it possible to compute these Make variables during analysis instead of configuration creation. RELNOTES: None. PiperOrigin-RevId: 161785868
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/analysis/RuleContext.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/analysis/RuleContext.java17
1 files changed, 7 insertions, 10 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/RuleContext.java b/src/main/java/com/google/devtools/build/lib/analysis/RuleContext.java
index 8987fedbd8..61daf33027 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/RuleContext.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/RuleContext.java
@@ -96,6 +96,7 @@ import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
@@ -1072,27 +1073,23 @@ public final class RuleContext extends TargetContext
}
public ImmutableMap<String, String> getMakeVariables(Iterable<String> attributeNames) {
- // Using an ImmutableBuilder to complain about duplicate keys. This traversal order of
- // getPrerequisites isn't well-defined, so this makes sure providers don't secretly stomp on
- // each other.
- ImmutableMap.Builder<String, String> makeVariableBuilder = ImmutableMap.builder();
- ImmutableSet.Builder<MakeVariableProvider> makeVariableProvidersBuilder =
- ImmutableSet.builder();
+ ArrayList<MakeVariableProvider> makeVariableProviders = new ArrayList<>();
for (String attributeName : attributeNames) {
// TODO(b/37567440): Remove this continue statement.
if (!attributes().has(attributeName)) {
continue;
}
- makeVariableProvidersBuilder.addAll(
+ Iterables.addAll(makeVariableProviders,
getPrerequisites(attributeName, Mode.TARGET, MakeVariableProvider.SKYLARK_CONSTRUCTOR));
}
- for (MakeVariableProvider makeVariableProvider : makeVariableProvidersBuilder.build()) {
- makeVariableBuilder.putAll(makeVariableProvider.getMakeVariables());
+ LinkedHashMap<String, String> makeVariables = new LinkedHashMap<>();
+ for (MakeVariableProvider makeVariableProvider : makeVariableProviders) {
+ makeVariables.putAll(makeVariableProvider.getMakeVariables());
}
- return makeVariableBuilder.build();
+ return ImmutableMap.copyOf(makeVariables);
}
/**