diff --git a/src/main/java/com/google/devtools/build/lib/analysis/actions/PathMappers.java b/src/main/java/com/google/devtools/build/lib/analysis/actions/PathMappers.java index f0d52883152cef..9ccfd15c105d66 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/actions/PathMappers.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/actions/PathMappers.java @@ -36,7 +36,8 @@ * PathMapper}). */ public final class PathMappers { - // TODO: Replace with a command-line flag. + // TODO: Remove actions from this list by adding ExecutionRequirements.SUPPORTS_PATH_MAPPING to + // their execution info instead. private static final ImmutableSet SUPPORTED_MNEMONICS = ImmutableSet.of( "AndroidLint", @@ -45,8 +46,6 @@ public final class PathMappers { "DejetifySrcs", "Desugar", "DexBuilder", - "Javac", - "JavacTurbine", "Jetify", "JetifySrcs", "LinkAndroidResources", @@ -56,8 +55,6 @@ public final class PathMappers { "StarlarkAARGenerator", "StarlarkMergeCompiledAndroidResources", "StarlarkRClassGenerator", - "Turbine", - "JavaResourceJar", "Mock action"); /** diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/JavaCompilationHelper.java b/src/main/java/com/google/devtools/build/lib/rules/java/JavaCompilationHelper.java index 984065b31e65a1..c00f413af1597f 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/java/JavaCompilationHelper.java +++ b/src/main/java/com/google/devtools/build/lib/rules/java/JavaCompilationHelper.java @@ -416,24 +416,26 @@ private boolean separateResourceJar( } private ImmutableMap getExecutionInfo() throws RuleErrorException { - ImmutableMap.Builder executionInfo = ImmutableMap.builder(); - ImmutableMap.Builder workerInfo = ImmutableMap.builder(); + ImmutableMap.Builder modifiableExecutionInfo = ImmutableMap.builder(); + modifiableExecutionInfo.put(ExecutionRequirements.SUPPORTS_PATH_MAPPING, "1"); if (javaToolchain.getJavacSupportsWorkers()) { - workerInfo.put(ExecutionRequirements.SUPPORTS_WORKERS, "1"); + modifiableExecutionInfo.put(ExecutionRequirements.SUPPORTS_WORKERS, "1"); } if (javaToolchain.getJavacSupportsMultiplexWorkers()) { - workerInfo.put(ExecutionRequirements.SUPPORTS_MULTIPLEX_WORKERS, "1"); + modifiableExecutionInfo.put(ExecutionRequirements.SUPPORTS_MULTIPLEX_WORKERS, "1"); } if (javaToolchain.getJavacSupportsWorkerCancellation()) { - workerInfo.put(ExecutionRequirements.SUPPORTS_WORKER_CANCELLATION, "1"); + modifiableExecutionInfo.put(ExecutionRequirements.SUPPORTS_WORKER_CANCELLATION, "1"); } + ImmutableMap.Builder executionInfo = ImmutableMap.builder(); executionInfo.putAll( getConfiguration() - .modifiedExecutionInfo(workerInfo.buildOrThrow(), JavaCompileActionBuilder.MNEMONIC)); + .modifiedExecutionInfo( + modifiableExecutionInfo.buildOrThrow(), JavaCompileActionBuilder.MNEMONIC)); executionInfo.putAll( TargetUtils.getExecutionInfo(ruleContext.getRule(), ruleContext.isAllowTagsPropagation())); - return executionInfo.buildOrThrow(); + return executionInfo.buildKeepingLast(); } /** Returns the bootclasspath explicit set in attributes if present, or else the default. */ diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/JavaCompileAction.java b/src/main/java/com/google/devtools/build/lib/rules/java/JavaCompileAction.java index 3deb37b52aa358..f60d3581ffb4f5 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/java/JavaCompileAction.java +++ b/src/main/java/com/google/devtools/build/lib/rules/java/JavaCompileAction.java @@ -171,8 +171,6 @@ public JavaCompileAction( } this.tools = tools; this.compilationType = compilationType; - // TODO(djasper): The only thing that is conveyed through the executionInfo is whether worker - // mode is enabled or not. Investigate whether we can store just that. this.executionInfo = configuration.modifiedExecutionInfo(executionInfo, compilationType.mnemonic); this.executableLine = executableLine; diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/JavaHeaderCompileAction.java b/src/main/java/com/google/devtools/build/lib/rules/java/JavaHeaderCompileAction.java index ec7064c6d6b6b3..5dfc7dbaf80f27 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/java/JavaHeaderCompileAction.java +++ b/src/main/java/com/google/devtools/build/lib/rules/java/JavaHeaderCompileAction.java @@ -75,6 +75,8 @@ */ public final class JavaHeaderCompileAction extends SpawnAction { + private static final String DIRECT_CLASSPATH_MNEMONIC = "Turbine"; + private final boolean insertDependencies; private final NestedSet additionalArtifactsForPathMapping; @@ -462,14 +464,22 @@ public void build(JavaToolchainProvider javaToolchain) throws RuleErrorException } } - ImmutableMap executionInfo = - TargetUtils.getExecutionInfo(ruleContext.getRule(), ruleContext.isAllowTagsPropagation()); + ImmutableMap.Builder executionInfo = ImmutableMap.builder(); + executionInfo.putAll( + ruleContext + .getConfiguration() + .modifiedExecutionInfo( + ImmutableMap.of(ExecutionRequirements.SUPPORTS_PATH_MAPPING, "1"), + JavaCompileActionBuilder.MNEMONIC)); + executionInfo.putAll( + TargetUtils.getExecutionInfo( + ruleContext.getRule(), ruleContext.isAllowTagsPropagation())); if (javaConfiguration.inmemoryJdepsFiles()) { - executionInfo = - ImmutableMap.of( - ExecutionRequirements.REMOTE_EXECUTION_INLINE_OUTPUTS, - outputDepsProto.getExecPathString()); + executionInfo.put( + ExecutionRequirements.REMOTE_EXECUTION_INLINE_OUTPUTS, + outputDepsProto.getExecPathString()); } + if (useDirectClasspath) { NestedSet classpath; NestedSet additionalArtifactsForPathMapping; @@ -509,9 +519,11 @@ public void build(JavaToolchainProvider javaToolchain) throws RuleErrorException /* env= */ actionEnvironment, /* executionInfo= */ ruleContext .getConfiguration() - .modifiedExecutionInfo(executionInfo, "Turbine"), + .modifiedExecutionInfo( + executionInfo.buildKeepingLast(), DIRECT_CLASSPATH_MNEMONIC), /* progressMessage= */ progressMessage, - /* mnemonic= */ "Turbine", + + /* mnemonic= */ DIRECT_CLASSPATH_MNEMONIC, /* outputPathsMode= */ PathMappers.getOutputPathsMode( ruleContext.getConfiguration()), // If classPathMode == BAZEL, also make sure to inject the dependencies to be @@ -558,7 +570,7 @@ public void build(JavaToolchainProvider javaToolchain) throws RuleErrorException /* transitiveInputs= */ classpathEntries, /* directJars= */ directJars, /* outputs= */ outputs.build(), - /* executionInfo= */ executionInfo, + /* executionInfo= */ executionInfo.buildKeepingLast(), /* extraActionInfoSupplier= */ null, /* executableLine= */ executableLine, /* flagLine= */ commandLine.build(), diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/ResourceJarActionBuilder.java b/src/main/java/com/google/devtools/build/lib/rules/java/ResourceJarActionBuilder.java index 4cf8599282af34..4ee22dd6d081e8 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/java/ResourceJarActionBuilder.java +++ b/src/main/java/com/google/devtools/build/lib/rules/java/ResourceJarActionBuilder.java @@ -20,6 +20,7 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; import com.google.devtools.build.lib.actions.Artifact; +import com.google.devtools.build.lib.actions.ExecutionRequirements; import com.google.devtools.build.lib.actions.ParamFileInfo; import com.google.devtools.build.lib.actions.ParameterFile.ParameterFileType; import com.google.devtools.build.lib.analysis.RuleContext; @@ -39,6 +40,8 @@ public class ResourceJarActionBuilder { private static final ParamFileInfo PARAM_FILE_INFO = ParamFileInfo.builder(ParameterFileType.SHELL_QUOTED).build(); + private static final ImmutableMap EXECUTION_INFO = + ImmutableMap.of(ExecutionRequirements.SUPPORTS_PATH_MAPPING, "1"); private Artifact outputJar; private Map resources = ImmutableMap.of(); @@ -125,6 +128,7 @@ public void build(JavaSemantics semantics, RuleContext ruleContext, String execG .addCommandLine(command.build(), PARAM_FILE_INFO) .setProgressMessage("Building Java resource jar") .setMnemonic(MNEMONIC) + .setExecutionInfo(EXECUTION_INFO) .setExecGroup(execGroup) .build(ruleContext)); }