use of com.google.devtools.build.lib.vfs.SearchPath in project bazel by bazelbuild.
the class DarwinSandboxedStrategy method getRunUnderPath.
/**
* If a --run_under= option is set and refers to a command via its path (as opposed to via its
* label), we have to mount this. Note that this is best effort and works fine for shell scripts
* and small binaries, but we can't track any further dependencies of this command.
*
* <p>If --run_under= refers to a label, it is automatically provided in the spawn's input files,
* so mountInputs() will catch that case.
*/
private Path getRunUnderPath(Spawn spawn) {
if (spawn.getResourceOwner() instanceof TestRunnerAction) {
TestRunnerAction testRunnerAction = ((TestRunnerAction) spawn.getResourceOwner());
RunUnder runUnder = testRunnerAction.getExecutionSettings().getRunUnder();
if (runUnder != null && runUnder.getCommand() != null) {
PathFragment sourceFragment = new PathFragment(runUnder.getCommand());
Path mount;
if (sourceFragment.isAbsolute()) {
mount = blazeDirs.getFileSystem().getPath(sourceFragment);
} else if (blazeDirs.getExecRoot().getRelative(sourceFragment).exists()) {
mount = blazeDirs.getExecRoot().getRelative(sourceFragment);
} else {
List<Path> searchPath = SearchPath.parse(blazeDirs.getFileSystem(), clientEnv.get("PATH"));
mount = SearchPath.which(searchPath, runUnder.getCommand());
}
// only need to hardlink when under workspace
Path workspace = blazeDirs.getWorkspace();
if (mount != null && mount.startsWith(workspace)) {
return mount;
}
}
}
return null;
}
Aggregations