aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/analysis/config
diff options
context:
space:
mode:
authorGravatar gregce <gregce@google.com>2017-05-04 19:38:07 +0200
committerGravatar Damien Martin-Guillerez <dmarting@google.com>2017-05-04 23:05:59 +0200
commitb71e99b1f3746103e5d6802eebc24096b3494959 (patch)
treed15aedac96b3cfb2dd1e8f5113d6ead3b6dbeedb /src/main/java/com/google/devtools/build/lib/analysis/config
parentee0a8bb7f4a9b8edc3fdb30b4e255cf461415382 (diff)
Implement dynamically configured LIPO builds.
Quick overview: - provide a dynamic interface for getting the artifact owner configuration - provide a (dynamic) RuleTransitionFactory LIPO_ON_DEMAND to replace the (static) RuleClass.Configurator LIPO_ON_DEMAND. Eventually we'll remove the rule class configurator interface entirely. This doesn't actually turn dynamic LIPO on. So the direct effect of this change should be a no-op. The flip will come in a followup change. For now, dynamic LIPO can be triggered with --experimental_dynamic_configs=notrim. PiperOrigin-RevId: 155096056
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/analysis/config')
-rw-r--r--src/main/java/com/google/devtools/build/lib/analysis/config/BuildConfiguration.java64
1 files changed, 52 insertions, 12 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/config/BuildConfiguration.java b/src/main/java/com/google/devtools/build/lib/analysis/config/BuildConfiguration.java
index af68c8b9fa..e942556160 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/config/BuildConfiguration.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/config/BuildConfiguration.java
@@ -200,6 +200,18 @@ public final class BuildConfiguration {
public boolean compatibleWithStrategy(String strategyName) {
return true;
}
+
+ /**
+ * Returns the transition that produces the "artifact owner" for this configuration, or null
+ * if this configuration is its own owner.
+ *
+ * <p>If multiple fragments return the same transition, that transition is only applied
+ * once. Multiple fragments may not return different non-null transitions.
+ */
+ @Nullable
+ public PatchTransition getArtifactOwnerTransition() {
+ return null;
+ }
}
private static final Label convertLabel(String input) throws OptionsParsingException {
@@ -1968,16 +1980,21 @@ public final class BuildConfiguration {
if (currentTransition == ConfigurationTransition.NONE) {
currentTransition = ruleClassTransition;
} else {
- currentTransition = new ComposingSplitTransition(ruleClassTransition,
- currentTransition);
+ currentTransition = new ComposingSplitTransition(currentTransition,
+ ruleClassTransition);
}
}
}
- // We don't support rule class configurators (which may need intermediate configurations to
- // apply). The only current use of that is LIPO, which can't currently be invoked with dynamic
- // configurations (e.g. this code can never get called for LIPO builds). So check that
- // if there is a configurator, it's for LIPO, in which case we can ignore it.
+ /**
+ * Dynamic configurations don't support rule class configurators (which may need intermediate
+ * configurations to apply). The only current use of that is LIPO, which dynamic
+ * configurations have a different code path for:
+ * {@link com.google.devtools.build.lib.rules.cpp.CppRuleClasses.LIPO_ON_DEMAND}.
+ *
+ * So just check that if there is a configurator, it's for LIPO, in which case we can ignore
+ * it.
+ */
if (associatedRule != null) {
@SuppressWarnings("unchecked")
RuleClass.Configurator<?, ?> func =
@@ -2606,15 +2623,38 @@ public final class BuildConfiguration {
}
/**
+ * Returns the transition that produces the "artifact owner" for this configuration, or null
+ * if this configuration is its own owner.
+ *
+ * <p>This is the dynamic configuration version of {@link #getArtifactOwnerConfiguration}.
+ */
+ @Nullable
+ public PatchTransition getArtifactOwnerTransition() {
+ Preconditions.checkState(useDynamicConfigurations());
+ PatchTransition ownerTransition = null;
+ for (Fragment fragment : fragments.values()) {
+ PatchTransition fragmentTransition = fragment.getArtifactOwnerTransition();
+ if (fragmentTransition != null) {
+ if (ownerTransition != null) {
+ Verify.verify(ownerTransition == fragmentTransition,
+ String.format(
+ "cannot determine owner transition: fragments returning both %s and %s",
+ ownerTransition.toString(), fragmentTransition.toString()));
+ }
+ ownerTransition = fragmentTransition;
+ }
+ }
+ return ownerTransition;
+ }
+
+ /**
* See {@code BuildConfigurationCollection.Transitions.getArtifactOwnerConfiguration()}.
+ *
+ * <p>This is the static configuration version of {@link #getArtifactOwnerTransition}.
*/
public BuildConfiguration getArtifactOwnerConfiguration() {
- // Dynamic configurations inherit transitions objects from other configurations exclusively
- // for use of Transitions.getDynamicTransition. No other calls to transitions should be
- // made for dynamic configurations.
- // TODO(bazel-team): enforce the above automatically (without having to explicitly check
- // for dynamic configuration mode).
- return useDynamicConfigurations() ? this : transitions.getArtifactOwnerConfiguration();
+ Preconditions.checkState(!useDynamicConfigurations());
+ return transitions.getArtifactOwnerConfiguration();
}
/**