diff options
author | 2018-03-06 00:49:37 -0800 | |
---|---|---|
committer | 2018-03-06 00:51:47 -0800 | |
commit | d3dd6a1318a4019747f49abf451a35f6a8f2b243 (patch) | |
tree | f60613e8fce6346315bdc4039b1d19a1b522de22 | |
parent | b5a575afd7534c9d963273c3789bbba80f2994fa (diff) |
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
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/exec/SymlinkTreeHelper.java | 16 | ||||
-rw-r--r-- | src/test/java/com/google/devtools/build/lib/exec/SymlinkTreeHelperTest.java | 7 |
2 files changed, 12 insertions, 11 deletions
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 2b473202b1..143fc971e2 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 final class SymlinkTreeHelper { 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 @@ public final class SymlinkTreeHelper { } 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 @@ public final class SymlinkTreeHelper { 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 @@ public final class SymlinkTreeHelper { /** * 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 22bb7f8961..808fe36027 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 @@ public final class SymlinkTreeHelperTest { 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 @@ public final class SymlinkTreeHelperTest { .createSpawn( owner, execRoot, - BinTools.forUnitTesting(execRoot, ImmutableList.of(SymlinkTreeHelper.BUILD_RUNFILES)), + binTools, ImmutableMap.of(), inputManifest); assertThat(spawn.getResourceOwner()).isSameAs(owner); @@ -59,7 +61,8 @@ public final class SymlinkTreeHelperTest { 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(); } |