Skip to content

Commit

Permalink
Fix CXX compiler path in cmake-kits.json file
Browse files Browse the repository at this point in the history
Adds getCxxCompilerPath command, to provide correct path to g++ executable

Fixes #107
  • Loading branch information
will-v-pi committed Oct 30, 2024
1 parent c48b2ec commit 3793571
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 1 deletion.
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,12 @@
"category": "Raspberry Pi Pico",
"enablement": "false"
},
{
"command": "raspberry-pi-pico.getCxxCompilerPath",
"title": "Get C++ compiler path",
"category": "Raspberry Pi Pico",
"enablement": "false"
},
{
"command": "raspberry-pi-pico.getChip",
"title": "Get Chip",
Expand Down
2 changes: 1 addition & 1 deletion scripts/pico_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -901,7 +901,7 @@ def generateProjectFiles(projectPath, projectName, sdkPath, projects, debugger,
"name": "Pico",
"compilers": {{
"C": "${{command:raspberry-pi-pico.getCompilerPath}}",
"CXX": "${{command:raspberry-pi-pico.getCompilerPath}}"
"CXX": "${{command:raspberry-pi-pico.getCxxCompilerPath}}"
}},
"environmentVariables": {{
"PATH": "${{command:raspberry-pi-pico.getEnvPath}};${{env:PATH}}"
Expand Down
38 changes: 38 additions & 0 deletions src/commands/getPaths.mts
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,44 @@ export class GetCompilerPathCommand extends CommandWithResult<string> {
}
}

export class GetCxxCompilerPathCommand extends CommandWithResult<string> {
constructor() {
super("getCxxCompilerPath");
}

async execute(): Promise<string> {
if (
workspace.workspaceFolders === undefined ||
workspace.workspaceFolders.length === 0
) {
return "";
}

const workspaceFolder = workspace.workspaceFolders?.[0];

const selectedToolchainAndSDKVersions =
await cmakeGetSelectedToolchainAndSDKVersions(workspaceFolder.uri);
if (selectedToolchainAndSDKVersions === null) {
return "";
}
const toolchainVersion = selectedToolchainAndSDKVersions[1];

let triple = "arm-none-eabi";
if (toolchainVersion.includes("RISCV")) {
if (toolchainVersion.includes("COREV")) {
triple = "riscv32-corev-elf";
} else {
triple = "riscv32-unknown-elf";
}
}

return join(
buildToolchainPath(toolchainVersion), "bin",
triple + `-g++${process.platform === "win32" ? ".exe" : ""}`
);
}
}

export class GetChipCommand extends CommandWithResult<string> {
constructor() {
super("getChip");
Expand Down
2 changes: 2 additions & 0 deletions src/extension.mts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import {
GetEnvPathCommand,
GetGDBPathCommand,
GetCompilerPathCommand,
GetCxxCompilerPathCommand,
GetChipCommand,
GetTargetCommand,
GetChipUppercaseCommand,
Expand Down Expand Up @@ -108,6 +109,7 @@ export async function activate(context: ExtensionContext): Promise<void> {
new GetEnvPathCommand(),
new GetGDBPathCommand(),
new GetCompilerPathCommand(),
new GetCxxCompilerPathCommand(),
new GetChipCommand(),
new GetChipUppercaseCommand(),
new GetTargetCommand(),
Expand Down

0 comments on commit 3793571

Please sign in to comment.