From 96dd2b421b17fc90e0c617880e3f112bda359ee4 Mon Sep 17 00:00:00 2001 From: William Vinnicombe Date: Thu, 15 Aug 2024 14:30:24 +0100 Subject: [PATCH] Fix updating include path Use USERHOME, rather than a full path --- src/utils/cmakeUtil.mts | 2 +- src/utils/download.mts | 18 ++++++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/utils/cmakeUtil.mts b/src/utils/cmakeUtil.mts index c78cce2..45e2100 100644 --- a/src/utils/cmakeUtil.mts +++ b/src/utils/cmakeUtil.mts @@ -270,7 +270,7 @@ export async function cmakeUpdateSDK( `set(sdkVersion ${newSDKVersion})\n` + `set(toolchainVersion ${newToolchainVersion})\n` + `set(picotoolVersion ${picotoolVersion})\n` + - `include(${buildCMakeIncPath()})\n` + + `include(${buildCMakeIncPath(false)})\n` + // eslint-disable-next-line max-len "# ====================================================================================" ); diff --git a/src/utils/download.mts b/src/utils/download.mts index fdffed5..2eeca56 100644 --- a/src/utils/download.mts +++ b/src/utils/download.mts @@ -86,14 +86,24 @@ export function buildSDKPath(version: string): string { ); } -export function buildCMakeIncPath(): string { +export function buildCMakeIncPath(absolute: boolean): string { // TODO: maybe replace . with _ - return joinPosix( - homedir().replaceAll("\\", "/"), + const relPath = joinPosix( ".pico-sdk", "cmake", "pico-vscode.cmake" ); + if (absolute) { + return joinPosix( + homedir().replaceAll("\\", "/"), + relPath + ); + } else { + return joinPosix( + "${USERHOME}", + relPath + ); + } } export function buildToolsPath(version: string): string { @@ -305,7 +315,7 @@ export async function downloadAndInstallSDK( // Install pico-vscode.cmake file - overwrite if it's already there copyFileSync( joinPosix(getScriptsRoot(), "pico-vscode.cmake"), - buildCMakeIncPath() + buildCMakeIncPath(true) ); const targetDirectory = buildSDKPath(version);