Also get build-runfiles as an ActionInput for the symlink tree spawn
This isn't strictly necessary since we disable caching and require local
execution.
PiperOrigin-RevId: 187985476
diff --git a/src/main/java/com/google/devtools/build/lib/exec/SymlinkTreeHelper.java b/src/main/java/com/google/devtools/build/lib/exec/SymlinkTreeHelper.java
index 2b47320..143fc97 100644
--- a/src/main/java/com/google/devtools/build/lib/exec/SymlinkTreeHelper.java
+++ b/src/main/java/com/google/devtools/build/lib/exec/SymlinkTreeHelper.java
@@ -89,7 +89,7 @@
public void createSymlinksUsingCommand(
Path execRoot, BuildConfiguration config, BinTools binTools)
throws CommandException {
- List<String> argv = getSpawnArgumentList(execRoot, binTools);
+ List<String> argv = getSpawnArgumentList(execRoot, binTools.getExecPath(BUILD_RUNFILES));
CommandBuilder builder = new CommandBuilder();
builder.addArgs(argv);
builder.setWorkingDir(execRoot);
@@ -128,7 +128,7 @@
} else {
// Pretend we created the runfiles tree by copying the manifest
try {
- FileSystemUtils.createDirectoryAndParents(symlinkTreeRoot);
+ symlinkTreeRoot.createDirectoryAndParents();
FileSystemUtils.copyFile(inputManifest, symlinkTreeRoot.getChild("MANIFEST"));
} catch (IOException e) {
throw new UserExecException(e.getMessage(), e);
@@ -144,15 +144,16 @@
BinTools binTools,
ImmutableMap<String, String> environment,
ActionInput inputManifestArtifact) {
+ ActionInput buildRunfiles = binTools.getActionInput(BUILD_RUNFILES);
return new SimpleSpawn(
owner,
- getSpawnArgumentList(execRoot, binTools),
+ getSpawnArgumentList(execRoot, buildRunfiles.getExecPath()),
environment,
ImmutableMap.of(
ExecutionRequirements.LOCAL, "",
ExecutionRequirements.NO_CACHE, "",
ExecutionRequirements.NO_SANDBOX, ""),
- ImmutableList.of(inputManifestArtifact),
+ ImmutableList.of(inputManifestArtifact, buildRunfiles),
/*outputs=*/ ImmutableList.of(),
RESOURCE_SET);
}
@@ -160,12 +161,9 @@
/**
* Returns the complete argument list build-runfiles has to be called with.
*/
- private ImmutableList<String> getSpawnArgumentList(Path execRoot, BinTools binTools) {
- PathFragment path = binTools.getExecPath(BUILD_RUNFILES);
- Preconditions.checkNotNull(path, BUILD_RUNFILES + " not found in embedded tools");
-
+ private ImmutableList<String> getSpawnArgumentList(Path execRoot, PathFragment buildRunfiles) {
List<String> args = Lists.newArrayList();
- args.add(path.getPathString());
+ args.add(buildRunfiles.getPathString());
if (filesetTree) {
args.add("--allow_relative");
diff --git a/src/test/java/com/google/devtools/build/lib/exec/SymlinkTreeHelperTest.java b/src/test/java/com/google/devtools/build/lib/exec/SymlinkTreeHelperTest.java
index 22bb7f8..808fe36 100644
--- a/src/test/java/com/google/devtools/build/lib/exec/SymlinkTreeHelperTest.java
+++ b/src/test/java/com/google/devtools/build/lib/exec/SymlinkTreeHelperTest.java
@@ -42,6 +42,8 @@
Path execRoot = fs.getPath("/my/workspace");
Path inputManifestPath = execRoot.getRelative("input_manifest");
ActionInput inputManifest = ActionInputHelper.fromPath(inputManifestPath.asFragment());
+ BinTools binTools =
+ BinTools.forUnitTesting(execRoot, ImmutableList.of(SymlinkTreeHelper.BUILD_RUNFILES));
Spawn spawn =
new SymlinkTreeHelper(
inputManifestPath,
@@ -50,7 +52,7 @@
.createSpawn(
owner,
execRoot,
- BinTools.forUnitTesting(execRoot, ImmutableList.of(SymlinkTreeHelper.BUILD_RUNFILES)),
+ binTools,
ImmutableMap.of(),
inputManifest);
assertThat(spawn.getResourceOwner()).isSameAs(owner);
@@ -59,7 +61,8 @@
ExecutionRequirements.LOCAL, "",
ExecutionRequirements.NO_CACHE, "",
ExecutionRequirements.NO_SANDBOX, "");
- assertThat(spawn.getInputFiles()).containsExactly(inputManifest);
+ assertThat(spawn.getInputFiles())
+ .containsExactly(inputManifest, binTools.getActionInput(SymlinkTreeHelper.BUILD_RUNFILES));
// At this time, the spawn does not declare any output files.
assertThat(spawn.getOutputFiles()).isEmpty();
}