Update BazelStrategyModule to use registry methods instead of executorInit where possible.
Part of the roll-forward of
@@ -19,8 +19,9 @@ import com.google.devtools.build.lib.analysis.actions.FileWriteActionContext;
import com.google.devtools.build.lib.analysis.actions.TemplateExpansionContext;
import com.google.devtools.build.lib.buildtool.BuildRequest;
import com.google.devtools.build.lib.exec.ExecutionOptions;
-import com.google.devtools.build.lib.exec.ExecutorBuilder;
+import com.google.devtools.build.lib.exec.ModuleActionContextRegistry;
import com.google.devtools.build.lib.exec.SpawnCache;
+import com.google.devtools.build.lib.exec.SpawnStrategyRegistry;
import com.google.devtools.build.lib.remote.RemoteModule;
import com.google.devtools.build.lib.remote.options.RemoteOptions;
import com.google.devtools.build.lib.rules.cpp.CppIncludeExtractionContext;
@@ -45,7 +46,21 @@ public class BazelStrategyModule extends BlazeModule {
}
@Override
- public void executorInit(CommandEnvironment env, BuildRequest request, ExecutorBuilder builder) {
+ public void registerActionContexts(
+ ModuleActionContextRegistry.Builder registryBuilder,
+ CommandEnvironment env,
+ BuildRequest buildRequest) {
+ registryBuilder
+ .restrictTo(CppIncludeExtractionContext.class, "")
+ .restrictTo(CppIncludeScanningContext.class, "")
+ .restrictTo(FileWriteActionContext.class, "")
+ .restrictTo(TemplateExpansionContext.class, "")
+ .restrictTo(SpawnCache.class, "");
+ }
+
+ @Override
+ public void registerSpawnStrategies(
+ SpawnStrategyRegistry.Builder registryBuilder, CommandEnvironment env) {
ExecutionOptions options = env.getOptions().getOptions(ExecutionOptions.class);
RemoteOptions remoteOptions = env.getOptions().getOptions(RemoteOptions.class);
@@ -62,25 +77,18 @@ public class BazelStrategyModule extends BlazeModule {
}
spawnStrategies.add("local");
}
+ registryBuilder.setDefaultStrategies(spawnStrategies);
- // Allow genrule_strategy to also be overridden by --strategy= flags.
- builder.addStrategyByMnemonic("Genrule", options.genruleStrategy);
+ // By adding this filter before the ones derived from --strategy the latter can override the
+ // former.
+ registryBuilder.addMnemonicFilter("Genrule", options.genruleStrategy);
for (Map.Entry<String, List<String>> strategy : options.strategy) {
- builder.addStrategyByMnemonic(strategy.getKey(), strategy.getValue());
+ registryBuilder.addMnemonicFilter(strategy.getKey(), strategy.getValue());
}
- builder.addStrategyByMnemonic("", spawnStrategies);
-
for (Map.Entry<RegexFilter, List<String>> entry : options.strategyByRegexp) {
- builder.addStrategyByRegexp(entry.getKey(), entry.getValue());
+ registryBuilder.addDescriptionFilter(entry.getKey(), entry.getValue());
}
-
- builder
- .addStrategyByContext(CppIncludeExtractionContext.class, "")
- .addStrategyByContext(CppIncludeScanningContext.class, "")
- .addStrategyByContext(FileWriteActionContext.class, "")
- .addStrategyByContext(TemplateExpansionContext.class, "")
- .addStrategyByContext(SpawnCache.class, "");
}
}
