Search in sources :

Example 11 with CellPathResolver

use of com.facebook.buck.rules.CellPathResolver in project buck by facebook.

the class DistBuildSlaveExecutor method fullyQualifiedNameToBuildTarget.

private List<BuildTarget> fullyQualifiedNameToBuildTarget(Iterable<String> buildTargets) {
    List<BuildTarget> targets = Lists.newArrayList();
    CellPathResolver distBuildCellPathResolver = args.getState().getRootCell().getCellPathResolver();
    for (String fullyQualifiedBuildTarget : buildTargets) {
        BuildTarget target = BuildTargetParser.INSTANCE.parse(fullyQualifiedBuildTarget, BuildTargetPatternParser.fullyQualified(), distBuildCellPathResolver);
        targets.add(target);
    }
    return targets;
}
Also used : BuildTarget(com.facebook.buck.model.BuildTarget) CellPathResolver(com.facebook.buck.rules.CellPathResolver)

Example 12 with CellPathResolver

use of com.facebook.buck.rules.CellPathResolver in project buck by facebook.

the class QueryUtils method extractBuildTargets.

public static Stream<BuildTarget> extractBuildTargets(CellPathResolver cellPathResolver, BuildTargetPatternParser<BuildTargetPattern> parserPattern, Query query) throws QueryException {
    GraphEnhancementQueryEnvironment env = new GraphEnhancementQueryEnvironment(Optional.empty(), Optional.empty(), cellPathResolver, parserPattern, ImmutableSet.of());
    ListeningExecutorService executorService = MoreExecutors.newDirectExecutorService();
    QueryExpression parsedExp = QueryExpression.parse(query.getQuery(), env);
    List<String> targetLiterals = new ArrayList<>();
    parsedExp.collectTargetPatterns(targetLiterals);
    return targetLiterals.stream().flatMap(pattern -> {
        try {
            return env.getTargetsMatchingPattern(pattern, executorService).stream();
        } catch (Exception e) {
            throw new RuntimeException("Error parsing target expression", e);
        }
    }).map(queryTarget -> {
        Preconditions.checkState(queryTarget instanceof QueryBuildTarget);
        return ((QueryBuildTarget) queryTarget).getBuildTarget();
    });
}
Also used : MoreExecutors(com.google.common.util.concurrent.MoreExecutors) ImmutableSet(com.google.common.collect.ImmutableSet) CellPathResolver(com.facebook.buck.rules.CellPathResolver) QueryException(com.facebook.buck.query.QueryException) TargetGraph(com.facebook.buck.rules.TargetGraph) Set(java.util.Set) BuildTarget(com.facebook.buck.model.BuildTarget) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) BuildRule(com.facebook.buck.rules.BuildRule) List(java.util.List) BuildTargetPattern(com.facebook.buck.model.BuildTargetPattern) Stream(java.util.stream.Stream) QueryExpression(com.facebook.buck.query.QueryExpression) BuildTargetPatternParser(com.facebook.buck.parser.BuildTargetPatternParser) Optional(java.util.Optional) Preconditions(com.google.common.base.Preconditions) BuildRuleResolver(com.facebook.buck.rules.BuildRuleResolver) QueryBuildTarget(com.facebook.buck.query.QueryBuildTarget) QueryTarget(com.facebook.buck.query.QueryTarget) BuildRuleParams(com.facebook.buck.rules.BuildRuleParams) ListeningExecutorService(com.google.common.util.concurrent.ListeningExecutorService) ArrayList(java.util.ArrayList) ListeningExecutorService(com.google.common.util.concurrent.ListeningExecutorService) QueryExpression(com.facebook.buck.query.QueryExpression) QueryException(com.facebook.buck.query.QueryException) QueryBuildTarget(com.facebook.buck.query.QueryBuildTarget)

Aggregations

CellPathResolver (com.facebook.buck.rules.CellPathResolver)12 BuildTarget (com.facebook.buck.model.BuildTarget)8 ProjectFilesystem (com.facebook.buck.io.ProjectFilesystem)6 BuildRuleResolver (com.facebook.buck.rules.BuildRuleResolver)6 ImmutableSet (com.google.common.collect.ImmutableSet)5 Path (java.nio.file.Path)5 Optional (java.util.Optional)5 BuildTargetPattern (com.facebook.buck.model.BuildTargetPattern)4 TargetGraph (com.facebook.buck.rules.TargetGraph)4 BuildTargetPatternParser (com.facebook.buck.parser.BuildTargetPatternParser)3 BuildRule (com.facebook.buck.rules.BuildRule)3 BuildRuleParams (com.facebook.buck.rules.BuildRuleParams)3 SourcePathResolver (com.facebook.buck.rules.SourcePathResolver)3 Test (org.junit.Test)3 BuildTargets (com.facebook.buck.model.BuildTargets)2 Flavor (com.facebook.buck.model.Flavor)2 FlavorDomain (com.facebook.buck.model.FlavorDomain)2 Flavored (com.facebook.buck.model.Flavored)2 MacroException (com.facebook.buck.model.MacroException)2 NoSuchBuildTargetException (com.facebook.buck.parser.NoSuchBuildTargetException)2