Skip to content

Commit 2a73c0f

Browse files
adithyabskAdithya Balaji
authored andcommitted
[debug flags] Address file path escape issue on Windows
1 parent d795120 commit 2a73c0f

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

clwb/src/com/google/idea/blaze/clwb/run/BlazeCidrRunConfigurationRunner.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,15 @@ private ImmutableList<String> getExtraDebugFlags(ExecutionEnvironment env) {
112112
final var flagsBuilder = ImmutableList.<String>builder();
113113

114114
if (debuggerKind == BlazeDebuggerKind.BUNDLED_LLDB && !Registry.is("bazel.trim.absolute.path.disabled")) {
115-
flagsBuilder.add("--copt=-fdebug-compilation-dir=" + WorkspaceRoot.fromProject(env.getProject()));
115+
String workspaceRootPath = WorkspaceRoot.fromProject(env.getProject()).toString();
116+
// Convert backslashes to forward slashes for Windows compatibility,
117+
// particularly for tools like CMake invoked via rules_foreign_cc.
118+
if (SystemInfo.isWindows) {
119+
workspaceRootPath = workspaceRootPath.replace('\\', '/');
120+
}
121+
// Keep the single quotes around the whole copt value and double quotes around the path
122+
// as Bazel might need them for correct parsing, especially if the path contains spaces.
123+
flagsBuilder.add("--copt=-fdebug-compilation-dir='" + workspaceRootPath + "'");
116124

117125
if (SystemInfo.isMac) {
118126
flagsBuilder.add("--linkopt=-Wl,-oso_prefix,.");

0 commit comments

Comments
 (0)