Search in sources :

Example 1 with ShardedBuildProgressTracker

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();
}
Also used : AdditionalLanguagesHelper(com.google.idea.blaze.base.lang.AdditionalLanguagesHelper) LanguageSupport(com.google.idea.blaze.base.sync.projectview.LanguageSupport) PrefetchService(com.google.idea.blaze.base.prefetch.PrefetchService) BlazeProjectData(com.google.idea.blaze.base.model.BlazeProjectData) BlazeConsoleScope(com.google.idea.blaze.base.scope.scopes.BlazeConsoleScope) BlazeBuildParams(com.google.idea.blaze.base.sync.BlazeBuildParams) Map(java.util.Map) Task(com.google.idea.blaze.base.toolwindow.Task) FileUtil(com.intellij.openapi.util.io.FileUtil) SyncProjectState(com.google.idea.blaze.base.sync.SyncProjectState) Blaze(com.google.idea.blaze.base.settings.Blaze) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) Set(java.util.Set) RemoteArtifactPrefetcher(com.google.idea.blaze.base.prefetch.RemoteArtifactPrefetcher) BuildResultHelper(com.google.idea.blaze.base.command.buildresult.BuildResultHelper) PrintOutput(com.google.idea.blaze.base.scope.output.PrintOutput) BlazeArtifact(com.google.idea.blaze.base.command.buildresult.BlazeArtifact) OutputArtifact(com.google.idea.blaze.base.command.buildresult.OutputArtifact) ProjectTargetData(com.google.idea.blaze.base.model.ProjectTargetData) Status(com.google.idea.blaze.base.sync.aspects.BuildResult.Status) ProjectViewSet(com.google.idea.blaze.base.projectview.ProjectViewSet) BlazeInfo(com.google.idea.blaze.base.command.info.BlazeInfo) ToolWindowScope(com.google.idea.blaze.base.scope.scopes.ToolWindowScope) Joiner(com.google.common.base.Joiner) ListeningExecutorService(com.google.common.util.concurrent.ListeningExecutorService) BlazeContext(com.google.idea.blaze.base.scope.BlazeContext) StatusOutput(com.google.idea.blaze.base.scope.output.StatusOutput) ArrayList(java.util.ArrayList) NavigatableAdapter(com.intellij.pom.NavigatableAdapter) ArtifactsDiff(com.google.idea.blaze.base.filecache.ArtifactsDiff) Kind(com.google.idea.blaze.base.model.primitives.Kind) Lists(com.google.common.collect.Lists) ArtifactState(com.google.idea.blaze.base.filecache.ArtifactState) Scope(com.google.idea.blaze.base.scope.Scope) BoolExperiment(com.google.idea.common.experiments.BoolExperiment) IssueOutput(com.google.idea.blaze.base.scope.output.IssueOutput) ImmutableSet.toImmutableSet(com.google.common.collect.ImmutableSet.toImmutableSet) TargetIdeInfo(com.google.idea.blaze.base.ideinfo.TargetIdeInfo) LinkedHashSet(java.util.LinkedHashSet) Nullable(javax.annotation.Nullable) ImportRoots(com.google.idea.blaze.base.sync.projectview.ImportRoots) File(java.io.File) ExecutionException(java.util.concurrent.ExecutionException) BlazeExecutor(com.google.idea.blaze.base.async.executor.BlazeExecutor) AtomicLong(java.util.concurrent.atomic.AtomicLong) Futures(com.google.common.util.concurrent.Futures) BlazeVersionData(com.google.idea.blaze.base.model.BlazeVersionData) BlazeConfigurationHandler(com.google.idea.blaze.base.command.info.BlazeConfigurationHandler) BlazeFlags(com.google.idea.blaze.base.command.BlazeFlags) BlazeInvocationContext(com.google.idea.blaze.base.command.BlazeInvocationContext) BlazeConsoleExperimentManager(com.google.idea.blaze.base.console.BlazeConsoleExperimentManager) BlazeCommand(com.google.idea.blaze.base.command.BlazeCommand) EventType(com.google.idea.blaze.base.scope.scopes.TimingScope.EventType) AutomaticallyDeriveTargetsSection(com.google.idea.blaze.base.projectview.section.sections.AutomaticallyDeriveTargetsSection) Result(com.google.idea.blaze.base.scope.Result) BiFunction(java.util.function.BiFunction) TargetExpression(com.google.idea.blaze.base.model.primitives.TargetExpression) Logger(com.intellij.openapi.diagnostic.Logger) IntellijIdeInfo(com.google.devtools.intellij.ideinfo.IntellijIdeInfo) BlazeCommandRunner(com.google.idea.blaze.base.command.BlazeCommandRunner) ImmutableSet(com.google.common.collect.ImmutableSet) ImmutableMap(com.google.common.collect.ImmutableMap) AspectStrategy(com.google.idea.blaze.base.sync.aspects.strategy.AspectStrategy) Predicate(java.util.function.Predicate) Collection(java.util.Collection) FutureUtil(com.google.idea.blaze.base.async.FutureUtil) WorkspaceLanguageSettings(com.google.idea.blaze.base.sync.projectview.WorkspaceLanguageSettings) Instant(java.time.Instant) Sets(com.google.common.collect.Sets) BlazeCommandName(com.google.idea.blaze.base.command.BlazeCommandName) Objects(java.util.Objects) IssueOutputFilter(com.google.idea.blaze.base.issueparser.IssueOutputFilter) List(java.util.List) BuildResultHelperProvider(com.google.idea.blaze.base.command.buildresult.BuildResultHelperProvider) WorkspaceRoot(com.google.idea.blaze.base.model.primitives.WorkspaceRoot) TargetKey(com.google.idea.blaze.base.ideinfo.TargetKey) ShardedTargetList(com.google.idea.blaze.base.sync.sharding.ShardedTargetList) Ref(com.intellij.openapi.util.Ref) TargetMap(com.google.idea.blaze.base.ideinfo.TargetMap) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) ContextType(com.google.idea.blaze.base.command.BlazeInvocationContext.ContextType) HashMap(java.util.HashMap) Function(java.util.function.Function) HashSet(java.util.HashSet) ProcessCanceledException(com.intellij.openapi.progress.ProcessCanceledException) ImmutableList(com.google.common.collect.ImmutableList) OutputGroup(com.google.idea.blaze.base.sync.aspects.strategy.AspectStrategy.OutputGroup) Project(com.intellij.openapi.project.Project) RemoteOutputArtifacts(com.google.idea.blaze.base.model.RemoteOutputArtifacts) LanguageClass(com.google.idea.blaze.base.model.primitives.LanguageClass) PerformanceWarning(com.google.idea.blaze.base.scope.output.PerformanceWarning) PrefetchFileSource(com.google.idea.blaze.base.prefetch.PrefetchFileSource) Maps(com.google.common.collect.Maps) ShardedBuildProgressTracker(com.google.idea.blaze.base.sync.sharding.ShardedBuildProgressTracker) Ordering(com.google.common.collect.Ordering) TimingScope(com.google.idea.blaze.base.scope.scopes.TimingScope) BlazeIssueParser(com.google.idea.blaze.base.issueparser.BlazeIssueParser) LocalFileArtifact(com.google.idea.blaze.base.command.buildresult.BlazeArtifact.LocalFileArtifact) ShardedBuildProgressTracker(com.google.idea.blaze.base.sync.sharding.ShardedBuildProgressTracker) TargetExpression(com.google.idea.blaze.base.model.primitives.TargetExpression) Ref(com.intellij.openapi.util.Ref) AspectStrategy(com.google.idea.blaze.base.sync.aspects.strategy.AspectStrategy) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) ArrayList(java.util.ArrayList) List(java.util.List) ShardedTargetList(com.google.idea.blaze.base.sync.sharding.ShardedTargetList) ImmutableList(com.google.common.collect.ImmutableList)

Aggregations

Joiner (com.google.common.base.Joiner)1 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 ImmutableSet.toImmutableSet (com.google.common.collect.ImmutableSet.toImmutableSet)1 Lists (com.google.common.collect.Lists)1 Maps (com.google.common.collect.Maps)1 Ordering (com.google.common.collect.Ordering)1 Sets (com.google.common.collect.Sets)1 Futures (com.google.common.util.concurrent.Futures)1 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)1 ListeningExecutorService (com.google.common.util.concurrent.ListeningExecutorService)1 IntellijIdeInfo (com.google.devtools.intellij.ideinfo.IntellijIdeInfo)1 FutureUtil (com.google.idea.blaze.base.async.FutureUtil)1 BlazeExecutor (com.google.idea.blaze.base.async.executor.BlazeExecutor)1 BlazeCommand (com.google.idea.blaze.base.command.BlazeCommand)1 BlazeCommandName (com.google.idea.blaze.base.command.BlazeCommandName)1 BlazeCommandRunner (com.google.idea.blaze.base.command.BlazeCommandRunner)1 BlazeFlags (com.google.idea.blaze.base.command.BlazeFlags)1