// Copyright 2017 The Bazel Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package com.google.devtools.build.lib.analysis.config.transitions; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableList; import com.google.devtools.build.lib.analysis.config.BuildOptions; import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec; import java.util.List; /** * A configuration transition that composes two other transitions in an ordered sequence. * *
Example: * *
* transition1: { someSetting = $oldVal + " foo" } * transition2: { someSetting = $oldVal + " bar" } * ComposingSplitTransition(transition1, transition2): { someSetting = $oldVal + " foo bar" } ** *
Child transitions can be {@link SplitTransition}s, {@link PatchTransition}s, or any
* combination thereof. We implement this class as a {@link SplitTransition} since that abstraction
* captures all possible combinations.
*/
@AutoCodec
public class ComposingSplitTransition implements SplitTransition {
private ConfigurationTransition transition1;
private ConfigurationTransition transition2;
@Override
public String getName() {
return "(" + transition1.getName() + " + " + transition2.getName() + ")";
}
/**
* Creates a {@link ComposingSplitTransition} that applies the sequence: {@code fromOptions ->
* transition1 -> transition2 -> toOptions }.
*/
@AutoCodec.Instantiator
public ComposingSplitTransition(
ConfigurationTransition transition1, ConfigurationTransition transition2) {
this.transition1 = verifySupported(transition1);
this.transition2 = verifySupported(transition2);
}
@Override
public List