Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@
"onWebviewPanel:newPicoProject",
"onWebviewPanel:newPicoMicroPythonProject",
"onWebviewPanel:newPicoRustProject",
"onWebviewPanel:newPicoZephyrProject"
"onWebviewPanel:newPicoZephyrProject",
"onWebviewPanel:uninstaller"
],
"contributes": {
"commands": [
Expand Down Expand Up @@ -273,6 +274,11 @@
"title": "Get Zephyr SDK path",
"category": "Raspberry Pi Pico",
"enablement": "false"
},
{
"command": "raspberry-pi-pico.openUninstaller",
"title": "Open Uninstaller",
"category": "Raspberry Pi Pico"
}
],
"configuration": {
Expand Down
2 changes: 2 additions & 0 deletions src/commands/cmdIds.mts
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,5 @@ export const SWITCH_SDK = "switchSDK";
export const UNINSTALL_PICO_SDK = "uninstallPicoSDK";

export const UPDATE_OPENOCD = "updateOpenOCD";

export const OPEN_UNINSTALLER = "openUninstaller";
18 changes: 18 additions & 0 deletions src/commands/openUninstaller.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import type { Uri } from "vscode";
import { Command } from "./command.mjs";
import { OPEN_UNINSTALLER } from "./cmdIds.mjs";
import { UninstallerPanel } from "../webview/uninstallerPanel.mjs";

export default class OpenUninstallerCommand extends Command {
private readonly _extensionUri: Uri;

constructor(extensionUri: Uri) {
super(OPEN_UNINSTALLER);

this._extensionUri = extensionUri;
}

execute(): void {
UninstallerPanel.createOrShow(this._extensionUri);
}
}
1 change: 0 additions & 1 deletion src/commands/switchSDK.mts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
window,
workspace,
commands,
type WorkspaceFolder,
} from "vscode";
import type UI from "../ui.mjs";
import { updateVSCodeStaticConfigs } from "../utils/vscodeConfigUtil.mjs";
Expand Down
22 changes: 18 additions & 4 deletions src/extension.mts
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,7 @@ import {
downloadAndInstallOpenOCD,
} from "./utils/download.mjs";
import { getSupportedToolchains } from "./utils/toolchainUtil.mjs";
import {
NewProjectPanel,
getWebviewOptions,
} from "./webview/newProjectPanel.mjs";
import { NewProjectPanel } from "./webview/newProjectPanel.mjs";
import GithubApiCache from "./utils/githubApiCache.mjs";
import ClearGithubApiCacheCommand from "./commands/clearGithubApiCache.mjs";
import { ContextKeys } from "./contextKeys.mjs";
Expand Down Expand Up @@ -124,6 +121,10 @@ import {
ZEPHYR_PICO_W,
} from "./models/zephyrBoards.mjs";
import { NewZephyrProjectPanel } from "./webview/newZephyrProjectPanel.mjs";
import LastUsedDepsStore from "./utils/lastUsedDeps.mjs";
import { getWebviewOptions } from "./webview/sharedFunctions.mjs";
import { UninstallerPanel } from "./webview/uninstallerPanel.mjs";
import OpenUninstallerCommand from "./commands/openUninstaller.mjs";

export async function activate(context: ExtensionContext): Promise<void> {
Logger.info(LoggerSource.extension, "Extension activation triggered");
Expand All @@ -134,6 +135,7 @@ export async function activate(context: ExtensionContext): Promise<void> {
context.extension.packageJSON as PackageJSON
);
GithubApiCache.createInstance(context);
LastUsedDepsStore.instance.setup(context.globalState);

const picoProjectActivityBarProvider = new PicoProjectActivityBar();
const ui = new UI(picoProjectActivityBarProvider);
Expand Down Expand Up @@ -181,6 +183,7 @@ export async function activate(context: ExtensionContext): Promise<void> {
new UpdateOpenOCDCommand(),
new SbomTargetPathDebugCommand(),
new SbomTargetPathReleaseCommand(),
new OpenUninstallerCommand(context.extensionUri),
];

// register all command handlers
Expand Down Expand Up @@ -241,6 +244,17 @@ export async function activate(context: ExtensionContext): Promise<void> {
})
);

context.subscriptions.push(
window.registerWebviewPanelSerializer(UninstallerPanel.viewType, {
// eslint-disable-next-line @typescript-eslint/require-await
async deserializeWebviewPanel(webviewPanel: WebviewPanel): Promise<void> {
// Reset the webview options so we use latest uri for `localResourceRoots`.
webviewPanel.webview.options = getWebviewOptions(context.extensionUri);
UninstallerPanel.revive(webviewPanel, context.extensionUri);
},
})
);

context.subscriptions.push(
window.registerTreeDataProvider(
PicoProjectActivityBar.viewType,
Expand Down
1 change: 1 addition & 0 deletions src/logger.mts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export enum LoggerSource {
projectRust = "projectRust",
zephyrSetup = "setupZephyr",
projectZephyr = "projectZephyr",
uninstallUtil = "uninstallUtil",
}

/**
Expand Down
53 changes: 53 additions & 0 deletions src/models/dependency.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
export type DepId =
| "pico-sdk"
| "arm-toolchain"
| "riscv-toolchain"
| "ninja"
| "cmake"
| "embedded-python" // windows-only
| "git" // windows-only
| "openocd"
| "7zip" // windows-only
| "pico-sdk-tools"
| "picotool"
| "zephyr";

export interface DependencyMeta {
id: DepId;
label: string;
platforms?: NodeJS.Platform[]; // omit = all
versioned?: boolean; // default true
}

export const ALL_DEPS: DependencyMeta[] = [
{ id: "pico-sdk", label: "Pico SDK" },
{ id: "arm-toolchain", label: "Arm GNU Toolchain" },
{ id: "riscv-toolchain", label: "RISC-V GNU Toolchain" },
{ id: "ninja", label: "Ninja" },
{ id: "cmake", label: "CMake" },
{ id: "embedded-python", label: "Embedded Python", platforms: ["win32"] },
{ id: "git", label: "Git", platforms: ["win32"] },
{ id: "openocd", label: "OpenOCD" },
{ id: "7zip", label: "7-Zip", platforms: ["win32"], versioned: false },
{ id: "pico-sdk-tools", label: "Pico SDK Tools" },
{ id: "picotool", label: "Picotool" },
{ id: "zephyr", label: "Zephyr" },
];

// version -> YYYY-MM-DD (local)
export type VersionMap = Record<string, string>;
// dep -> VersionMap
export type DepVersionDb = Record<DepId, VersionMap>;

export const INSTALL_ROOT_ALIAS: Partial<Record<DepId, string>> = {
// eslint-disable-next-line @typescript-eslint/naming-convention
"pico-sdk": "sdk",
// eslint-disable-next-line @typescript-eslint/naming-convention
"pico-sdk-tools": "tools",
// eslint-disable-next-line @typescript-eslint/naming-convention
"arm-toolchain": "toolchain",
// eslint-disable-next-line @typescript-eslint/naming-convention
"riscv-toolchain": "toolchain",
zephyr: "zephyr_workspace",
// others default to their depId
};
19 changes: 18 additions & 1 deletion src/ui.mts
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,20 @@ enum StatusBarItemKey {

const STATUS_BAR_ITEMS: {
[key: string]: {
name: string;
text: string;
rustText?: string;
zephyrText?: string;
command: string;
tooltip: string;
rustTooltip?: string;
zephyrTooltip?: string;
rustSupport: boolean;
zephyrSupport: boolean;
};
} = {
[StatusBarItemKey.compile]: {
name: "Raspberry Pi Pico - Compile Project",
// alt. "$(gear) Compile"
text: "$(file-binary) Compile",
command: `${extensionName}.${COMPILE_PROJECT}`,
Expand All @@ -38,6 +41,7 @@ const STATUS_BAR_ITEMS: {
zephyrSupport: true,
},
[StatusBarItemKey.run]: {
name: "Raspberry Pi Pico - Run Project",
// alt. "$(gear) Compile"
text: "$(run) Run",
command: `${extensionName}.${RUN_PROJECT}`,
Expand All @@ -46,6 +50,7 @@ const STATUS_BAR_ITEMS: {
zephyrSupport: true,
},
[StatusBarItemKey.picoSDKQuickPick]: {
name: "Raspberry Pi Pico - Select SDK Version",
text: "Pico SDK: <version>",
zephyrText: "Zephyr version: <version>",
command: `${extensionName}.${SWITCH_SDK}`,
Expand All @@ -55,10 +60,12 @@ const STATUS_BAR_ITEMS: {
zephyrSupport: true,
},
[StatusBarItemKey.picoBoardQuickPick]: {
name: "Raspberry Pi Pico - Select Board",
text: "Board: <board>",
rustText: "Chip: <chip>",
command: `${extensionName}.${SWITCH_BOARD}`,
tooltip: "Select Chip",
tooltip: "Select board",
rustTooltip: "Select Chip",
rustSupport: true,
zephyrSupport: true,
},
Expand All @@ -78,6 +85,7 @@ export default class UI {
Object.entries(STATUS_BAR_ITEMS).forEach(([key, value]) => {
this._items[key] = this.createStatusBarItem(
key,
value.name,
value.text,
value.command,
value.tooltip
Expand All @@ -102,6 +110,13 @@ export default class UI {
if (STATUS_BAR_ITEMS[item.id].zephyrTooltip) {
item.tooltip = STATUS_BAR_ITEMS[item.id].zephyrTooltip;
}
} else if (isRustProject) {
if (STATUS_BAR_ITEMS[item.id].rustText) {
item.text = STATUS_BAR_ITEMS[item.id].rustText!;
}
if (STATUS_BAR_ITEMS[item.id].rustTooltip) {
item.tooltip = STATUS_BAR_ITEMS[item.id].rustTooltip;
}
}
item.show();
});
Expand Down Expand Up @@ -160,11 +175,13 @@ export default class UI {

private createStatusBarItem(
key: string,
name: string,
text: string,
command: string,
tooltip: string
): StatusBarItem {
const item = window.createStatusBarItem(key, StatusBarAlignment.Right);
item.name = name;
item.text = text;
item.command = command;
item.tooltip = tooltip;
Expand Down
Loading
Loading