From eebd96394c0115a923809575f7209ba4c54cb459 Mon Sep 17 00:00:00 2001 From: William Vinnicombe Date: Mon, 25 Nov 2024 11:25:15 +0000 Subject: [PATCH] Fix picotool version, and Pico 2 W version parsing --- src/commands/switchBoard.mts | 6 +++--- src/utils/cmakeUtil.mts | 15 +++++++++++---- src/webview/newProjectPanel.mts | 1 + 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/commands/switchBoard.mts b/src/commands/switchBoard.mts index 3b27300..18543bc 100644 --- a/src/commands/switchBoard.mts +++ b/src/commands/switchBoard.mts @@ -13,7 +13,7 @@ import { cmakeUpdateSDK, } from "../utils/cmakeUtil.mjs"; import { join } from "path"; -import { compareLtMajor } from "../utils/semverUtil.mjs"; +import { compareLt } from "../utils/semverUtil.mjs"; import type UI from "../ui.mjs"; import { updateVSCodeStaticConfigs } from "../utils/vscodeConfigUtil.mjs"; import { getSupportedToolchains } from "../utils/toolchainUtil.mjs"; @@ -33,11 +33,11 @@ export default class SwitchBoardCommand extends Command { Promise<[string, boolean] | undefined> { const quickPickItems: string[] = ["pico", "pico_w"]; - if (!compareLtMajor(sdkVersion, "2.0.0")) { + if (!compareLt(sdkVersion, "2.0.0")) { quickPickItems.push("pico2"); } - if (!compareLtMajor(sdkVersion, "2.1.0")) { + if (!compareLt(sdkVersion, "2.1.0")) { quickPickItems.push("pico2_w"); } diff --git a/src/utils/cmakeUtil.mts b/src/utils/cmakeUtil.mts index cdaf4b6..0b986f1 100644 --- a/src/utils/cmakeUtil.mts +++ b/src/utils/cmakeUtil.mts @@ -10,7 +10,7 @@ import { readFile, writeFile } from "fs/promises"; import { rimraf, windows as rimrafWindows } from "rimraf"; import { homedir } from "os"; import which from "which"; -import { compareLtMajor } from "./semverUtil.mjs"; +import { compareLt } from "./semverUtil.mjs"; import { buildCMakeIncPath } from "./download.mjs"; export const CMAKE_DO_NOT_EDIT_HEADER_PREFIX = @@ -369,11 +369,18 @@ export async function cmakeUpdateSDK( if ( picoBoard !== null && ((picoBoard[1].includes("pico2") && - compareLtMajor(newSDKVersion, "2.0.0")) || + compareLt(newSDKVersion, "2.0.0")) || (picoBoard[1].includes('pico2_w') && - compareLtMajor(newSDKVersion, "2.1.0"))) + compareLt(newSDKVersion, "2.1.0"))) ) { - const result = await window.showQuickPick(["pico", "pico_w"], { + const quickPickItems = ["pico", "pico_w"]; + if (!compareLt(newSDKVersion, "2.0.0")) { + quickPickItems.push("pico2"); + } + if (!compareLt(newSDKVersion, "2.1.0")) { + quickPickItems.push("pico2_w"); + } + const result = await window.showQuickPick(quickPickItems, { placeHolder: "The new SDK version does not support your current board", canPickMany: false, ignoreFocusOut: true, diff --git a/src/webview/newProjectPanel.mts b/src/webview/newProjectPanel.mts index 2de7b38..0c3456c 100644 --- a/src/webview/newProjectPanel.mts +++ b/src/webview/newProjectPanel.mts @@ -524,6 +524,7 @@ export class NewProjectPanel { result: versionBundle !== undefined, toolchainVersion: versionBundle?.toolchain, riscvToolchainVersion: riscvToolchain, + picotoolVersion: versionBundle?.picotool, }, }); }