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;
}
Aggregations