diff options
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnRunner.java')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnRunner.java | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnRunner.java b/src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnRunner.java index 45ed382569..f6d79ad45c 100644 --- a/src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnRunner.java +++ b/src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnRunner.java @@ -102,6 +102,7 @@ class RemoteSpawnRunner implements SpawnRunner { spawn.getOutputFiles(), Digests.computeDigest(command), repository.getMerkleDigest(inputRoot), + platform, policy.getTimeout()); // Look up action cache, and reuse the action output if it is found. @@ -175,10 +176,11 @@ class RemoteSpawnRunner implements SpawnRunner { } } - private Action buildAction( + static Action buildAction( Collection<? extends ActionInput> outputs, Digest command, Digest inputRoot, + Platform platform, Duration timeout) { Action.Builder action = Action.newBuilder(); action.setCommandDigest(command); @@ -199,13 +201,13 @@ class RemoteSpawnRunner implements SpawnRunner { return action.build(); } - private Command buildCommand(List<String> arguments, ImmutableMap<String, String> environment) { + static Command buildCommand(List<String> arguments, ImmutableMap<String, String> env) { Command.Builder command = Command.newBuilder(); command.addAllArguments(arguments); // Sorting the environment pairs by variable name. - TreeSet<String> variables = new TreeSet<>(environment.keySet()); + TreeSet<String> variables = new TreeSet<>(env.keySet()); for (String var : variables) { - command.addEnvironmentVariablesBuilder().setName(var).setValue(environment.get(var)); + command.addEnvironmentVariablesBuilder().setName(var).setValue(env.get(var)); } return command.build(); } @@ -268,19 +270,22 @@ class RemoteSpawnRunner implements SpawnRunner { return result; } } + List<Path> outputFiles = listExistingOutputFiles(execRoot, spawn); + remoteCache.upload(actionKey, execRoot, outputFiles, policy.getFileOutErr()); + return result; + } + + static List<Path> listExistingOutputFiles(Path execRoot, Spawn spawn) { ArrayList<Path> outputFiles = new ArrayList<>(); for (ActionInput output : spawn.getOutputFiles()) { - Path outputFile = execRoot.getRelative(output.getExecPathString()); - // Ignore non-existent files. - // TODO(ulfjack): This is not ideal - in general, all spawn strategies should stat the - // output files and return a list of existing files. We shouldn't re-stat the files here. - if (!outputFile.exists()) { - continue; + Path outputPath = execRoot.getRelative(output.getExecPathString()); + // TODO(ulfjack): Store the actual list of output files in SpawnResult and use that instead + // of statting the files here again. + if (outputPath.exists()) { + outputFiles.add(outputPath); } - outputFiles.add(outputFile); } - remoteCache.upload(actionKey, execRoot, outputFiles, policy.getFileOutErr()); - return result; + return outputFiles; } /** Release resources associated with this spawn runner. */ |