Skip to content

Commit

Permalink
Thread new incompatible flag into creation of execution transitions d…
Browse files Browse the repository at this point in the history
…uring rule creation.

Part of work on execution transitions, bazelbuild#7935.

PiperOrigin-RevId: 257036118
  • Loading branch information
katre authored and irengrig committed Jul 15, 2019
1 parent d087d0a commit c428db5
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ public static class Builder implements RuleDefinitionEnvironment {

private ThirdPartyLicenseExistencePolicy thirdPartyLicenseExistencePolicy =
ThirdPartyLicenseExistencePolicy.USER_CONTROLLABLE;
private boolean enableExecutionTransition = false;

public Builder addWorkspaceFilePrefix(String contents) {
defaultWorkspaceFilePrefix.append(contents);
Expand Down Expand Up @@ -456,6 +457,16 @@ public Builder setShouldInvalidateCacheForOptionDiff(
return this;
}

@Override
public boolean enableExecutionTransition() {
return enableExecutionTransition;
}

public Builder enableExecutionTransition(boolean flag) {
this.enableExecutionTransition = flag;
return this;
}

/**
* Overrides the predicate which determines whether the analysis cache should be invalidated for
* the given options diff.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,7 @@ public interface RuleDefinitionEnvironment {
* Returns the tools repository prefix.
*/
String getToolsRepository();

/** Returns whether the execution transition should be enabled. */
boolean enableExecutionTransition();
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,19 @@
*/
public class ExecutionTransitionFactory implements TransitionFactory<AttributeTransitionData> {

/**
* Returns either a new {@link ExecutionTransitionFactory} or a factory for the {@link
* HostTransition}, depending on the value of {@code enableExecutionTransition}.
*/
public static TransitionFactory<AttributeTransitionData> create(
boolean enableExecutionTransition) {
if (enableExecutionTransition) {
return new ExecutionTransitionFactory();
} else {
return HostTransition.createFactory();
}
}

@Override
public PatchTransition create(AttributeTransitionData data) {
return new ExecutionTransition(data.executionPlatform());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1488,6 +1488,12 @@ public BlazeRuntime build() throws AbruptExitException {

ConfiguredRuleClassProvider.Builder ruleClassBuilder =
new ConfiguredRuleClassProvider.Builder();
BlazeServerStartupOptions blazeServerStartupOptions =
startupOptionsProvider.getOptions(BlazeServerStartupOptions.class);
if (blazeServerStartupOptions != null) {
ruleClassBuilder.enableExecutionTransition(
blazeServerStartupOptions.enableExecutionTransition);
}
for (BlazeModule module : blazeModules) {
module.initializeRuleClasses(ruleClassBuilder);
}
Expand Down

0 comments on commit c428db5

Please sign in to comment.