Skip to content

Commit

Permalink
Also get build-runfiles as an ActionInput for the symlink tree spawn
Browse files Browse the repository at this point in the history
This isn't strictly necessary since we disable caching and require local
execution.

PiperOrigin-RevId: 187985476
  • Loading branch information
ulfjack authored and Copybara-Service committed Mar 6, 2018
1 parent b5a575a commit d3dd6a1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public Path getOutputManifest() {
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);
Expand Down Expand Up @@ -128,7 +128,7 @@ public List<SpawnResult> createSymlinks(
} 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);
Expand All @@ -144,28 +144,26 @@ Spawn createSpawn(
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);
}

/**
* 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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ public void checkCreatedSpawn() {
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,
Expand All @@ -50,7 +52,7 @@ public void checkCreatedSpawn() {
.createSpawn(
owner,
execRoot,
BinTools.forUnitTesting(execRoot, ImmutableList.of(SymlinkTreeHelper.BUILD_RUNFILES)),
binTools,
ImmutableMap.of(),
inputManifest);
assertThat(spawn.getResourceOwner()).isSameAs(owner);
Expand All @@ -59,7 +61,8 @@ public void checkCreatedSpawn() {
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();
}
Expand Down

0 comments on commit d3dd6a1

Please sign in to comment.