use of com.google.idea.blaze.base.model.primitives.WorkspaceRoot in project intellij by bazelbuild.
the class BlazeBuildService method buildTargetExpressions.
@VisibleForTesting
void buildTargetExpressions(Project project, List<TargetExpression> targets, ProjectViewSet projectViewSet, NotificationScope notificationScope) {
if (targets.isEmpty() || projectViewSet == null) {
return;
}
BlazeProjectData blazeProjectData = BlazeProjectDataManager.getInstance(project).getBlazeProjectData();
if (blazeProjectData == null) {
return;
}
// go/futurereturn-lsc
@SuppressWarnings("unused") Future<?> possiblyIgnoredError = ProgressiveTaskWithProgressIndicator.builder(project).setTitle("Building targets").submitTaskWithResult(new ScopedTask<Void>() {
@Override
public Void execute(BlazeContext context) {
context.push(new ExperimentScope()).push(new BlazeConsoleScope.Builder(project).addConsoleFilters(new IssueOutputFilter(project, WorkspaceRoot.fromProject(project), BlazeInvocationContext.Sync, true)).build()).push(new IssuesScope(project, true)).push(new IdeaLogScope()).push(new TimingScope("Make", EventType.BlazeInvocation)).push(notificationScope);
WorkspaceRoot workspaceRoot = WorkspaceRoot.fromProject(project);
SaveUtil.saveAllFiles();
ShardedTargetsResult shardedTargets = BlazeBuildTargetSharder.expandAndShardTargets(project, context, workspaceRoot, projectViewSet, blazeProjectData.workspacePathResolver, targets);
if (shardedTargets.buildResult.status == BuildResult.Status.FATAL_ERROR) {
return null;
}
BuildResult buildResult = BlazeIdeInterface.getInstance().compileIdeArtifacts(project, context, workspaceRoot, projectViewSet, blazeProjectData.blazeVersionData, blazeProjectData.workspaceLanguageSettings, shardedTargets.shardedTargets);
FileCaches.refresh(project);
if (buildResult.status != BuildResult.Status.SUCCESS) {
context.setHasError();
}
return null;
}
});
}
use of com.google.idea.blaze.base.model.primitives.WorkspaceRoot in project intellij by bazelbuild.
the class CPrefetchFileSourceTest method getImportRoots.
private ImportRoots getImportRoots(ProjectViewSet projectViewSet) {
BlazeImportSettings importSettings = BlazeImportSettingsManager.getInstance(getProject()).getImportSettings();
WorkspaceRoot workspaceRoot = WorkspaceRoot.fromImportSettings(importSettings);
return ImportRoots.builder(workspaceRoot, importSettings.getBuildSystem()).add(projectViewSet).build();
}
use of com.google.idea.blaze.base.model.primitives.WorkspaceRoot in project intellij by bazelbuild.
the class BlazeEditProjectViewControl method update.
public void update(BlazeNewProjectBuilder builder) {
this.workspaceOption = builder.getWorkspaceOption();
this.projectViewOption = builder.getProjectViewOption();
WorkspaceRoot workspaceRoot = workspaceOption.getWorkspaceRoot();
WorkspacePath workspacePath = projectViewOption.getSharedProjectView();
String initialProjectViewText = projectViewOption.getInitialProjectViewText();
boolean allowAddDefaultValues = projectViewOption.allowAddDefaultProjectViewValues() && allowAddprojectViewDefaultValues.getValue();
WorkspacePathResolver workspacePathResolver = workspaceOption.getWorkspacePathResolver();
HashCode hashCode = Hashing.md5().newHasher().putUnencodedChars(workspaceRoot.toString()).putUnencodedChars(workspacePath != null ? workspacePath.toString() : "").putUnencodedChars(initialProjectViewText != null ? initialProjectViewText : "").putBoolean(allowAddDefaultValues).hash();
// If any params have changed, reinit the control
if (!hashCode.equals(paramsHash)) {
this.paramsHash = hashCode;
this.isInitialising = true;
init(workspaceOption.getBuildSystemForWorkspace(), workspaceRoot, workspacePathResolver, workspacePath, initialProjectViewText, allowAddDefaultValues);
this.isInitialising = false;
}
}
use of com.google.idea.blaze.base.model.primitives.WorkspaceRoot in project intellij by bazelbuild.
the class BlazeVcsHandler method vcsHandlerForProject.
@Nullable
static BlazeVcsHandler vcsHandlerForProject(Project project) {
BuildSystem buildSystem = Blaze.getBuildSystem(project);
WorkspaceRoot workspaceRoot = WorkspaceRoot.fromProject(project);
for (BlazeVcsHandler candidate : BlazeVcsHandler.EP_NAME.getExtensions()) {
if (candidate.handlesProject(buildSystem, workspaceRoot)) {
return candidate;
}
}
return null;
}
use of com.google.idea.blaze.base.model.primitives.WorkspaceRoot in project intellij by bazelbuild.
the class GitWorkingSetProvider method calculateWorkingSet.
/**
* Finds all changes between HEAD and the git commit specified by the provided SHA.<br>
* Returns null if an error occurred.
*/
@Nullable
public static WorkingSet calculateWorkingSet(WorkspaceRoot workspaceRoot, String upstreamSha, BlazeContext context) {
String gitRoot = getConsoleOutput(workspaceRoot, "git", "rev-parse", "--show-toplevel");
if (gitRoot == null) {
return null;
}
GitStatusLineProcessor processor = new GitStatusLineProcessor(workspaceRoot, gitRoot);
ByteArrayOutputStream stderr = new ByteArrayOutputStream();
// Do a git diff to find all modified files we know about
int retVal = ExternalTask.builder(workspaceRoot).args("git", "diff", "--name-status", "--no-renames", upstreamSha).context(context).stdout(LineProcessingOutputStream.of(processor)).stderr(stderr).build().run(new TimingScope("GitDiff", EventType.Other));
if (retVal != 0) {
logger.error(stderr);
return null;
}
// Finally list all untracked files, as they're not caught by the git diff step above
String untrackedFilesOutput = getConsoleOutput(workspaceRoot, "git", "ls-files", "--others", "--exclude-standard");
if (untrackedFilesOutput == null) {
return null;
}
List<WorkspacePath> untrackedFiles = Arrays.asList(untrackedFilesOutput.split("\n")).stream().filter(s -> !Strings.isNullOrEmpty(s)).filter(WorkspacePath::isValid).map(WorkspacePath::new).collect(Collectors.toList());
return new WorkingSet(ImmutableList.<WorkspacePath>builder().addAll(processor.addedFiles).addAll(untrackedFiles).build(), ImmutableList.copyOf(processor.modifiedFiles), ImmutableList.copyOf(processor.deletedFiles));
}
Aggregations