forked from bazelbuild/intellij
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CLion MSVC Support (bazelbuild#6500)
* Add .exe if compiler cannot be found on windows * Disable the generated compiler wrapper script for all platforms except mac * Add arg max heuristic for windows * Add MSVC support * Add sdkcompat for MSVCCompilerToVersionCacheService * Persist compiler information to select right debugger * Disable gdb on windows * Replaced generic switch builder with compiler specific * fixed #api tags in sdkcompat * added static to methods fixes bazelbuild#6451
- Loading branch information
Showing
36 changed files
with
1,130 additions
and
292 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Copyright 2024 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. | ||
|
||
load( | ||
"//intellij_platform_sdk:build_defs.bzl", | ||
"select_for_plugin_api", | ||
) | ||
|
||
java_library( | ||
name = "sdkcompat", | ||
srcs = select_for_plugin_api({ | ||
"clion-2022.3": ["//clwb/sdkcompat/v223"], | ||
"clion-2023.1": ["//clwb/sdkcompat/v231"], | ||
"clion-2023.2": ["//clwb/sdkcompat/v232"], | ||
"clion-2023.3": ["//clwb/sdkcompat/v233"], | ||
"clion-2024.1": ["//clwb/sdkcompat/v241"], | ||
"clion-2024.2": ["//clwb/sdkcompat/v242"], | ||
}), | ||
visibility = ["//clwb:__pkg__"], | ||
deps = ["//intellij_platform_sdk:plugin_api"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Copyright 2024 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. | ||
|
||
filegroup( | ||
name = "v223", | ||
srcs = glob(["**/*.java"]), | ||
visibility = ["//clwb/sdkcompat:__pkg__"], | ||
) |
17 changes: 17 additions & 0 deletions
17
clwb/sdkcompat/v223/com/google/idea/blaze/clwb/MSVCCompilerVersionCompat.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.google.idea.blaze.clwb; | ||
|
||
import com.jetbrains.cidr.cpp.toolchains.CPPEnvironment; | ||
|
||
import java.io.File; | ||
import javax.annotation.Nullable; | ||
|
||
// #api223 | ||
public class MSVCCompilerVersionCompat { | ||
public record ArchAndVersion() {} | ||
|
||
public static @Nullable ArchAndVersion getCompilerVersion(File compiler) { | ||
return new ArchAndVersion(); | ||
} | ||
|
||
public static void setEnvironmentVersion(CPPEnvironment environment, ArchAndVersion version) { } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Copyright 2024 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. | ||
|
||
filegroup( | ||
name = "v231", | ||
srcs = glob(["**/*.java"]), | ||
visibility = ["//clwb/sdkcompat:__pkg__"], | ||
) |
30 changes: 30 additions & 0 deletions
30
clwb/sdkcompat/v231/com/google/idea/blaze/clwb/MSVCCompilerVersionCompat.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.google.idea.blaze.clwb; | ||
|
||
import com.intellij.openapi.application.ApplicationManager; | ||
import com.jetbrains.cidr.cpp.toolchains.CPPEnvironment; | ||
import com.jetbrains.cidr.cpp.toolchains.MSVC; | ||
import com.jetbrains.cidr.cpp.toolchains.msvc.MSVCCompilerToVersionCacheService; | ||
import java.io.File; | ||
import javax.annotation.Nullable; | ||
|
||
// #api231 | ||
public class MSVCCompilerVersionCompat { | ||
public record ArchAndVersion(MSVCCompilerToVersionCacheService.ArchAndVersion delegate) {} | ||
|
||
public static @Nullable ArchAndVersion getCompilerVersion(File compiler) { | ||
final var service = ApplicationManager.getApplication() | ||
.getService(MSVCCompilerToVersionCacheService.class); | ||
|
||
final var result = service.getCompilerVersion(compiler.getAbsolutePath()); | ||
if (result == null) { | ||
return null; | ||
} | ||
|
||
return new ArchAndVersion(result); | ||
} | ||
|
||
public static void setEnvironmentVersion(CPPEnvironment environment, ArchAndVersion version) { | ||
final var msvc = (MSVC) environment.getToolSet(); | ||
msvc.setToolsVersion(version.delegate); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Copyright 2024 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. | ||
|
||
filegroup( | ||
name = "v232", | ||
srcs = glob(["**/*.java"]), | ||
visibility = ["//clwb/sdkcompat:__pkg__"], | ||
) |
31 changes: 31 additions & 0 deletions
31
clwb/sdkcompat/v232/com/google/idea/blaze/clwb/MSVCCompilerVersionCompat.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.google.idea.blaze.clwb; | ||
|
||
import com.intellij.openapi.application.ApplicationManager; | ||
import com.jetbrains.cidr.cpp.toolchains.CPPEnvironment; | ||
import com.jetbrains.cidr.cpp.toolchains.MSVC; | ||
import com.jetbrains.cidr.cpp.toolchains.msvc.MSVCArchAndVersion; | ||
import com.jetbrains.cidr.cpp.toolchains.msvc.MSVCCompilerToVersionCacheService; | ||
import java.io.File; | ||
import javax.annotation.Nullable; | ||
|
||
// #api232 | ||
public class MSVCCompilerVersionCompat { | ||
public record ArchAndVersion(MSVCArchAndVersion delegate) {} | ||
|
||
public static @Nullable ArchAndVersion getCompilerVersion(File compiler) { | ||
final var service = ApplicationManager.getApplication() | ||
.getService(MSVCCompilerToVersionCacheService.class); | ||
|
||
final var result = service.getCompilerVersion(compiler.getAbsolutePath()); | ||
if (result == null) { | ||
return null; | ||
} | ||
|
||
return new ArchAndVersion(result); | ||
} | ||
|
||
public static void setEnvironmentVersion(CPPEnvironment environment, ArchAndVersion version) { | ||
final var msvc = (MSVC) environment.getToolSet(); | ||
msvc.setToolsVersion(version.delegate); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Copyright 2024 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. | ||
|
||
filegroup( | ||
name = "v233", | ||
srcs = glob(["**/*.java"]), | ||
visibility = ["//clwb/sdkcompat:__pkg__"], | ||
) |
31 changes: 31 additions & 0 deletions
31
clwb/sdkcompat/v233/com/google/idea/blaze/clwb/MSVCCompilerVersionCompat.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.google.idea.blaze.clwb; | ||
|
||
import com.intellij.openapi.application.ApplicationManager; | ||
import com.jetbrains.cidr.cpp.toolchains.CPPEnvironment; | ||
import com.jetbrains.cidr.cpp.toolchains.MSVC; | ||
import com.jetbrains.cidr.cpp.toolchains.msvc.MSVCArchAndVersion; | ||
import com.jetbrains.cidr.cpp.toolchains.msvc.MSVCCompilerToVersionCacheService; | ||
import java.io.File; | ||
import javax.annotation.Nullable; | ||
|
||
// #api232 | ||
public class MSVCCompilerVersionCompat { | ||
public record ArchAndVersion(MSVCArchAndVersion delegate) {} | ||
|
||
public static @Nullable ArchAndVersion getCompilerVersion(File compiler) { | ||
final var service = ApplicationManager.getApplication() | ||
.getService(MSVCCompilerToVersionCacheService.class); | ||
|
||
final var result = service.getCompilerVersion(compiler.getAbsolutePath()); | ||
if (result == null) { | ||
return null; | ||
} | ||
|
||
return new ArchAndVersion(result); | ||
} | ||
|
||
public static void setEnvironmentVersion(CPPEnvironment environment, ArchAndVersion version) { | ||
final var msvc = (MSVC) environment.getToolSet(); | ||
msvc.setToolsVersion(version.delegate); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Copyright 2024 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. | ||
|
||
filegroup( | ||
name = "v241", | ||
srcs = glob(["**/*.java"]), | ||
visibility = ["//clwb/sdkcompat:__pkg__"], | ||
) |
31 changes: 31 additions & 0 deletions
31
clwb/sdkcompat/v241/com/google/idea/blaze/clwb/MSVCCompilerVersionCompat.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.google.idea.blaze.clwb; | ||
|
||
import com.intellij.openapi.application.ApplicationManager; | ||
import com.jetbrains.cidr.cpp.toolchains.CPPEnvironment; | ||
import com.jetbrains.cidr.cpp.toolchains.MSVC; | ||
import com.jetbrains.cidr.cpp.toolchains.msvc.MSVCArchAndVersion; | ||
import com.jetbrains.cidr.cpp.toolchains.msvc.MSVCCompilerToVersionCacheService; | ||
import java.io.File; | ||
import javax.annotation.Nullable; | ||
|
||
// #api232 | ||
public class MSVCCompilerVersionCompat { | ||
public record ArchAndVersion(MSVCArchAndVersion delegate) {} | ||
|
||
public static @Nullable ArchAndVersion getCompilerVersion(File compiler) { | ||
final var service = ApplicationManager.getApplication() | ||
.getService(MSVCCompilerToVersionCacheService.class); | ||
|
||
final var result = service.getCompilerVersion(compiler.getAbsolutePath()); | ||
if (result == null) { | ||
return null; | ||
} | ||
|
||
return new ArchAndVersion(result); | ||
} | ||
|
||
public static void setEnvironmentVersion(CPPEnvironment environment, ArchAndVersion version) { | ||
final var msvc = (MSVC) environment.getToolSet(); | ||
msvc.setToolsVersion(version.delegate); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Copyright 2024 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. | ||
|
||
filegroup( | ||
name = "v242", | ||
srcs = glob(["**/*.java"]), | ||
visibility = ["//clwb/sdkcompat:__pkg__"], | ||
) |
31 changes: 31 additions & 0 deletions
31
clwb/sdkcompat/v242/com/google/idea/blaze/clwb/MSVCCompilerVersionCompat.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.google.idea.blaze.clwb; | ||
|
||
import com.intellij.openapi.application.ApplicationManager; | ||
import com.jetbrains.cidr.cpp.toolchains.CPPEnvironment; | ||
import com.jetbrains.cidr.cpp.toolchains.MSVC; | ||
import com.jetbrains.cidr.cpp.toolchains.msvc.MSVCArchAndVersion; | ||
import com.jetbrains.cidr.cpp.toolchains.msvc.MSVCCompilerToVersionCacheService; | ||
import java.io.File; | ||
import javax.annotation.Nullable; | ||
|
||
// #api232 | ||
public class MSVCCompilerVersionCompat { | ||
public record ArchAndVersion(MSVCArchAndVersion delegate) {} | ||
|
||
public static @Nullable ArchAndVersion getCompilerVersion(File compiler) { | ||
final var service = ApplicationManager.getApplication() | ||
.getService(MSVCCompilerToVersionCacheService.class); | ||
|
||
final var result = service.getCompilerVersion(compiler.getAbsolutePath()); | ||
if (result == null) { | ||
return null; | ||
} | ||
|
||
return new ArchAndVersion(result); | ||
} | ||
|
||
public static void setEnvironmentVersion(CPPEnvironment environment, ArchAndVersion version) { | ||
final var msvc = (MSVC) environment.getToolSet(); | ||
msvc.setToolsVersion(version.delegate); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.