Search in sources :

Example 6 with WorkspaceRoot

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;
        }
    });
}
Also used : ShardedTargetsResult(com.google.idea.blaze.base.sync.sharding.BlazeBuildTargetSharder.ShardedTargetsResult) IssueOutputFilter(com.google.idea.blaze.base.issueparser.IssueOutputFilter) ExperimentScope(com.google.idea.blaze.base.experiments.ExperimentScope) WorkspaceRoot(com.google.idea.blaze.base.model.primitives.WorkspaceRoot) IdeaLogScope(com.google.idea.blaze.base.scope.scopes.IdeaLogScope) BlazeContext(com.google.idea.blaze.base.scope.BlazeContext) BuildResult(com.google.idea.blaze.base.sync.aspects.BuildResult) TimingScope(com.google.idea.blaze.base.scope.scopes.TimingScope) IssuesScope(com.google.idea.blaze.base.scope.scopes.IssuesScope) BlazeProjectData(com.google.idea.blaze.base.model.BlazeProjectData) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 7 with WorkspaceRoot

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();
}
Also used : BlazeImportSettings(com.google.idea.blaze.base.settings.BlazeImportSettings) WorkspaceRoot(com.google.idea.blaze.base.model.primitives.WorkspaceRoot)

Example 8 with WorkspaceRoot

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;
    }
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) HashCode(com.google.common.hash.HashCode) WorkspacePathResolver(com.google.idea.blaze.base.sync.workspace.WorkspacePathResolver) WorkspaceRoot(com.google.idea.blaze.base.model.primitives.WorkspaceRoot)

Example 9 with WorkspaceRoot

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;
}
Also used : BuildSystem(com.google.idea.blaze.base.settings.Blaze.BuildSystem) WorkspaceRoot(com.google.idea.blaze.base.model.primitives.WorkspaceRoot) Nullable(javax.annotation.Nullable)

Example 10 with WorkspaceRoot

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));
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) ExternalTask(com.google.idea.blaze.base.async.process.ExternalTask) Arrays(java.util.Arrays) BlazeContext(com.google.idea.blaze.base.scope.BlazeContext) ByteArrayOutputStream(java.io.ByteArrayOutputStream) StringUtil(com.intellij.openapi.util.text.StringUtil) Collectors(java.util.stream.Collectors) Strings(com.google.common.base.Strings) List(java.util.List) LineProcessingOutputStream(com.google.idea.blaze.base.async.process.LineProcessingOutputStream) ImmutableList(com.google.common.collect.ImmutableList) TimingScope(com.google.idea.blaze.base.scope.scopes.TimingScope) WorkspaceRoot(com.google.idea.blaze.base.model.primitives.WorkspaceRoot) WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) Logger(com.intellij.openapi.diagnostic.Logger) WorkingSet(com.google.idea.blaze.base.sync.workspace.WorkingSet) Nullable(javax.annotation.Nullable) EventType(com.google.idea.blaze.base.scope.scopes.TimingScope.EventType) TimingScope(com.google.idea.blaze.base.scope.scopes.TimingScope) ByteArrayOutputStream(java.io.ByteArrayOutputStream) WorkingSet(com.google.idea.blaze.base.sync.workspace.WorkingSet) Nullable(javax.annotation.Nullable)

Aggregations

WorkspaceRoot (com.google.idea.blaze.base.model.primitives.WorkspaceRoot)50 File (java.io.File)30 Nullable (javax.annotation.Nullable)23 WorkspacePath (com.google.idea.blaze.base.model.primitives.WorkspacePath)21 BlazeContext (com.google.idea.blaze.base.scope.BlazeContext)19 ProjectViewSet (com.google.idea.blaze.base.projectview.ProjectViewSet)18 ImmutableList (com.google.common.collect.ImmutableList)14 List (java.util.List)13 Project (com.intellij.openapi.project.Project)12 TargetKey (com.google.idea.blaze.base.ideinfo.TargetKey)10 Kind (com.google.idea.blaze.base.model.primitives.Kind)10 VirtualFile (com.intellij.openapi.vfs.VirtualFile)10 Lists (com.google.common.collect.Lists)9 TargetIdeInfo (com.google.idea.blaze.base.ideinfo.TargetIdeInfo)9 ImportRoots (com.google.idea.blaze.base.sync.projectview.ImportRoots)9 Collectors (java.util.stream.Collectors)9 ArtifactLocation (com.google.idea.blaze.base.ideinfo.ArtifactLocation)8 TargetMap (com.google.idea.blaze.base.ideinfo.TargetMap)8 Label (com.google.idea.blaze.base.model.primitives.Label)8 BlazeImportSettings (com.google.idea.blaze.base.settings.BlazeImportSettings)8