Skip to content

Commit

Permalink
make sure IdempotencyChecker use the correct rule transition and remo…
Browse files Browse the repository at this point in the history
…ve redundant computeTransition calls.

PiperOrigin-RevId: 559252770
Change-Id: Iab6c893c25aae081ff35407c6650b12bdd214607
  • Loading branch information
Googler authored and copybara-github committed Aug 22, 2023
1 parent 171aae3 commit 34c5ef2
Showing 1 changed file with 18 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -229,14 +229,7 @@ private StateMachine determineConfiguration(Tasks tasks) {
return DONE;
}

ConfigurationTransition transition =
computeTransition(target.getAssociatedRule(), trimmingTransitionFactory);
if (transition == null) {
lookUpConfigurationValue(tasks);
return DONE;
}

return new RuleTransitionApplier(transition);
return new RuleTransitionApplier();
}

private void delegateTo(Tasks tasks, ActionLookupKey delegate) {
Expand Down Expand Up @@ -274,19 +267,12 @@ private class RuleTransitionApplier
TransitionApplier.ResultSink,
ConfigConditionsProducer.ResultSink,
PlatformInfoProducer.ResultSink {
// -------------------- Input --------------------
private final ConfigurationTransition transition;
// -------------------- Internal State --------------------
private BuildConfigurationKey configurationKey;

private RuleTransitionApplier(ConfigurationTransition transition) {
this.transition = transition;
}

private ConfigConditions configConditions;

@Nullable private PlatformInfo platformInfo;

private ConfigConditions configConditions;
private ConfigurationTransition ruleTransition;
private BuildConfigurationKey configurationKey;

@Override
public StateMachine step(Tasks tasks) throws InterruptedException {

Expand Down Expand Up @@ -316,6 +302,7 @@ public StateMachine step(Tasks tasks) throws InterruptedException {
return DONE;
}

// TODO: @aranguyen b/297077082
public UnloadedToolchainContextsInputs getUnloadedToolchainContextsInputs(
Target target, @Nullable Label parentExecutionPlatformLabel) throws InterruptedException {
if (!(target instanceof Rule)) {
Expand Down Expand Up @@ -450,6 +437,7 @@ private ImmutableSet<Label> getExecutionPlatformConstraints(

@CanIgnoreReturnValue
public StateMachine computeConfigConditions(Tasks tasks) {
// TODO @aranguyen b/297077082
tasks.enqueue(
new ConfigConditionsProducer(
target,
Expand Down Expand Up @@ -488,9 +476,17 @@ public StateMachine computeTransition(Tasks tasks) {
transition = trimmingTransition;
}
}

if (transition == null) {
lookUpConfigurationValue(tasks);
return DONE;
}

this.ruleTransition = transition;

return new TransitionApplier(
preRuleTransitionKey.getConfigurationKey(),
transition,
ruleTransition,
transitionCache,
(TransitionApplier.ResultSink) this,
eventHandler,
Expand Down Expand Up @@ -592,7 +588,7 @@ private class IdempotencyChecker implements StateMachine, TransitionApplier.Resu
public StateMachine step(Tasks tasks) {
return new TransitionApplier(
configurationKey,
transition,
ruleTransition,
transitionCache,
(TransitionApplier.ResultSink) this,
eventHandler,
Expand Down Expand Up @@ -683,6 +679,7 @@ public static DetailedExitCode createDetailedExitCode(String message) {
}

// Public for Cquery.
// TODO: @aranguyen keep cquery in sync with ConfiguredTargetFunction
@Nullable
public static ConfigurationTransition computeTransition(
Rule rule, @Nullable TransitionFactory<RuleTransitionData> trimmingTransitionFactory) {
Expand Down

0 comments on commit 34c5ef2

Please sign in to comment.