Search in sources :

Example 1 with Transition

use of com.google.devtools.build.lib.packages.Attribute.Transition 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;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) BuildConfiguration(com.google.devtools.build.lib.analysis.config.BuildConfiguration) AppleCrosstoolSplitTransition(com.google.devtools.build.lib.rules.objc.AppleCrosstoolSplitTransition) SplitTransition(com.google.devtools.build.lib.packages.Attribute.SplitTransition) Transitions(com.google.devtools.build.lib.analysis.config.BuildConfigurationCollection.Transitions) AppleCrosstoolSplitTransition(com.google.devtools.build.lib.rules.objc.AppleCrosstoolSplitTransition) LipoTransition(com.google.devtools.build.lib.rules.cpp.CppRuleClasses.LipoTransition) ConfigurationTransition(com.google.devtools.build.lib.packages.Attribute.ConfigurationTransition) SplitTransition(com.google.devtools.build.lib.packages.Attribute.SplitTransition) AppleCrosstoolTransition(com.google.devtools.build.lib.rules.objc.AppleCrosstoolTransition) Transition(com.google.devtools.build.lib.packages.Attribute.Transition) ConfigurationHolder(com.google.devtools.build.lib.analysis.config.BuildConfigurationCollection.ConfigurationHolder) ConfigurationTransition(com.google.devtools.build.lib.packages.Attribute.ConfigurationTransition)

Aggregations

BuildConfiguration (com.google.devtools.build.lib.analysis.config.BuildConfiguration)1 ConfigurationHolder (com.google.devtools.build.lib.analysis.config.BuildConfigurationCollection.ConfigurationHolder)1 Transitions (com.google.devtools.build.lib.analysis.config.BuildConfigurationCollection.Transitions)1 ConfigurationTransition (com.google.devtools.build.lib.packages.Attribute.ConfigurationTransition)1 SplitTransition (com.google.devtools.build.lib.packages.Attribute.SplitTransition)1 Transition (com.google.devtools.build.lib.packages.Attribute.Transition)1 LipoTransition (com.google.devtools.build.lib.rules.cpp.CppRuleClasses.LipoTransition)1 AppleCrosstoolSplitTransition (com.google.devtools.build.lib.rules.objc.AppleCrosstoolSplitTransition)1 AppleCrosstoolTransition (com.google.devtools.build.lib.rules.objc.AppleCrosstoolTransition)1 LinkedHashSet (java.util.LinkedHashSet)1