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;
}
use of com.google.devtools.build.lib.vfs.Path in project bazel by bazelbuild.
the class SdkMavenRepository method create.
/**
* Parses a set of maven repository directory trees looking for and parsing .pom files.
*/
static SdkMavenRepository create(Iterable<Path> mavenRepositories) throws IOException {
Collection<Path> pomPaths = new ArrayList<>();
for (Path mavenRepository : mavenRepositories) {
pomPaths.addAll(FileSystemUtils.traverseTree(mavenRepository, new Predicate<Path>() {
@Override
public boolean apply(@Nullable Path path) {
return path.toString().endsWith(".pom");
}
}));
}
ImmutableSortedSet.Builder<Pom> poms = new ImmutableSortedSet.Builder<>(Ordering.usingToString());
for (Path pomPath : pomPaths) {
try {
Pom pom = Pom.parse(pomPath);
if (pom != null) {
poms.add(pom);
}
} catch (ParserConfigurationException | SAXException e) {
throw new IOException(e);
}
}
return new SdkMavenRepository(poms.build());
}
Aggregations