use of com.google.devtools.build.lib.pkgcache.PackageProvider in project bazel by bazelbuild.
the class GenQuery method executeQuery.
@Nullable
private byte[] executeQuery(RuleContext ruleContext, QueryOptions queryOptions, Set<Target> scope, String query) throws InterruptedException {
SkyFunction.Environment env = ruleContext.getAnalysisEnvironment().getSkyframeEnv();
Pair<ImmutableMap<PackageIdentifier, Package>, ImmutableMap<Label, Target>> closureInfo;
try {
closureInfo = constructPackageMap(env, scope);
if (closureInfo == null) {
return null;
}
} catch (BrokenQueryScopeException e) {
ruleContext.ruleError(e.getMessage());
return null;
}
ImmutableMap<PackageIdentifier, Package> packageMap = closureInfo.first;
ImmutableMap<Label, Target> validTargetsMap = closureInfo.second;
PackageProvider packageProvider = new PreloadedMapPackageProvider(packageMap, validTargetsMap);
TargetPatternEvaluator evaluator = new SkyframeEnvTargetPatternEvaluator(env);
Predicate<Label> labelFilter = Predicates.in(validTargetsMap.keySet());
return doQuery(queryOptions, packageProvider, labelFilter, evaluator, query, ruleContext);
}
Aggregations