Search in sources :

Example 1 with PackageRootResolutionException

use of com.google.devtools.build.lib.actions.PackageRootResolutionException in project bazel by bazelbuild.

the class SkyframeExecutor method getArtifactRoots.

private Map<PathFragment, Root> getArtifactRoots(final ExtendedEventHandler eventHandler, Iterable<PathFragment> execPaths, boolean forFiles) throws PackageRootResolutionException, InterruptedException {
    final Map<PathFragment, SkyKey> packageKeys = new HashMap<>();
    for (PathFragment execPath : execPaths) {
        try {
            PackageIdentifier pkgIdentifier = PackageIdentifier.discoverFromExecPath(execPath, forFiles);
            packageKeys.put(execPath, ContainingPackageLookupValue.key(pkgIdentifier));
        } catch (LabelSyntaxException e) {
            throw new PackageRootResolutionException(String.format("Could not find the external repository for %s", execPath), e);
        }
    }
    EvaluationResult<ContainingPackageLookupValue> result;
    synchronized (valueLookupLock) {
        result = buildDriver.evaluate(packageKeys.values(), /*keepGoing=*/
        true, /*numThreads=*/
        1, eventHandler);
    }
    if (result.hasError()) {
        throw new PackageRootResolutionException("Exception encountered determining package roots", result.getError().getException());
    }
    Map<PathFragment, Root> roots = new HashMap<>();
    for (PathFragment execPath : execPaths) {
        ContainingPackageLookupValue value = result.get(packageKeys.get(execPath));
        if (value.hasContainingPackage()) {
            roots.put(execPath, Root.computeSourceRoot(value.getContainingPackageRoot(), value.getContainingPackageName().getRepository()));
        } else {
            roots.put(execPath, null);
        }
    }
    return roots;
}
Also used : SkyKey(com.google.devtools.build.skyframe.SkyKey) LabelSyntaxException(com.google.devtools.build.lib.cmdline.LabelSyntaxException) PackageIdentifier(com.google.devtools.build.lib.cmdline.PackageIdentifier) Root(com.google.devtools.build.lib.actions.Root) LinkedHashMap(java.util.LinkedHashMap) HashMap(java.util.HashMap) PathFragment(com.google.devtools.build.lib.vfs.PathFragment) PackageRootResolutionException(com.google.devtools.build.lib.actions.PackageRootResolutionException)

Aggregations

PackageRootResolutionException (com.google.devtools.build.lib.actions.PackageRootResolutionException)1 Root (com.google.devtools.build.lib.actions.Root)1 LabelSyntaxException (com.google.devtools.build.lib.cmdline.LabelSyntaxException)1 PackageIdentifier (com.google.devtools.build.lib.cmdline.PackageIdentifier)1 PathFragment (com.google.devtools.build.lib.vfs.PathFragment)1 SkyKey (com.google.devtools.build.skyframe.SkyKey)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1