use of com.google.idea.blaze.base.scope.output.StatusOutput in project intellij by bazelbuild.
the class ShardedTargetList method runShardedCommand.
/**
* Runs the provided blaze invocation on each target list shard, returning the combined {@link
* BuildResult}. Attempts to work around out of memory errors caused by lack of blaze garbage
* collection where possible.
*/
public BuildResult runShardedCommand(Project project, BlazeContext context, Function<Integer, String> progressMessage, Function<List<TargetExpression>, BuildResult> invocation) {
if (isEmpty()) {
return BuildResult.SUCCESS;
}
if (shardedTargets.size() == 1) {
return invocation.apply(shardedTargets.get(0));
}
int progress = 0;
BuildResult output = null;
for (int i = 0; i < shardedTargets.size(); i++, progress++) {
context.output(new StatusOutput(progressMessage.apply(i + 1)));
BuildResult result = invocation.apply(shardedTargets.get(i));
if (result.outOfMemory() && progress > 0) {
// re-try now that blaze server has restarted
progress = 0;
IssueOutput.warn(retryOnOomMessage(project, i)).submit(context);
result = invocation.apply(shardedTargets.get(i));
}
output = output == null ? result : BuildResult.combine(output, result);
if (output.status == BuildResult.Status.FATAL_ERROR) {
return output;
}
}
return output;
}
use of com.google.idea.blaze.base.scope.output.StatusOutput in project intellij by bazelbuild.
the class FastBuildServiceImpl method buildDeployJar.
private ListenableFuture<FastBuildState.BuildOutput> buildDeployJar(Label label, FastBuildParameters buildParameters) {
Label deployJarLabel = createDeployJarLabel(label);
WorkspaceRoot workspaceRoot = WorkspaceRoot.fromProject(project);
// TODO(plumpy): this assumes we're running this build as part of a run action. I try not to
// make that assumption anywhere else, so this should be supplied by the caller.
BlazeConsolePopupBehavior consolePopupBehavior = BlazeUserSettings.getInstance().getSuppressConsoleForRunAction() ? BlazeConsolePopupBehavior.NEVER : BlazeConsolePopupBehavior.ALWAYS;
AspectStrategy aspectStrategy = AspectStrategyProvider.findAspectStrategy(projectDataManager.getBlazeProjectData().blazeVersionData);
BuildResultHelper buildResultHelper = BuildResultHelper.forFiles(file -> file.endsWith(deployJarLabel.targetName().toString()) || aspectStrategy.getAspectOutputFilePredicate().test(file));
ListenableFuture<BuildResult> buildResultFuture = ProgressiveTaskWithProgressIndicator.builder(project).submitTaskWithResult(new ScopedTask<BuildResult>() {
@Override
protected BuildResult execute(BlazeContext context) {
context.push(new IssuesScope(project, /* focusProblemsViewOnIssue */
true)).push(new BlazeConsoleScope.Builder(project).setPopupBehavior(consolePopupBehavior).addConsoleFilters(new IssueOutputFilter(project, workspaceRoot, BlazeInvocationContext.NonSync, true)).build());
context.output(new StatusOutput("Building base deploy jar for fast builds: " + deployJarLabel.targetName()));
BlazeCommand.Builder command = BlazeCommand.builder(buildParameters.blazeBinary(), BlazeCommandName.BUILD).addTargets(label).addTargets(deployJarLabel).addBlazeFlags(buildParameters.blazeFlags()).addBlazeFlags(buildResultHelper.getBuildFlags());
List<String> outputGroups = new ArrayList<>();
// needed to retrieve the deploy jar
outputGroups.add("default");
outputGroups.addAll(aspectStrategy.getOutputGroups(OutputGroup.INFO, ImmutableSet.of(LanguageClass.JAVA)));
aspectStrategy.addAspectAndOutputGroups(command, outputGroups);
int exitCode = ExternalTask.builder(workspaceRoot).addBlazeCommand(command.build()).context(context).stderr(LineProcessingOutputStream.of(BlazeConsoleLineProcessorProvider.getAllStderrLineProcessors(context))).build().run();
return BuildResult.fromExitCode(exitCode);
}
});
ListenableFuture<BuildOutput> buildOutputFuture = transform(buildResultFuture, result -> {
if (result.status != Status.SUCCESS) {
throw new RuntimeException("Blaze failure building deploy jar");
}
ImmutableList<File> deployJarArtifacts = buildResultHelper.getBuildArtifactsForTarget(deployJarLabel);
checkState(deployJarArtifacts.size() == 1);
File deployJar = deployJarArtifacts.get(0);
ImmutableList<File> ideInfoFiles = buildResultHelper.getArtifactsForOutputGroups(aspectStrategy.getOutputGroups(OutputGroup.INFO, ImmutableSet.of(LanguageClass.JAVA)));
ImmutableMap<TargetKey, TargetIdeInfo> targetMap = ideInfoFiles.stream().map(file -> readTargetIdeInfo(aspectStrategy, file)).filter(Objects::nonNull).collect(toImmutableMap(ideInfo -> ideInfo.key, i -> i));
return BuildOutput.create(deployJar, new TargetMap(targetMap));
}, ConcurrencyUtil.getAppExecutorService());
buildOutputFuture.addListener(buildResultHelper::close, ConcurrencyUtil.getAppExecutorService());
return buildOutputFuture;
}
use of com.google.idea.blaze.base.scope.output.StatusOutput in project intellij by bazelbuild.
the class BlazeTypescriptSyncPlugin method updateSyncState.
@Override
public void updateSyncState(Project project, BlazeContext context, WorkspaceRoot workspaceRoot, ProjectViewSet projectViewSet, WorkspaceLanguageSettings workspaceLanguageSettings, BlazeInfo blazeInfo, @Nullable WorkingSet workingSet, WorkspacePathResolver workspacePathResolver, ArtifactLocationDecoder artifactLocationDecoder, TargetMap targetMap, SyncState.Builder syncStateBuilder, @Nullable SyncState previousSyncState) {
if (!workspaceLanguageSettings.isLanguageActive(LanguageClass.TYPESCRIPT)) {
return;
}
Set<Label> tsConfigTargets = getTsConfigTargets(projectViewSet);
if (tsConfigTargets.isEmpty()) {
invalidProjectViewError(context, Blaze.getBuildSystemProvider(project));
return;
}
Scope.push(context, (childContext) -> {
childContext.push(new TimingScope("TsConfig", EventType.BlazeInvocation));
childContext.output(new StatusOutput("Updating tsconfig..."));
for (Label target : tsConfigTargets) {
if (runTsConfigTarget(project, childContext, workspaceRoot, projectViewSet, target) != 0) {
childContext.setHasError();
// continue running any remaining targets
}
}
});
}
use of com.google.idea.blaze.base.scope.output.StatusOutput in project intellij by bazelbuild.
the class BlazeSyncTask method computeWorkspacePathResolverAndProjectView.
private WorkspacePathResolverAndProjectView computeWorkspacePathResolverAndProjectView(BlazeContext context, BlazeVcsHandler vcsHandler, ListeningExecutorService executor) {
context.output(new StatusOutput("Updating VCS..."));
for (int i = 0; i < 3; ++i) {
WorkspacePathResolver vcsWorkspacePathResolver = null;
BlazeVcsHandler.BlazeVcsSyncHandler vcsSyncHandler = vcsHandler.createSyncHandler(project, workspaceRoot);
if (vcsSyncHandler != null) {
boolean ok = Scope.push(context, (childContext) -> {
childContext.push(new TimingScope("UpdateVcs", EventType.Other));
return vcsSyncHandler.update(context, executor);
});
if (!ok) {
return null;
}
vcsWorkspacePathResolver = vcsSyncHandler.getWorkspacePathResolver();
}
WorkspacePathResolver workspacePathResolver = vcsWorkspacePathResolver != null ? vcsWorkspacePathResolver : new WorkspacePathResolverImpl(workspaceRoot);
ProjectViewSet projectViewSet = ProjectViewManager.getInstance(project).reloadProjectView(context, workspacePathResolver);
if (projectViewSet == null) {
return null;
}
if (vcsSyncHandler != null) {
BlazeVcsHandler.BlazeVcsSyncHandler.ValidationResult validationResult = vcsSyncHandler.validateProjectView(context, projectViewSet);
switch(validationResult) {
case OK:
// Fall-through and return
break;
case Error:
return null;
case RestartSync:
continue;
default:
// Cannot happen
return null;
}
}
return new WorkspacePathResolverAndProjectView(workspacePathResolver, projectViewSet);
}
return null;
}
use of com.google.idea.blaze.base.scope.output.StatusOutput in project intellij by bazelbuild.
the class BlazeSyncTask method resolveIdeArtifacts.
private static BuildResult resolveIdeArtifacts(Project project, BlazeContext parentContext, WorkspaceRoot workspaceRoot, ProjectViewSet projectViewSet, BlazeVersionData blazeVersionData, WorkspaceLanguageSettings workspaceLanguageSettings, ShardedTargetList shardedTargets) {
return Scope.push(parentContext, context -> {
context.push(new TimingScope(Blaze.buildSystemName(project) + "Build", EventType.BlazeInvocation));
context.output(new StatusOutput("Building IDE resolve files..."));
// We don't want IDE resolve errors to fail the whole sync
context.setPropagatesErrors(false);
if (shardedTargets.isEmpty()) {
return BuildResult.SUCCESS;
}
BlazeIdeInterface blazeIdeInterface = BlazeIdeInterface.getInstance();
return blazeIdeInterface.resolveIdeArtifacts(project, context, workspaceRoot, projectViewSet, blazeVersionData, workspaceLanguageSettings, shardedTargets);
});
}
Aggregations