Search in sources :

Example 1 with ExpandedTargetsResult

use of com.google.idea.blaze.base.sync.sharding.WildcardTargetExpander.ExpandedTargetsResult in project intellij by bazelbuild.

the class BlazeBuildTargetSharder method doExpandWildcardTargets.

private static ExpandedTargetsResult doExpandWildcardTargets(Project project, BlazeContext context, WorkspaceRoot workspaceRoot, ProjectViewSet projectViewSet, WorkspacePathResolver pathResolver, List<TargetExpression> targets) {
    List<WildcardTargetPattern> includes = getWildcardPatterns(targets);
    if (includes.isEmpty()) {
        return new ExpandedTargetsResult(targets, BuildResult.SUCCESS);
    }
    Map<TargetExpression, List<TargetExpression>> expandedTargets = WildcardTargetExpander.expandToNonRecursiveWildcardTargets(project, context, pathResolver, includes);
    if (expandedTargets == null) {
        return new ExpandedTargetsResult(ImmutableList.of(), BuildResult.FATAL_ERROR);
    }
    // replace original recursive targets with expanded list, retaining relative ordering
    List<TargetExpression> fullList = new ArrayList<>();
    for (TargetExpression target : targets) {
        List<TargetExpression> expanded = expandedTargets.get(target);
        if (expanded == null) {
            fullList.add(target);
        } else {
            fullList.addAll(expanded);
        }
    }
    return WildcardTargetExpander.expandToSingleTargets(project, context, workspaceRoot, projectViewSet, fullList);
}
Also used : WildcardTargetPattern(com.google.idea.blaze.base.model.primitives.WildcardTargetPattern) ArrayList(java.util.ArrayList) TargetExpression(com.google.idea.blaze.base.model.primitives.TargetExpression) ArrayList(java.util.ArrayList) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) ExpandedTargetsResult(com.google.idea.blaze.base.sync.sharding.WildcardTargetExpander.ExpandedTargetsResult)

Example 2 with ExpandedTargetsResult

use of com.google.idea.blaze.base.sync.sharding.WildcardTargetExpander.ExpandedTargetsResult in project intellij by bazelbuild.

the class BlazeBuildTargetSharder method expandAndShardTargets.

/**
 * Expand wildcard target patterns and partition the resulting target list.
 */
public static ShardedTargetsResult expandAndShardTargets(Project project, BlazeContext context, WorkspaceRoot workspaceRoot, ProjectViewSet projectViewSet, WorkspacePathResolver pathResolver, List<TargetExpression> targets) {
    if (!shardingEnabled(projectViewSet)) {
        return new ShardedTargetsResult(new ShardedTargetList(ImmutableList.of(targets)), BuildResult.SUCCESS);
    }
    List<WildcardTargetPattern> wildcardIncludes = getWildcardPatterns(targets);
    if (wildcardIncludes.isEmpty()) {
        return new ShardedTargetsResult(new ShardedTargetList(ImmutableList.of(targets)), BuildResult.SUCCESS);
    }
    ExpandedTargetsResult expandedTargets = expandWildcardTargets(project, context, workspaceRoot, projectViewSet, pathResolver, targets);
    if (expandedTargets.buildResult.status == BuildResult.Status.FATAL_ERROR) {
        return new ShardedTargetsResult(new ShardedTargetList(ImmutableList.of()), expandedTargets.buildResult);
    }
    return new ShardedTargetsResult(shardTargets(expandedTargets.singleTargets, getTargetShardSize(projectViewSet)), expandedTargets.buildResult);
}
Also used : WildcardTargetPattern(com.google.idea.blaze.base.model.primitives.WildcardTargetPattern) ExpandedTargetsResult(com.google.idea.blaze.base.sync.sharding.WildcardTargetExpander.ExpandedTargetsResult)

Aggregations

WildcardTargetPattern (com.google.idea.blaze.base.model.primitives.WildcardTargetPattern)2 ExpandedTargetsResult (com.google.idea.blaze.base.sync.sharding.WildcardTargetExpander.ExpandedTargetsResult)2 ImmutableList (com.google.common.collect.ImmutableList)1 TargetExpression (com.google.idea.blaze.base.model.primitives.TargetExpression)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1