Skip to content

Commit

Permalink
Simplify naming of transitions in cquery output.
Browse files Browse the repository at this point in the history
Work towards composable starlark transitions: #22248.

PiperOrigin-RevId: 640136865
Change-Id: Ia4d45e20d4a2bbcff2f625e22b9ab53ec81927ba
  • Loading branch information
katre authored and copybara-github committed Jun 4, 2024
1 parent d7cf004 commit 69802ba
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ public static <T extends TransitionFactory.Data> boolean isInstance(
return instance instanceof Factory;
}

/**
* Returns {@code true} if the given {@link ConfigurationTransition} is an instance of the no
* transition.
*/
public static boolean isInstance(ConfigurationTransition transition) {
return transition instanceof NoTransition;
}

/** A {@link TransitionFactory} implementation that generates the no transition. */
@AutoValue
abstract static class Factory<T extends TransitionFactory.Data>
Expand Down
1 change: 0 additions & 1 deletion src/main/java/com/google/devtools/build/lib/query2/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ java_library(
"//src/main/java/com/google/devtools/build/lib/analysis:config/starlark_defined_config_transition",
"//src/main/java/com/google/devtools/build/lib/analysis:config/starlark_transition_cache",
"//src/main/java/com/google/devtools/build/lib/analysis:config/toolchain_type_requirement",
"//src/main/java/com/google/devtools/build/lib/analysis:config/transitions/composing_transition",
"//src/main/java/com/google/devtools/build/lib/analysis:config/transitions/composing_transition_factory",
"//src/main/java/com/google/devtools/build/lib/analysis:config/transitions/configuration_transition",
"//src/main/java/com/google/devtools/build/lib/analysis:config/transitions/no_transition",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import com.google.devtools.build.lib.analysis.config.BuildConfigurationValue;
import com.google.devtools.build.lib.analysis.config.BuildOptions;
import com.google.devtools.build.lib.analysis.config.StarlarkTransitionCache;
import com.google.devtools.build.lib.analysis.config.transitions.ComposingTransition;
import com.google.devtools.build.lib.analysis.config.transitions.ComposingTransitionFactory;
import com.google.devtools.build.lib.analysis.config.transitions.ConfigurationTransition;
import com.google.devtools.build.lib.analysis.config.transitions.NoTransition;
Expand Down Expand Up @@ -273,14 +272,13 @@ private ConfigurationTransition getRuleTransition(CqueryNode configuredTarget) {

private static String getTransitionName(
@Nullable ConfigurationTransition attributeTransition,
@Nullable ConfigurationTransition ruleTransition) {
ConfigurationTransition transition = NoTransition.INSTANCE;
if (attributeTransition != null) {
transition = ComposingTransition.of(transition, attributeTransition);
ConfigurationTransition ruleTransition) {
if (attributeTransition == null || NoTransition.isInstance(attributeTransition)) {
return ruleTransition.getName();
} else if (NoTransition.isInstance(ruleTransition)) {
return attributeTransition.getName();
} else {
return "(" + attributeTransition.getName() + " + " + ruleTransition.getName() + ")";
}
if (ruleTransition != null) {
transition = ComposingTransition.of(transition, ruleTransition);
}
return transition.getName();
}
}

0 comments on commit 69802ba

Please sign in to comment.