-
Notifications
You must be signed in to change notification settings - Fork 304
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added build folder action #6615
Changes from 9 commits
90f0f5f
4e79303
c1cacd1
c4f6938
4bd7d29
f3e1697
8bab9b4
cf0bb22
1ab1234
86df84e
9f87422
925f9c7
8562252
a59c674
83d41eb
f6f9515
ec81777
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* | ||
* Copyright 2016 The Bazel Authors. All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.google.idea.blaze.base.actions; | ||
|
||
import com.google.idea.blaze.base.build.BlazeBuildService; | ||
import com.google.idea.blaze.base.model.primitives.*; | ||
import com.google.idea.blaze.base.lang.buildfile.search.BlazePackage; | ||
import com.google.idea.common.actions.ActionPresentationHelper; | ||
import com.intellij.openapi.actionSystem.*; | ||
import com.intellij.openapi.project.Project; | ||
import com.intellij.openapi.vfs.VirtualFile; | ||
|
||
import java.io.*; | ||
import java.util.List; | ||
|
||
/** Action to compile all build files in folder if folder picked or compile corresponding build file if file picked */ | ||
public class CompileFolderAction extends BlazeProjectAction { | ||
|
||
@Override | ||
protected void actionPerformedInBlazeProject(Project project, AnActionEvent e) { | ||
runBuild(project, e); | ||
} | ||
|
||
protected void runBuild(Project project, AnActionEvent e) { | ||
VirtualFile vf = e.getData(CommonDataKeys.VIRTUAL_FILE); | ||
WorkspaceRoot root = WorkspaceRoot.fromProject(project); | ||
WorkspacePath path = root.workspacePathForSafe(new File(vf.getPath())); | ||
try { | ||
List<TargetExpression> dt = List.of(TargetExpression.fromString("//" + path.toString() + "/...")); | ||
BlazeBuildService.getInstance(project).buildFolder(vf.getName(),dt); | ||
} catch (InvalidTargetException ex) { | ||
throw new RuntimeException(ex); | ||
} | ||
} | ||
|
||
@Override | ||
protected void updateForBlazeProject(Project project, AnActionEvent e) { | ||
Presentation presentation = e.getPresentation(); | ||
|
||
DataContext dataContext = e.getDataContext(); | ||
VirtualFile virtualFile = CommonDataKeys.VIRTUAL_FILE.getData(dataContext); | ||
BlazePackage blazePackage = BuildFileUtils.getBuildFile(project, virtualFile); | ||
|
||
boolean enabled = blazePackage != null; | ||
presentation.setVisible(enabled || !ActionPlaces.isPopupPlace(e.getPlace())); | ||
presentation.setEnabled(enabled); | ||
|
||
ActionPresentationHelper.of(e) | ||
.disableIf(virtualFile == null) | ||
.disableIf(!virtualFile.isDirectory()) | ||
.setText(virtualFile.getName() + "/...:all") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No the text is "folder/...alll", can we change it to "Compile folder/...all"? |
||
.hideInContextMenuIfDisabled() | ||
.commit(); | ||
} | ||
|
||
@Override | ||
protected QuerySyncStatus querySyncSupport() { | ||
return QuerySyncStatus.SUPPORTED; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,10 +44,8 @@ | |
import com.google.idea.blaze.base.sync.workspace.WorkspacePathResolver; | ||
import com.google.idea.common.experiments.IntExperiment; | ||
import com.intellij.openapi.project.Project; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Objects; | ||
|
||
import java.util.*; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We prefer to aviod wildcard imports |
||
import java.util.stream.Collectors; | ||
|
||
/** Utility methods for sharding blaze build invocations. */ | ||
|
@@ -111,6 +109,9 @@ private enum ShardingApproach { | |
|
||
private static ShardingApproach getShardingApproach( | ||
SyncStrategy parallelStrategy, ProjectViewSet viewSet) { | ||
if (parallelStrategy == SyncStrategy.SERIAL_NOT_EXPAND) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So this overrides the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The issue here is that compile folder with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, that's a good point. Btw what do you think about setting the default PV in Example here https://github.com/bazelbuild/bazel/blob/master/tools/intellij/.managed.bazelproject There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Personally, I think It's a good idea, but I don't have a lot of knowledge about how often people want to use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @LeFrosch what do you think about it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, actually if I am not mistaken, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But anyway logically it would be better if shard-sync won't affect build. Often There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay, but I can't guarantee it will be permanent. If it turns out to be misleading, we’ll adjust it to align with the shard_sync setting. |
||
return ShardingApproach.SHARD_WITHOUT_EXPANDING; | ||
} | ||
if (shardingRequested(viewSet)) { | ||
return ShardingApproach.EXPAND_AND_SHARD; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copyright 2024