Skip to content

Commit ace7320

Browse files
authored
Small Windows fixes (bazelbuild#7535)
* disable curses on windows * use path objects in BlazeIntellijPluginDeployer to avoid issues on windows
1 parent 2e4b533 commit ace7320

File tree

4 files changed

+29
-27
lines changed

4 files changed

+29
-27
lines changed

base/src/com/google/idea/blaze/base/buildview/BazelExecService.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import com.intellij.openapi.diagnostic.Logger
2626
import com.intellij.openapi.project.Project
2727
import com.intellij.openapi.util.Key
2828
import com.intellij.util.io.LimitedInputStream
29+
import com.intellij.util.system.OS
2930
import com.intellij.util.ui.EDT
3031
import kotlinx.coroutines.*
3132
import java.io.BufferedInputStream
@@ -63,8 +64,8 @@ class BazelExecService(private val project: Project, private val scope: Coroutin
6364
}
6465

6566
private suspend fun execute(ctx: BlazeContext, cmdBuilder: BlazeCommand.Builder): Int {
66-
// the old sync view does not use a PTY based terminal
67-
if (BuildViewMigration.present(ctx)) {
67+
// the old sync view does not use a PTY based terminal, and idk why it does not work on windows :c
68+
if (BuildViewMigration.present(ctx) && OS.CURRENT != OS.Windows) {
6869
cmdBuilder.addBlazeFlags("--curses=yes")
6970
} else {
7071
cmdBuilder.addBlazeFlags("--curses=no")
@@ -89,7 +90,7 @@ class BazelExecService(private val project: Project, private val scope: Coroutin
8990

9091
handler.addProcessListener(object : ProcessListener {
9192
override fun onTextAvailable(event: ProcessEvent, outputType: Key<*>) {
92-
if (outputType === ProcessOutputTypes.SYSTEM) {
93+
if (outputType == ProcessOutputTypes.SYSTEM) {
9394
ctx.println(event.text)
9495
} else {
9596
ctx.output(PrintOutput.process(event.text))

clwb/clwb.bazelproject

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ directories:
44
-aswb
55
-plugin_dev
66
-examples
7+
-java
8+
-golang
79
-clwb/tests/projects
10+
-testing/test_deps/projects
811

912
targets:
1013
//clwb:all

ijwb/ijwb.bazelproject

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ directories:
55
-cpp
66
-examples
77
-ijwb/tests/projects
8+
-testing/test_deps/projects
89

910
targets:
1011
//ijwb:ijwb_bazel_dev

plugin_dev/src/com/google/idea/blaze/plugin/run/BlazeIntellijPluginDeployer.java

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,16 @@
3535
import com.intellij.concurrency.AsyncUtil;
3636
import com.intellij.execution.ExecutionException;
3737
import com.intellij.openapi.util.Key;
38-
import com.intellij.openapi.util.text.StringUtil;
3938
import java.io.BufferedInputStream;
4039
import java.io.File;
4140
import java.io.IOException;
4241
import java.io.InputStream;
4342
import java.io.InputStreamReader;
43+
import java.nio.file.Path;
4444
import java.util.ArrayList;
4545
import java.util.Collection;
4646
import java.util.HashMap;
4747
import java.util.List;
48-
import java.util.Locale;
4948
import java.util.Map;
5049
import java.util.concurrent.Future;
5150

@@ -59,7 +58,7 @@ class BlazeIntellijPluginDeployer {
5958
Key.create(BlazeIntellijPluginDeployer.class.getName());
6059

6160
private final String sandboxHome;
62-
private final Map<String, OutputArtifact> buildArtifactsMap = new HashMap<>();
61+
private final Map<Path, OutputArtifact> buildArtifactsMap = new HashMap<>();
6362
private final List<OutputArtifact> deployInfoArtifacts = new ArrayList<>();
6463
private final Map<OutputArtifact, File> filesToDeploy = Maps.newHashMap();
6564

@@ -81,7 +80,7 @@ void buildStarted() {
8180
void reportBuildComplete(BlazeBuildOutputs.Legacy blazeBuildOutputs) throws GetArtifactsException {
8281
ImmutableSet<OutputArtifact> buildArtifacts = blazeBuildOutputs.getAllOutputArtifacts();
8382
buildArtifactsMap.clear();
84-
buildArtifacts.forEach(a -> buildArtifactsMap.put(a.getBazelOutRelativePath(), a));
83+
buildArtifacts.forEach(a -> buildArtifactsMap.put(a.getArtifactPath(), a));
8584

8685
deployInfoArtifacts.clear();
8786
deployInfoArtifacts.addAll(
@@ -158,36 +157,34 @@ private ImmutableMap<OutputArtifact, File> getFilesToDeploy(
158157
for (IntellijPluginDeployInfo deployInfo : deployInfos) {
159158
for (IntellijPluginDeployFile deployFile : deployInfo.getDeployFilesList()) {
160159
result.put(
161-
getArtifactFromDeployFile(deployFile, buildSystem),
160+
getArtifactFromDeployFile(deployFile),
162161
new File(sandboxPluginDirectory(sandboxHome), deployFile.getDeployLocation()));
163162
}
164163
for (IntellijPluginDeployFile deployFile : deployInfo.getJavaAgentDeployFilesList()) {
165164
result.put(
166-
getArtifactFromDeployFile(deployFile, buildSystem),
165+
getArtifactFromDeployFile(deployFile),
167166
new File(sandboxPluginDirectory(sandboxHome), deployFile.getDeployLocation()));
168167
}
169168
}
170169
return result.build();
171170
}
172171

173-
private OutputArtifact getArtifactFromDeployFile(
174-
IntellijPluginDeployFile deployFile, String buildSystem) throws ExecutionException {
175-
String relativePath =
176-
buildArtifactsMap.keySet().stream()
177-
.filter(
178-
key ->
179-
key.endsWith(
180-
StringUtil.trimStart(
181-
deployFile.getExecutionPath(),
182-
String.format("%s-out/", buildSystem.toLowerCase(Locale.ROOT)))))
183-
.findAny()
184-
.orElseThrow(
185-
() ->
186-
new ExecutionException(
187-
String.format(
188-
"Plugin file '%s' not found. Did the build fail?",
189-
deployFile.getExecutionPath())));
190-
return buildArtifactsMap.get(relativePath);
172+
private OutputArtifact getArtifactFromDeployFile(IntellijPluginDeployFile deployFile) throws ExecutionException {
173+
final var fileExecutionPath = Path.of(deployFile.getExecutionPath());
174+
175+
// trim the first element from the execution path i.e. bazel-out
176+
final var fileRelativePath = fileExecutionPath.subpath(1, fileExecutionPath.getNameCount());
177+
178+
// Find the matching artifact by comparing the end of the path
179+
Path matchingPath = buildArtifactsMap.keySet().stream()
180+
.filter(key -> key.endsWith(fileRelativePath))
181+
.findAny()
182+
.orElseThrow(
183+
() ->
184+
new ExecutionException(
185+
String.format("Plugin file '%s' not found. Did the build fail?", fileExecutionPath)));
186+
187+
return buildArtifactsMap.get(matchingPath);
191188
}
192189

193190
private ImmutableSet<File> listJavaAgentFiles(Collection<IntellijPluginDeployInfo> deployInfos) {

0 commit comments

Comments
 (0)