use of com.google.devtools.build.lib.analysis.config.BuildConfigurationCollection.Transitions in project bazel by bazelbuild.
the class BazelConfigurationCollection method setupTransitions.
static BuildConfiguration setupTransitions(BuildConfiguration targetConfiguration, BuildConfiguration dataConfiguration, BuildConfiguration hostConfiguration, ListMultimap<SplitTransition<?>, BuildConfiguration> splitTransitionsTable) {
Set<BuildConfiguration> allConfigurations = new LinkedHashSet<>();
allConfigurations.add(targetConfiguration);
allConfigurations.add(dataConfiguration);
allConfigurations.add(hostConfiguration);
allConfigurations.addAll(splitTransitionsTable.values());
Table<BuildConfiguration, Transition, ConfigurationHolder> transitionBuilder = HashBasedTable.create();
for (BuildConfiguration from : allConfigurations) {
for (ConfigurationTransition transition : ConfigurationTransition.values()) {
BuildConfiguration to;
if (transition == ConfigurationTransition.HOST) {
to = hostConfiguration;
} else if (transition == ConfigurationTransition.DATA && from == targetConfiguration) {
to = dataConfiguration;
} else {
to = from;
}
transitionBuilder.put(from, transition, new ConfigurationHolder(to));
}
}
// collection.
for (BuildConfiguration config : allConfigurations) {
transitionBuilder.put(config, LipoTransition.LIPO_COLLECTOR, new ConfigurationHolder(config));
transitionBuilder.put(config, LipoTransition.TARGET_CONFIG_FOR_LIPO, new ConfigurationHolder(config.isHostConfiguration() ? null : config));
}
for (BuildConfiguration config : allConfigurations) {
// configuration.
if (config.isHostConfiguration() && config.getTransitions() != null) {
continue;
}
boolean isSplitConfig = splitTransitionsTable.values().contains(config);
// the split transition overwrites the cpu, which it usually does.
if (isSplitConfig && config.getTransitions() != null) {
continue;
}
Transitions outgoingTransitions = new BazelTransitions(config, transitionBuilder.row(config), // DependencyResolver.resolveLateBoundAttributes().
isSplitConfig ? ImmutableListMultimap.<SplitTransition<?>, BuildConfiguration>of() : splitTransitionsTable);
config.setConfigurationTransitions(outgoingTransitions);
}
return targetConfiguration;
}
Aggregations