@@ -23,11 +23,11 @@ import {
2323} from "./newProjectPanel.mjs" ;
2424import which from "which" ;
2525import { existsSync } from "fs" ;
26- import { join } from "path" ;
26+ import { join , dirname } from "path" ;
2727import { PythonExtension } from "@vscode/python-extension" ;
2828import { unknownErrorToString } from "../utils/errorHelper.mjs" ;
2929import { buildZephyrWorkspacePath } from "../utils/download.mjs" ;
30- import { setupZephyr } from "../utils/setupZephyr.mjs" ;
30+ import { setupZephyr , type ZephyrSetupOutputs } from "../utils/setupZephyr.mjs" ;
3131import VersionBundlesLoader , {
3232 type VersionBundle ,
3333} from "../utils/versionBundles.mjs" ;
@@ -142,7 +142,18 @@ export class NewZephyrProjectPanel {
142142
143143 // Create settings.json file with correct subsitution for tools such as
144144 // CMake, Ninja, Python, etc
145- private static createSettingsJson ( ) : string {
145+ private static createSettingsJson (
146+ homePath : string ,
147+ cmakePath : string
148+ ) : string {
149+ // Helper functions
150+ const getDirName = ( s : string ) : string => dirname ( joinPosix ( s ) ) ;
151+
152+ const subbedCmakePath = getDirName (
153+ cmakePath . replace ( homePath , "${userHome}" )
154+ ) ;
155+ console . log ( subbedCmakePath ) ;
156+
146157 const settingsJson = {
147158 /* eslint-disable @typescript-eslint/naming-convention */
148159 "cmake.options.statusBarVisibility" : "hidden" ,
@@ -161,27 +172,37 @@ export class NewZephyrProjectPanel {
161172 "cmake.automaticReconfigure" : false ,
162173 "cmake.configureOnOpen" : false ,
163174 "cmake.generator" : "Ninja" ,
164- "cmake.cmakePath" : "${userHome}/.pico-sdk/cmake/v3.31.5/bin/cmake" ,
175+ "cmake.cmakePath" : ` ${ cmakePath . replace ( homePath , "${userHome}" ) } ` ,
165176 "C_Cpp.debugShortcut" : false ,
166177 "terminal.integrated.env.windows" : {
167178 PICO_SDK_PATH : "${env:USERPROFILE}/.pico-sdk/sdk/2.1.1" ,
168179 PICO_TOOLCHAIN_PATH : "${env:USERPROFILE}/.pico-sdk/toolchain/14_2_Rel1" ,
169- Path : "${env:USERPROFILE}/.pico-sdk/toolchain/14_2_Rel1/bin;${env:USERPROFILE}/.pico-sdk/picotool/2.1.1/picotool;${env:USERPROFILE}/.pico-sdk/cmake/v3.31.5/bin;${env:USERPROFILE}/.pico-sdk/ninja/v1.12.1;${env:PATH}" ,
180+ Path :
181+ "${env:USERPROFILE}/.pico-sdk/toolchain/14_2_Rel1/bin;${env:USERPROFILE}/.pico-sdk/picotool/2.1.1/picotool;" +
182+ `${ getDirName ( cmakePath . replace ( homePath , "${env:USERPROFILE}" ) ) } ;` +
183+ "${env:USERPROFILE}/.pico-sdk/ninja/v1.12.1;${env:PATH}" ,
170184 } ,
171185 "terminal.integrated.env.osx" : {
172186 PICO_SDK_PATH : "${env:HOME}/.pico-sdk/sdk/2.1.1" ,
173187 PICO_TOOLCHAIN_PATH : "${env:HOME}/.pico-sdk/toolchain/14_2_Rel1" ,
174- PATH : "${env:HOME}/.pico-sdk/toolchain/14_2_Rel1/bin:${env:HOME}/.pico-sdk/picotool/2.1.1/picotool:${env:HOME}/.pico-sdk/cmake/v3.31.5/bin:${env:HOME}/.pico-sdk/ninja/v1.12.1:${env:PATH}" ,
188+ PATH :
189+ "${env:HOME}/.pico-sdk/toolchain/14_2_Rel1/bin:${env:HOME}/.pico-sdk/picotool/2.1.1/picotool:" +
190+ `${ getDirName ( cmakePath . replace ( homePath , "{env:HOME}" ) ) } :` +
191+ "${env:HOME}/.pico-sdk/ninja/v1.12.1:${env:PATH}" ,
175192 } ,
176193 "terminal.integrated.env.linux" : {
177194 PICO_SDK_PATH : "${env:HOME}/.pico-sdk/sdk/2.1.1" ,
178195 PICO_TOOLCHAIN_PATH : "${env:HOME}/.pico-sdk/toolchain/14_2_Rel1" ,
179- PATH : "${env:HOME}/.pico-sdk/toolchain/14_2_Rel1/bin:${env:HOME}/.pico-sdk/picotool/2.1.1/picotool:${env:HOME}/.pico-sdk/cmake/v3.31.5/bin:${env:HOME}/.pico-sdk/ninja/v1.12.1:${env:PATH}" ,
196+ PATH :
197+ "${env:HOME}/.pico-sdk/toolchain/14_2_Rel1/bin:${env:HOME}/.pico-sdk/picotool/2.1.1/picotool:" +
198+ `${ getDirName ( cmakePath . replace ( homePath , "{env:HOME}" ) ) } :` +
199+ "${env:HOME}/.pico-sdk/ninja/v1.12.1:${env:PATH}" ,
180200 } ,
181201 "raspberry-pi-pico.cmakeAutoConfigure" : true ,
182202 "raspberry-pi-pico.useCmakeTools" : false ,
183- "raspberry-pi-pico.cmakePath" :
184- "${HOME}/.pico-sdk/cmake/v3.31.5/bin/cmake" ,
203+ "raspberry-pi-pico.cmakePath" : `${ getDirName (
204+ cmakePath . replace ( homePath , "${HOME}" )
205+ ) } ;`,
185206 "raspberry-pi-pico.ninjaPath" : "${HOME}/.pico-sdk/ninja/v1.12.1/ninja" ,
186207 } ;
187208
@@ -497,9 +518,12 @@ export class NewZephyrProjectPanel {
497518 cmakeVersion : data . cmakeVersion ,
498519 } ) ;
499520
500- if ( zephyrSetupOutputs ! == null ) {
501- this . _logger . info ( zephyrSetupOutputs ) ;
521+ if ( zephyrSetupOutputs = == null ) {
522+ return ;
502523 }
524+
525+ this . _logger . info ( JSON . stringify ( zephyrSetupOutputs ) ) ;
526+
503527 this . _logger . info ( "Generating new Zephyr Project" ) ;
504528
505529 // Create a new directory to put the project in
@@ -593,7 +617,10 @@ export class NewZephyrProjectPanel {
593617 ) ;
594618
595619 // Create settings JSON and write to new folder
596- const settingsJson = NewZephyrProjectPanel . createSettingsJson ( ) ;
620+ const settingsJson = NewZephyrProjectPanel . createSettingsJson (
621+ homeDirectory . replaceAll ( "\\" , "/" ) ,
622+ zephyrSetupOutputs ?. cmakeExecutable || ""
623+ ) ;
597624 await workspace . fs . writeFile (
598625 Uri . file ( settingJsonFile ) ,
599626 Buffer . from ( settingsJson )
0 commit comments