use of com.google.devtools.build.lib.vfs.Path in project bazel by bazelbuild.
the class TestStrategy method getLocalRunfilesDirectory.
/**
* Returns the runfiles directory associated with the test executable, creating/updating it if
* necessary and --build_runfile_links is specified.
*/
protected static Path getLocalRunfilesDirectory(TestRunnerAction testAction, ActionExecutionContext actionExecutionContext, BinTools binTools, ImmutableMap<String, String> shellEnvironment, boolean enableRunfiles) throws ExecException, InterruptedException {
TestTargetExecutionSettings execSettings = testAction.getExecutionSettings();
Path runfilesDir = execSettings.getRunfilesDir();
// as a flag to the build.
if (execSettings.getRunfilesSymlinksCreated()) {
return runfilesDir;
}
// Synchronize runfiles tree generation on the runfiles manifest artifact.
// This is necessary, because we might end up with multiple test runner actions
// trying to generate same runfiles tree in case of --runs_per_test > 1 or
// local test sharding.
long startTime = Profiler.nanoTimeMaybe();
synchronized (execSettings.getInputManifest()) {
Profiler.instance().logSimpleTask(startTime, ProfilerTask.WAIT, testAction);
updateLocalRunfilesDirectory(testAction, runfilesDir, actionExecutionContext, binTools, shellEnvironment, enableRunfiles);
}
return runfilesDir;
}
use of com.google.devtools.build.lib.vfs.Path in project bazel by bazelbuild.
the class ExecutionTool method createBuilder.
private Builder createBuilder(BuildRequest request, ActionCache actionCache, SkyframeExecutor skyframeExecutor, ModifiedFileSet modifiedOutputFiles) {
BuildRequest.BuildRequestOptions options = request.getBuildOptions();
boolean keepGoing = request.getViewOptions().keepGoing;
Path actionOutputRoot = env.getDirectories().getActionConsoleOutputDirectory();
Predicate<Action> executionFilter = CheckUpToDateFilter.fromOptions(request.getOptions(ExecutionOptions.class));
// jobs should have been verified in BuildRequest#validateOptions().
Preconditions.checkState(options.jobs >= -1);
// Treat 0 jobs as a single task.
int actualJobs = options.jobs == 0 ? 1 : options.jobs;
skyframeExecutor.setActionOutputRoot(actionOutputRoot);
ArtifactFactory artifactFactory = env.getSkyframeBuildView().getArtifactFactory();
return new SkyframeBuilder(skyframeExecutor, new ActionCacheChecker(actionCache, artifactFactory, executionFilter, ActionCacheChecker.CacheConfig.builder().setEnabled(options.useActionCache).setVerboseExplanations(options.verboseExplanations).build()), keepGoing, actualJobs, request.getPackageCacheOptions().checkOutputFiles ? modifiedOutputFiles : ModifiedFileSet.NOTHING_MODIFIED, options.finalizeActions, fileCache, request.getBuildOptions().progressReportInterval);
}
use of com.google.devtools.build.lib.vfs.Path in project bazel by bazelbuild.
the class ExecutionTool method startLocalOutputBuild.
/**
* Prepare for a local output build.
*/
private void startLocalOutputBuild(String workspaceName) throws ExecutorInitException {
try (AutoProfiler p = AutoProfiler.profiled("Starting local output build", ProfilerTask.INFO)) {
Path outputPath = env.getDirectories().getOutputPath(workspaceName);
Path localOutputPath = env.getDirectories().getLocalOutputPath();
if (outputPath.isSymbolicLink()) {
try {
// Remove the existing symlink first.
outputPath.delete();
if (localOutputPath.exists()) {
// Pre-existing local output directory. Move to outputPath.
localOutputPath.renameTo(outputPath);
}
} catch (IOException e) {
throw new ExecutorInitException("Couldn't handle local output directory symlinks", e);
}
}
}
}
use of com.google.devtools.build.lib.vfs.Path in project bazel by bazelbuild.
the class OutputDirectoryLinksUtils method relativize.
// Helper to getPrettyPath. Returns file, relativized w.r.t. the referent of
// "linkname", or null if it was a not a child.
private static PathFragment relativize(Path file, Path workspaceDirectory, String linkname) {
PathFragment link = new PathFragment(linkname);
try {
Path dir = workspaceDirectory.getRelative(link);
PathFragment levelOneLinkTarget = dir.readSymbolicLink();
if (levelOneLinkTarget.isAbsolute() && file.startsWith(dir = file.getRelative(levelOneLinkTarget))) {
return link.getRelative(file.relativeTo(dir));
}
} catch (IOException e) {
/* ignore */
}
return null;
}
use of com.google.devtools.build.lib.vfs.Path in project bazel by bazelbuild.
the class GlobCache method getGlobUnsorted.
@VisibleForTesting
protected List<String> getGlobUnsorted(String pattern, boolean excludeDirs) throws IOException, BadGlobException, InterruptedException {
Future<List<Path>> futureResult = getGlobUnsortedAsync(pattern, excludeDirs);
List<Path> globPaths = fromFuture(futureResult);
// garbage collection of the GlobFuture and GlobVisitor objects.
if (!(futureResult instanceof SettableFuture<?>)) {
SettableFuture<List<Path>> completedFuture = SettableFuture.create();
completedFuture.set(globPaths);
globCache.put(Pair.of(pattern, excludeDirs), completedFuture);
}
List<String> result = Lists.newArrayListWithCapacity(globPaths.size());
for (Path path : globPaths) {
String relative = path.relativeTo(packageDirectory).getPathString();
// really want to name the package directory.
if (!relative.isEmpty()) {
result.add(relative);
}
}
return result;
}
Aggregations