Skip to content

Rustup support #96

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,15 @@ For optimal functionality, consider enabling:

When prompted, select the `Pico` kit in CMake Tools, and set your build and launch targets accordingly. Use CMake Tools for compilation, but continue using this extension for debugging, as CMake Tools debugging is not compatible with Pico.

## Rust Prerequisites

* **rustup** – Installs and manages Rust. Get it from [rustup.rs](https://rustup.rs).
* A C compiler for your system:

* **Linux**: `gcc`
* **macOS**: `clang`
* **Windows**: `MSVC`

## VS Code Profiles

If you work with multiple microcontroller toolchains, consider installing this extension into a [VS Code Profile](https://code.visualstudio.com/docs/editor/profiles) to avoid conflicts with other toolchains. Follow these steps:
Expand Down
7 changes: 7 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 31 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
},
"activationEvents": [
"workspaceContains:./pico_sdk_import.cmake",
"workspaceContains:./.pico-rs",
"onWebviewPanel:newPicoProject",
"onWebviewPanel:newPicoMicroPythonProject"
],
Expand All @@ -79,20 +80,26 @@
"command": "raspberry-pi-pico.switchSDK",
"title": "Switch Pico SDK",
"category": "Raspberry Pi Pico",
"enablement": "raspberry-pi-pico.isPicoProject"
"enablement": "raspberry-pi-pico.isPicoProject && !raspberry-pi-pico.isRustProject"
},
{
"command": "raspberry-pi-pico.switchBoard",
"title": "Switch Board",
"category": "Raspberry Pi Pico",
"enablement": "raspberry-pi-pico.isPicoProject"
"enablement": "raspberry-pi-pico.isPicoProject && !raspberry-pi-pico.isRustProject"
},
{
"command": "raspberry-pi-pico.launchTargetPath",
"title": "Get path of the project executable",
"category": "Raspberry Pi Pico",
"enablement": "false"
},
{
"command": "raspberry-pi-pico.launchTargetPathRelease",
"title": "Get path of the project release executable (rust only)",
"category": "Raspberry Pi Pico",
"enablement": "false"
},
{
"command": "raspberry-pi-pico.getPythonPath",
"title": "Get python path",
Expand Down Expand Up @@ -147,6 +154,18 @@
"category": "Raspberry Pi Pico",
"enablement": "false"
},
{
"command": "raspberry-pi-pico.getOpenOCDRoot",
"title": "Get OpenOCD root",
"category": "Raspberry Pi Pico",
"enablement": "false"
},
{
"command": "raspberry-pi-pico.getSVDPath",
"title": "Get SVD Path (rust only)",
"category": "Raspberry Pi Pico",
"enablement": "false"
},
{
"command": "raspberry-pi-pico.compileProject",
"title": "Compile Pico Project",
Expand Down Expand Up @@ -185,13 +204,13 @@
"command": "raspberry-pi-pico.configureCmake",
"title": "Configure CMake",
"category": "Raspberry Pi Pico",
"enablement": "raspberry-pi-pico.isPicoProject"
"enablement": "raspberry-pi-pico.isPicoProject && !raspberry-pi-pico.isRustProject"
},
{
"command": "raspberry-pi-pico.switchBuildType",
"title": "Switch Build Type",
"category": "Raspberry Pi Pico",
"enablement": "raspberry-pi-pico.isPicoProject"
"enablement": "raspberry-pi-pico.isPicoProject && !raspberry-pi-pico.isRustProject"
},
{
"command": "raspberry-pi-pico.importProject",
Expand All @@ -212,13 +231,19 @@
"command": "raspberry-pi-pico.flashProject",
"title": "Flash Pico Project (SWD)",
"category": "Raspberry Pi Pico",
"enablement": "raspberry-pi-pico.isPicoProject"
"enablement": "raspberry-pi-pico.isPicoProject && !raspberry-pi-pico.isRustProject"
},
{
"command": "raspberry-pi-pico.cleanCmake",
"title": "Clean CMake",
"category": "Raspberry Pi Pico",
"enablement": "raspberry-pi-pico.isPicoProject && !raspberry-pi-pico.isRustProject"
},
{
"command": "raspberry-pi-pico.getRTTDecoderPath",
"title": "Get RTT Decoder module path",
"category": "Raspberry Pi Pico",
"enablement": "false"
}
],
"configuration": {
Expand Down Expand Up @@ -326,6 +351,7 @@
"got": "^14.4.7",
"ini": "^5.0.0",
"rimraf": "^6.0.1",
"toml": "^3.0.0",
"undici": "^6.21.0",
"uuid": "^11.1.0",
"which": "^5.0.0"
Expand Down
7 changes: 7 additions & 0 deletions src/commands/compileProject.mts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { EventEmitter } from "events";
import { CommandWithResult } from "./command.mjs";
import Logger from "../logger.mjs";
import Settings, { SettingsKey } from "../settings.mjs";
import State from "../state.mjs";

export default class CompileProjectCommand extends CommandWithResult<boolean> {
private _logger: Logger = new Logger("CompileProjectCommand");
Expand All @@ -18,9 +19,15 @@ export default class CompileProjectCommand extends CommandWithResult<boolean> {
const task = (await tasks.fetchTasks()).find(
task => task.name === "Compile Project"
);
/*const isRustProject = await commands.executeCommand(
"getContext",
ContextKeys.isRustProject
);*/
const isRustProject = State.getInstance().isRustProject;

const settings = Settings.getInstance();
if (
!isRustProject &&
settings !== undefined &&
settings.getBoolean(SettingsKey.useCmakeTools)
) {
Expand Down
23 changes: 21 additions & 2 deletions src/commands/conditionalDebugging.mts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { Command } from "./command.mjs";
import { Command, extensionName } from "./command.mjs";
import Logger from "../logger.mjs";
import { commands } from "vscode";
import { commands, window, workspace, debug } from "vscode";
import State from "../state.mjs";
import DebugLayoutCommand from "./debugLayout.mjs";

/**
* Relay command for the default buildin debug select and start command.
Expand All @@ -16,6 +18,23 @@ export default class ConditionalDebuggingCommand extends Command {
}

async execute(): Promise<void> {
const isRustProject = State.getInstance().isRustProject;

if (isRustProject) {
const wsFolder = workspace.workspaceFolders?.[0];
if (!wsFolder) {
this._logger.error("No workspace folder found.");
void window.showErrorMessage("No workspace folder found.");

return;
}

void commands.executeCommand(`${extensionName}.${DebugLayoutCommand.id}`);
void debug.startDebugging(wsFolder, "Pico Debug (probe-rs)");

return;
}

await commands.executeCommand("workbench.action.debug.selectandstart");
}
}
Loading
Loading