diff --git a/scripts/pico_project.py b/scripts/pico_project.py index 2ffcc08..7afc1d9 100644 --- a/scripts/pico_project.py +++ b/scripts/pico_project.py @@ -356,24 +356,12 @@ def cmakeToolchainPath(toolchainVersion): def cmakeToolsPath(sdkVersion): return f"${{USERHOME}}{relativeToolsPath(sdkVersion)}" -def propertiesSdkPath(sdkVersion, force_windows=False, force_non_windows=False): - if (isWindows or force_windows) and not force_non_windows: - return f"${{env:USERPROFILE}}{relativeSDKPath(sdkVersion)}" - else: - return f"${{env:HOME}}{relativeSDKPath(sdkVersion)}" - def codeSdkPath(sdkVersion): return f"${{userHome}}{relativeSDKPath(sdkVersion)}" def codeOpenOCDPath(openocdVersion): return f"${{userHome}}{relativeOpenOCDPath(openocdVersion)}" -def propertiesToolchainPath(toolchainVersion, force_windows=False, force_non_windows=False): - if (isWindows or force_windows) and not force_non_windows: - return f"${{env:USERPROFILE}}{relativeToolchainPath(toolchainVersion)}" - else: - return f"${{env:HOME}}{relativeToolchainPath(toolchainVersion)}" - def codeToolchainPath(toolchainVersion): return f"${{userHome}}{relativeToolchainPath(toolchainVersion)}" @@ -830,10 +818,10 @@ def generateProjectFiles(projectPath, projectName, sdkPath, projects, debugger, "name": "Pico", "includePath": [ "${{workspaceFolder}}/**", - "{propertiesSdkPath(sdkVersion)}/**" + "{codeSdkPath(sdkVersion)}/**" ], "forcedInclude": [ - "{propertiesSdkPath(sdkVersion)}/src/common/pico_base/include/pico.h", + "{codeSdkPath(sdkVersion)}/src/common/pico_base/include/pico.h", "${{workspaceFolder}}/build/generated/pico_base/pico/config_autogen.h" ], "defines": [], @@ -870,19 +858,19 @@ def generateProjectFiles(projectPath, projectName, sdkPath, projects, debugger, "cmake.cmakePath": "{cmakePath.replace(user_home, "${userHome}") if use_home_var else cmakePath}", "C_Cpp.debugShortcut": false, "terminal.integrated.env.windows": {{ - "PICO_SDK_PATH": "{propertiesSdkPath(sdkVersion, force_windows=True)}", - "PICO_TOOLCHAIN_PATH": "{propertiesToolchainPath(sdkVersion, force_windows=True)}", - "Path": "{propertiesToolchainPath(toolchainVersion, force_windows=True)}/bin;{os.path.dirname(cmakePath.replace(user_home, "${env:USERPROFILE}") if use_home_var else cmakePath)};{os.path.dirname(ninjaPath.replace(user_home, "${env:USERPROFILE}") if use_home_var else ninjaPath)};${{env:PATH}}" + "PICO_SDK_PATH": "{codeSdkPath(sdkVersion)}", + "PICO_TOOLCHAIN_PATH": "{codeToolchainPath(sdkVersion)}", + "Path": "{codeToolchainPath(toolchainVersion)}/bin;{os.path.dirname(cmakePath.replace(user_home, "${userHome}") if use_home_var else cmakePath)};{os.path.dirname(ninjaPath.replace(user_home, "${userHome}") if use_home_var else ninjaPath)};${{env:PATH}}" }}, "terminal.integrated.env.osx": {{ - "PICO_SDK_PATH": "{propertiesSdkPath(sdkVersion, force_non_windows=True)}", - "PICO_TOOLCHAIN_PATH": "{propertiesToolchainPath(toolchainVersion, force_non_windows=True)}", - "PATH": "{propertiesToolchainPath(toolchainVersion, force_non_windows=True)}/bin:{os.path.dirname(cmakePath.replace(user_home, "${env:HOME}") if use_home_var else cmakePath)}:{os.path.dirname(ninjaPath.replace(user_home, "${env:HOME}") if use_home_var else ninjaPath)}:${{env:PATH}}" + "PICO_SDK_PATH": "{codeSdkPath(sdkVersion)}", + "PICO_TOOLCHAIN_PATH": "{codeToolchainPath(toolchainVersion)}", + "PATH": "{codeToolchainPath(toolchainVersion)}/bin:{os.path.dirname(cmakePath.replace(user_home, "${userHome}") if use_home_var else cmakePath)}:{os.path.dirname(ninjaPath.replace(user_home, "${userHome}") if use_home_var else ninjaPath)}:${{env:PATH}}" }}, "terminal.integrated.env.linux": {{ - "PICO_SDK_PATH": "{propertiesSdkPath(sdkVersion, force_non_windows=True)}", - "PICO_TOOLCHAIN_PATH": "{propertiesToolchainPath(toolchainVersion, force_non_windows=True)}", - "PATH": "{propertiesToolchainPath(toolchainVersion, force_non_windows=True)}/bin:{os.path.dirname(cmakePath.replace(user_home, "${env:HOME}") if use_home_var else cmakePath)}:{os.path.dirname(ninjaPath.replace(user_home, "${env:HOME}") if use_home_var else ninjaPath)}:${{env:PATH}}" + "PICO_SDK_PATH": "{codeSdkPath(sdkVersion)}", + "PICO_TOOLCHAIN_PATH": "{codeToolchainPath(toolchainVersion)}", + "PATH": "{codeToolchainPath(toolchainVersion)}/bin:{os.path.dirname(cmakePath.replace(user_home, "${userHome}") if use_home_var else cmakePath)}:{os.path.dirname(ninjaPath.replace(user_home, "${userHome}") if use_home_var else ninjaPath)}:${{env:PATH}}" }}, "raspberry-pi-pico.cmakeAutoConfigure": true, "raspberry-pi-pico.cmakePath": "{cmakePath.replace(user_home, "${HOME}") if use_home_var else cmakePath}", @@ -1138,7 +1126,7 @@ def DoEverything(parent, params): if args.cpath: compilerPath = Path(args.cpath) elif args.toolchainVersion: - compilerPath = Path(propertiesToolchainPath(args.toolchainVersion)+"/bin/"+COMPILER_NAME) + compilerPath = Path(codeToolchainPath(args.toolchainVersion)+"/bin/"+COMPILER_NAME) else: compilerPath = Path(c) diff --git a/src/utils/vscodeConfigUtil.mts b/src/utils/vscodeConfigUtil.mts index f81688d..d20d84d 100644 --- a/src/utils/vscodeConfigUtil.mts +++ b/src/utils/vscodeConfigUtil.mts @@ -28,13 +28,13 @@ async function updateCppPropertiesFile( cppProperties.configurations.forEach(config => { // Remove the old pico-sdk includePath values set by this extension config.includePath = config.includePath.filter( - item => !item.startsWith("${env:HOME}/.pico-sdk") + item => !item.startsWith("${userHome}/.pico-sdk") ); // Add the new pico-sdk includePath - config.includePath.push(`\${env:HOME}/.pico-sdk/sdk/${newSDKVersion}/**`); + config.includePath.push(`\${userHome}/.pico-sdk/sdk/${newSDKVersion}/**`); // Update the compilerPath config.compilerPath = - "${env:HOME}/.pico-sdk/toolchain" + + "${userHome}/.pico-sdk/toolchain" + `/${newToolchainVersion}/bin/${ // "arm-none-eabi-gcc" should work on all platforms no need for extension on Windows /*process.platform === "win32" @@ -94,10 +94,7 @@ function relativeToolchainPath(toolchainVersion: string): string { * @returns The path to the toolchain. */ function buildPropertiesToolchainPathBin(toolchainVersion: string): string { - // TODO: may home is also available in newer versions of windows - return `${ - process.platform === "win32" ? "${env:USERPROFILE}" : "${env:HOME}" - }${relativeToolchainPath(toolchainVersion)}/bin`; + return `\${userHome}${relativeToolchainPath(toolchainVersion)}/bin`; } function buildCMakePath(cmakeVersion: string): string {