Skip to content

Commit 3793571

Browse files
committed
Fix CXX compiler path in cmake-kits.json file
Adds getCxxCompilerPath command, to provide correct path to g++ executable Fixes #107
1 parent c48b2ec commit 3793571

File tree

4 files changed

+47
-1
lines changed

4 files changed

+47
-1
lines changed

package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,12 @@
117117
"category": "Raspberry Pi Pico",
118118
"enablement": "false"
119119
},
120+
{
121+
"command": "raspberry-pi-pico.getCxxCompilerPath",
122+
"title": "Get C++ compiler path",
123+
"category": "Raspberry Pi Pico",
124+
"enablement": "false"
125+
},
120126
{
121127
"command": "raspberry-pi-pico.getChip",
122128
"title": "Get Chip",

scripts/pico_project.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -901,7 +901,7 @@ def generateProjectFiles(projectPath, projectName, sdkPath, projects, debugger,
901901
"name": "Pico",
902902
"compilers": {{
903903
"C": "${{command:raspberry-pi-pico.getCompilerPath}}",
904-
"CXX": "${{command:raspberry-pi-pico.getCompilerPath}}"
904+
"CXX": "${{command:raspberry-pi-pico.getCxxCompilerPath}}"
905905
}},
906906
"environmentVariables": {{
907907
"PATH": "${{command:raspberry-pi-pico.getEnvPath}};${{env:PATH}}"

src/commands/getPaths.mts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,44 @@ export class GetCompilerPathCommand extends CommandWithResult<string> {
149149
}
150150
}
151151

152+
export class GetCxxCompilerPathCommand extends CommandWithResult<string> {
153+
constructor() {
154+
super("getCxxCompilerPath");
155+
}
156+
157+
async execute(): Promise<string> {
158+
if (
159+
workspace.workspaceFolders === undefined ||
160+
workspace.workspaceFolders.length === 0
161+
) {
162+
return "";
163+
}
164+
165+
const workspaceFolder = workspace.workspaceFolders?.[0];
166+
167+
const selectedToolchainAndSDKVersions =
168+
await cmakeGetSelectedToolchainAndSDKVersions(workspaceFolder.uri);
169+
if (selectedToolchainAndSDKVersions === null) {
170+
return "";
171+
}
172+
const toolchainVersion = selectedToolchainAndSDKVersions[1];
173+
174+
let triple = "arm-none-eabi";
175+
if (toolchainVersion.includes("RISCV")) {
176+
if (toolchainVersion.includes("COREV")) {
177+
triple = "riscv32-corev-elf";
178+
} else {
179+
triple = "riscv32-unknown-elf";
180+
}
181+
}
182+
183+
return join(
184+
buildToolchainPath(toolchainVersion), "bin",
185+
triple + `-g++${process.platform === "win32" ? ".exe" : ""}`
186+
);
187+
}
188+
}
189+
152190
export class GetChipCommand extends CommandWithResult<string> {
153191
constructor() {
154192
super("getChip");

src/extension.mts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import {
3737
GetEnvPathCommand,
3838
GetGDBPathCommand,
3939
GetCompilerPathCommand,
40+
GetCxxCompilerPathCommand,
4041
GetChipCommand,
4142
GetTargetCommand,
4243
GetChipUppercaseCommand,
@@ -108,6 +109,7 @@ export async function activate(context: ExtensionContext): Promise<void> {
108109
new GetEnvPathCommand(),
109110
new GetGDBPathCommand(),
110111
new GetCompilerPathCommand(),
112+
new GetCxxCompilerPathCommand(),
111113
new GetChipCommand(),
112114
new GetChipUppercaseCommand(),
113115
new GetTargetCommand(),

0 commit comments

Comments
 (0)