Search in sources :

Example 76 with Path

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);
}
Also used : Path(com.google.devtools.build.lib.vfs.Path) ExecutionOptions(com.google.devtools.build.lib.exec.ExecutionOptions) Action(com.google.devtools.build.lib.actions.Action) WorkspaceStatusAction(com.google.devtools.build.lib.analysis.WorkspaceStatusAction) ArtifactFactory(com.google.devtools.build.lib.actions.ArtifactFactory) ActionCacheChecker(com.google.devtools.build.lib.actions.ActionCacheChecker)

Example 77 with Path

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);
            }
        }
    }
}
Also used : Path(com.google.devtools.build.lib.vfs.Path) AutoProfiler(com.google.devtools.build.lib.profiler.AutoProfiler) IOException(java.io.IOException) ExecutorInitException(com.google.devtools.build.lib.actions.ExecutorInitException)

Example 78 with Path

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;
}
Also used : Path(com.google.devtools.build.lib.vfs.Path) PathFragment(com.google.devtools.build.lib.vfs.PathFragment) IOException(java.io.IOException)

Example 79 with Path

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;
}
Also used : Path(com.google.devtools.build.lib.vfs.Path) SettableFuture(com.google.common.util.concurrent.SettableFuture) ArrayList(java.util.ArrayList) List(java.util.List) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 80 with Path

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());
}
Also used : Path(com.google.devtools.build.lib.vfs.Path) ArrayList(java.util.ArrayList) IOException(java.io.IOException) Predicate(com.google.common.base.Predicate) SAXException(org.xml.sax.SAXException) ImmutableSortedSet(com.google.common.collect.ImmutableSortedSet) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) Nullable(javax.annotation.Nullable)

Aggregations

Path (com.google.devtools.build.lib.vfs.Path)492 Test (org.junit.Test)250 PathFragment (com.google.devtools.build.lib.vfs.PathFragment)111 RootedPath (com.google.devtools.build.lib.vfs.RootedPath)105 IOException (java.io.IOException)102 Artifact (com.google.devtools.build.lib.actions.Artifact)37 SkyKey (com.google.devtools.build.skyframe.SkyKey)37 ArrayList (java.util.ArrayList)29 SpecialArtifact (com.google.devtools.build.lib.actions.Artifact.SpecialArtifact)17 FileSystem (com.google.devtools.build.lib.vfs.FileSystem)17 InMemoryFileSystem (com.google.devtools.build.lib.vfs.inmemoryfs.InMemoryFileSystem)17 HashMap (java.util.HashMap)17 WindowsPath (com.google.devtools.build.lib.windows.WindowsFileSystem.WindowsPath)16 TreeFileArtifact (com.google.devtools.build.lib.actions.Artifact.TreeFileArtifact)14 Before (org.junit.Before)14 Package (com.google.devtools.build.lib.packages.Package)13 FileStatus (com.google.devtools.build.lib.vfs.FileStatus)13 Map (java.util.Map)12 Nullable (javax.annotation.Nullable)12 Executor (com.google.devtools.build.lib.actions.Executor)10