use of com.google.idea.blaze.base.sync.sharding.ShardedBuildProgressTracker in project intellij by bazelbuild.
the class BlazeIdeInterfaceAspectsImpl method build.
@Override
public BlazeBuildOutputs build(Project project, BlazeContext context, WorkspaceRoot workspaceRoot, BlazeVersionData blazeVersion, BlazeBuildParams buildParams, ProjectViewSet projectViewSet, BlazeInfo blazeInfo, ShardedTargetList shardedTargets, WorkspaceLanguageSettings workspaceLanguageSettings, ImmutableSet<OutputGroup> outputGroups) {
AspectStrategy aspectStrategy = AspectStrategy.getInstance(blazeVersion);
final Ref<BlazeBuildOutputs> combinedResult = new Ref<>();
boolean parallelize = buildParams.parallelizeBuilds();
// The build is a sync iff INFO output group is present
boolean isSync = outputGroups.contains(OutputGroup.INFO);
Function<Integer, String> progressMessage = count -> String.format("Building targets for shard %s of %s...", count, shardedTargets.shardCount());
final ShardedBuildProgressTracker progressTracker = new ShardedBuildProgressTracker(shardedTargets.shardCount());
BiFunction<List<? extends TargetExpression>, Integer, BuildResult> invocation = (targets, shard) -> Scope.push(context, (childContext) -> {
setupToolWindow(project, context, childContext, workspaceRoot, "Build shard " + shard, isSync);
// we use context (rather than childContext) here since the shard state relates
// to the parent task (which encapsulates all the build shards).
progressTracker.onBuildStarted(context);
BlazeBuildOutputs result = runBuildForTargets(project, childContext, workspaceRoot, buildParams, projectViewSet, blazeInfo, workspaceLanguageSettings.getActiveLanguages(), targets, aspectStrategy, outputGroups);
// TODO(b/216104482) track failures
progressTracker.onBuildCompleted(context);
if (!result.buildResult.outOfMemory()) {
combinedResult.set(combinedResult.isNull() ? result : combinedResult.get().updateOutputs(result));
}
return result.buildResult;
});
BuildResult buildResult = shardedTargets.runShardedCommand(project, context, progressMessage, invocation, parallelize);
if (combinedResult.isNull() || buildResult.status == Status.FATAL_ERROR) {
return BlazeBuildOutputs.noOutputs(buildResult);
}
return combinedResult.get();
}
Aggregations