Skip to content

Commit

Permalink
Capture build-runfiles output.
Browse files Browse the repository at this point in the history
As bazelbuild#6176 shows, it's very hard to debug runfiles building failures when all output is eaten.

Closes bazelbuild#6305.

PiperOrigin-RevId: 216717016
  • Loading branch information
benjaminp authored and Copybara-Service committed Oct 11, 2018
1 parent 324e71e commit c63e4fe
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@
import com.google.devtools.build.lib.actions.SimpleSpawn;
import com.google.devtools.build.lib.actions.Spawn;
import com.google.devtools.build.lib.actions.UserExecException;
import com.google.devtools.build.lib.shell.Command;
import com.google.devtools.build.lib.shell.CommandException;
import com.google.devtools.build.lib.util.CommandBuilder;
import com.google.devtools.build.lib.util.CommandUtils;
import com.google.devtools.build.lib.util.OsUtils;
import com.google.devtools.build.lib.util.io.OutErr;
import com.google.devtools.build.lib.vfs.FileSystemUtils;
import com.google.devtools.build.lib.vfs.Path;
import com.google.devtools.build.lib.vfs.PathFragment;
Expand Down Expand Up @@ -85,16 +87,20 @@ public Path getOutputManifest() {
* @throws CommandException
*/
public void createSymlinksUsingCommand(
Path execRoot, BinTools binTools, ImmutableMap<String, String> shellEnvironment)
Path execRoot,
BinTools binTools,
ImmutableMap<String, String> shellEnvironment,
OutErr outErr)
throws CommandException {
List<String> argv = getSpawnArgumentList(execRoot, binTools.getExecPath(BUILD_RUNFILES));
Preconditions.checkNotNull(shellEnvironment);
new CommandBuilder()
.addArgs(argv)
.setWorkingDir(execRoot)
.setEnv(shellEnvironment)
.build()
.execute();
Command command =
new CommandBuilder().addArgs(argv).setWorkingDir(execRoot).setEnv(shellEnvironment).build();
if (outErr != null) {
command.execute(outErr.getOutputStream(), outErr.getErrorStream());
} else {
command.execute();
}
}

/**
Expand All @@ -115,7 +121,10 @@ public void createSymlinks(
if (enableRunfiles) {
try {
createSymlinksUsingCommand(
actionExecutionContext.getExecRoot(), binTools, shellEnvironment);
actionExecutionContext.getExecRoot(),
binTools,
shellEnvironment,
actionExecutionContext.getFileOutErr());
} catch (CommandException e) {
throw new UserExecException(CommandUtils.describeCommandFailure(true, e), e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,8 @@ private Path ensureRunfilesBuilt(CommandEnvironment env, RunfilesSupport runfile
runfilesSupport.getRunfilesDirectory(),
false);
helper.createSymlinksUsingCommand(
env.getExecRoot(), env.getBlazeWorkspace().getBinTools(), ImmutableMap.of());
env.getExecRoot(), env.getBlazeWorkspace().getBinTools(),
/* shellEnvironment= */ ImmutableMap.of(), /* outErr= */ null);
return workingDir;
}

Expand Down

0 comments on commit c63e4fe

Please sign in to comment.