use of com.google.idea.blaze.base.sync.aspects.BlazeBuildOutputs in project intellij by bazelbuild.
the class BuildPhaseSyncTask method doRun.
private void doRun(BlazeContext context) throws SyncFailedException, SyncCanceledException {
List<TargetExpression> targets = Lists.newArrayList();
ProjectViewSet viewSet = projectState.getProjectViewSet();
if (syncParams.addWorkingSet() && projectState.getWorkingSet() != null) {
Collection<TargetExpression> workingSetTargets = getWorkingSetTargets(context);
if (!workingSetTargets.isEmpty()) {
targets.addAll(workingSetTargets);
printTargets(context, "working set", workingSetTargets);
}
}
if (syncParams.addProjectViewTargets()) {
ProjectTargets projectTargets = SyncProjectTargetsHelper.getProjectTargets(project, context, viewSet, projectState.getWorkspacePathResolver(), projectState.getLanguageSettings());
if (!projectTargets.derivedTargets.isEmpty()) {
buildStats.setTargetsDerivedFromDirectories(true);
printTargets(context, "project view directories", projectTargets.derivedTargets);
}
if (!projectTargets.explicitTargets.isEmpty()) {
printTargets(context, "project view targets", projectTargets.explicitTargets);
}
targets.addAll(projectTargets.getTargetsToSync());
}
if (!syncParams.sourceFilesToSync().isEmpty()) {
Collection<TargetExpression> targetsFromSources = findTargetsBuildingSourceFiles(syncParams.sourceFilesToSync(), context);
if (!targetsFromSources.isEmpty()) {
targets.addAll(targetsFromSources);
printTargets(context, syncParams.title() + " (targets derived from query)", targetsFromSources);
}
}
if (!syncParams.targetExpressions().isEmpty()) {
targets.addAll(syncParams.targetExpressions());
printTargets(context, syncParams.title(), syncParams.targetExpressions());
}
buildStats.setTargets(targets);
notifyBuildStarted(context, syncParams.addProjectViewTargets(), ImmutableList.copyOf(targets));
BlazeBuildParams buildParams = BlazeBuildParams.fromProject(project);
ShardedTargetsResult shardedTargetsResult = BlazeBuildTargetSharder.expandAndShardTargets(project, context, workspaceRoot, buildParams, viewSet, projectState.getWorkspacePathResolver(), targets);
if (shardedTargetsResult.buildResult.status == BuildResult.Status.FATAL_ERROR) {
throw new SyncFailedException();
}
ShardedTargetList shardedTargets = shardedTargetsResult.shardedTargets;
buildStats.setSyncSharded(shardedTargets.shardCount() > 1).setShardCount(shardedTargets.shardCount()).setShardStats(shardedTargets.shardStats()).setParallelBuilds(buildParams.parallelizeBuilds());
BlazeBuildOutputs blazeBuildResult = getBlazeBuildResult(context, viewSet, shardedTargets);
resultBuilder.setBuildResult(blazeBuildResult);
buildStats.setBuildResult(blazeBuildResult.buildResult).setBuildIds(blazeBuildResult.buildIds);
if (context.isCancelled()) {
throw new SyncCanceledException();
}
String invocationResultMsg = "Build invocation result: " + blazeBuildResult.buildResult.status;
if (blazeBuildResult.buildResult.status == BuildResult.Status.FATAL_ERROR) {
context.setHasError();
if (blazeBuildResult.buildResult.outOfMemory()) {
SuggestBuildShardingNotification.syncOutOfMemoryError(project, context);
}
context.output(PrintOutput.error(invocationResultMsg));
throw new SyncFailedException();
}
context.output(PrintOutput.log(invocationResultMsg));
}
use of com.google.idea.blaze.base.sync.aspects.BlazeBuildOutputs in project intellij by bazelbuild.
the class BlazeBuildService method buildTargetExpressions.
private static void buildTargetExpressions(Project project, ProjectViewSet projectView, BlazeProjectData projectData, ScopedFunction<List<TargetExpression>> targetsFunction, NotificationScope notificationScope, String taskName) {
if (ApplicationManager.getApplication().isUnitTestMode()) {
// this never being called *and* relied on PROJECT_LAST_BUILD_TIMESTAMP_KEY being set
return;
}
FocusBehavior problemsViewFocus = BlazeUserSettings.getInstance().getShowProblemsViewOnRun();
// go/futurereturn-lsc
@SuppressWarnings("unused") Future<?> possiblyIgnoredError = ProgressiveTaskWithProgressIndicator.builder(project, "Building targets").submitTaskWithResult(new ScopedTask<Void>() {
@Override
public Void execute(BlazeContext context) {
Task task = new Task(taskName, Task.Type.BLAZE_MAKE);
context.push(new ToolWindowScope.Builder(project, task).setIssueParsers(BlazeIssueParser.defaultIssueParsers(project, WorkspaceRoot.fromProject(project), BlazeInvocationContext.ContextType.Sync)).build()).push(new ExperimentScope()).push(new BlazeConsoleScope.Builder(project).addConsoleFilters(new IssueOutputFilter(project, WorkspaceRoot.fromProject(project), BlazeInvocationContext.ContextType.Sync, true)).build()).push(new ProblemsViewScope(project, problemsViewFocus)).push(new IdeaLogScope()).push(new TimingScope("Make", EventType.BlazeInvocation)).push(notificationScope);
List<TargetExpression> targets = targetsFunction.execute(context);
if (targets == null) {
return null;
}
BlazeBuildParams buildParams = BlazeBuildParams.fromProject(project);
WorkspaceRoot workspaceRoot = WorkspaceRoot.fromProject(project);
SaveUtil.saveAllFiles();
BlazeBuildListener.EP_NAME.extensions().forEach(e -> e.buildStarting(project));
ShardedTargetsResult shardedTargets = BlazeBuildTargetSharder.expandAndShardTargets(project, context, workspaceRoot, buildParams, projectView, projectData.getWorkspacePathResolver(), targets);
if (shardedTargets.buildResult.status == BuildResult.Status.FATAL_ERROR) {
return null;
}
BlazeBuildOutputs buildOutputs = BlazeIdeInterface.getInstance().build(project, context, workspaceRoot, projectData.getBlazeVersionData(), buildParams, projectView, projectData.getBlazeInfo(), shardedTargets.shardedTargets, projectData.getWorkspaceLanguageSettings(), ImmutableSet.of(OutputGroup.COMPILE));
refreshFileCachesAndNotifyListeners(context, buildOutputs, project);
if (buildOutputs.buildResult.status != BuildResult.Status.SUCCESS) {
context.setHasError();
}
return null;
}
});
}
Aggregations