Search in sources :

Example 1 with PackageProvider

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);
}
Also used : TargetPatternEvaluator(com.google.devtools.build.lib.pkgcache.TargetPatternEvaluator) SkyFunction(com.google.devtools.build.skyframe.SkyFunction) Label(com.google.devtools.build.lib.cmdline.Label) ImmutableMap(com.google.common.collect.ImmutableMap) PackageProvider(com.google.devtools.build.lib.pkgcache.PackageProvider) ConfiguredTarget(com.google.devtools.build.lib.analysis.ConfiguredTarget) Target(com.google.devtools.build.lib.packages.Target) PackageIdentifier(com.google.devtools.build.lib.cmdline.PackageIdentifier) Package(com.google.devtools.build.lib.packages.Package) Nullable(javax.annotation.Nullable)

Aggregations

ImmutableMap (com.google.common.collect.ImmutableMap)1 ConfiguredTarget (com.google.devtools.build.lib.analysis.ConfiguredTarget)1 Label (com.google.devtools.build.lib.cmdline.Label)1 PackageIdentifier (com.google.devtools.build.lib.cmdline.PackageIdentifier)1 Package (com.google.devtools.build.lib.packages.Package)1 Target (com.google.devtools.build.lib.packages.Target)1 PackageProvider (com.google.devtools.build.lib.pkgcache.PackageProvider)1 TargetPatternEvaluator (com.google.devtools.build.lib.pkgcache.TargetPatternEvaluator)1 SkyFunction (com.google.devtools.build.skyframe.SkyFunction)1 Nullable (javax.annotation.Nullable)1