use of com.google.devtools.build.lib.exec.SymlinkTreeHelper in project bazel by bazelbuild.
the class RunCommand method ensureRunfilesBuilt.
/**
* Ensures that runfiles are built for the specified target. If they already
* are, does nothing, otherwise builds them.
*
* @param target the target to build runfiles for.
* @return the path of the runfiles directory.
* @throws CommandException
*/
private Path ensureRunfilesBuilt(CommandEnvironment env, ConfiguredTarget target) throws CommandException {
FilesToRunProvider provider = target.getProvider(FilesToRunProvider.class);
RunfilesSupport runfilesSupport = provider == null ? null : provider.getRunfilesSupport();
if (runfilesSupport == null) {
return env.getWorkingDirectory();
}
Artifact manifest = runfilesSupport.getRunfilesManifest();
PathFragment runfilesDir = runfilesSupport.getRunfilesDirectoryExecPath();
Path workingDir = env.getExecRoot().getRelative(runfilesDir);
// Workspace name directory doesn't exist, so don't add it.
if (target.getConfiguration().runfilesEnabled()) {
workingDir = workingDir.getRelative(runfilesSupport.getRunfiles().getSuffix());
}
// a handy way to check whether runfiles were built or not.
if (!RUNFILES_MANIFEST.matches(manifest.getFilename())) {
// Runfiles already built, nothing to do.
return workingDir;
}
SymlinkTreeHelper helper = new SymlinkTreeHelper(manifest.getPath(), runfilesSupport.getRunfilesDirectory(), false);
helper.createSymlinksUsingCommand(env.getExecRoot(), target.getConfiguration(), env.getBlazeWorkspace().getBinTools());
return workingDir;
}
Aggregations