Changes SplitTransition#split's return type to Map and updates the current native implementations to return CPU-based keys. Lists returned by Starlark transitions are automatically keyed by indexes.
This change relands https://github.com/bazelbuild/bazel/commit/528cb62caa4a742c9918d984d929fe8662a539df with a fix to the duplicate map key issue in the new objc handling code. Other parts of the change are free of the problem because they already deduplicate CPU flag values with ImmutableSortedSet. Added a test case to ObjcSkylarkTest.java and ran TGP with no suspicious results found.
RELNOTES: None
PiperOrigin-RevId: 293656453
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 d2d4b80..b1b13d0 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
@@ -909,16 +909,16 @@
.executionPlatform(getToolchainContext().executionPlatform().label())
.build());
BuildOptions fromOptions = getConfiguration().getOptions();
- List<BuildOptions> splitOptions = transition.split(fromOptions);
+ Map<String, BuildOptions> splitOptions = transition.split(fromOptions);
List<ConfiguredTargetAndData> deps = getConfiguredTargetAndTargetDeps(attributeName);
- if (SplitTransition.equals(fromOptions, splitOptions)) {
+ if (SplitTransition.equals(fromOptions, splitOptions.values())) {
// The split transition is not active. Defer the decision on which CPU to use.
return ImmutableMap.of(Optional.<String>absent(), deps);
}
Set<String> cpus = new HashSet<>();
- for (BuildOptions options : splitOptions) {
+ for (BuildOptions options : splitOptions.values()) {
// This method should only be called when the split config is enabled on the command line, in
// which case this cpu can't be null.
cpus.add(options.get(CoreOptions.class).cpu);