aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/analysis/config/ComposingRuleTransitionFactory.java
diff options
context:
space:
mode:
authorGravatar gregce <gregce@google.com>2017-07-06 22:51:30 -0400
committerGravatar John Cater <jcater@google.com>2017-07-07 07:08:43 -0400
commit692f763fe7bfb36610a711a4ca05194db721a34b (patch)
treea0b5c9339913a649b1c07a03ac3de6af5eb9d65e /src/main/java/com/google/devtools/build/lib/analysis/config/ComposingRuleTransitionFactory.java
parent6cfffdf37e11018c7e6e2cabc90440d6d29c819b (diff)
Replace Transitions.configurationHook with equivalent rule class transitions.
This removes the last dynamic dependency on the static configuration transition table. PiperOrigin-RevId: 161162272
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/analysis/config/ComposingRuleTransitionFactory.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/analysis/config/ComposingRuleTransitionFactory.java45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/config/ComposingRuleTransitionFactory.java b/src/main/java/com/google/devtools/build/lib/analysis/config/ComposingRuleTransitionFactory.java
new file mode 100644
index 0000000000..3cc2ff71f4
--- /dev/null
+++ b/src/main/java/com/google/devtools/build/lib/analysis/config/ComposingRuleTransitionFactory.java
@@ -0,0 +1,45 @@
+// 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;
+
+import com.google.devtools.build.lib.packages.Attribute;
+import com.google.devtools.build.lib.packages.Rule;
+import com.google.devtools.build.lib.packages.RuleTransitionFactory;
+
+/**
+ * A {@link RuleTransitionFactory} that composes other {@link RuleTransitionFactory}s.
+ */
+public class ComposingRuleTransitionFactory implements RuleTransitionFactory {
+
+ private final RuleTransitionFactory rtf1;
+ private final RuleTransitionFactory rtf2;
+
+ /**
+ * Creates a factory that applies the given factories in-order ({@code rtf1} first,
+ * {@code rtf2} second).
+ */
+ public ComposingRuleTransitionFactory(RuleTransitionFactory rtf1, RuleTransitionFactory rtf2) {
+ this.rtf1 = rtf1;
+ this.rtf2 = rtf2;
+ }
+
+ @Override
+ public Attribute.Transition buildTransitionFor(Rule rule) {
+ return new ComposingPatchTransition(
+ (PatchTransition) rtf1.buildTransitionFor(rule),
+ (PatchTransition) rtf2.buildTransitionFor(rule));
+ }
+}