@@ -259,7 +259,7 @@ export async function activate(context: ExtensionContext): Promise<void> {
259259    return ; 
260260  } 
261261
262-   void  commands . executeCommand ( 
262+   await  commands . executeCommand ( 
263263    "setContext" , 
264264    ContextKeys . isRustProject , 
265265    isRustProject 
@@ -315,15 +315,102 @@ export async function activate(context: ExtensionContext): Promise<void> {
315315        return ; 
316316      } 
317317
318+       const  cmakePath  =  settings . getString ( SettingsKey . cmakePath ) ; 
319+       // TODO: or auto upgrade to latest cmake 
320+       if  ( cmakePath  ===  undefined )  { 
321+         Logger . error ( 
322+           LoggerSource . extension , 
323+           "CMake path not set in settings. Cannot setup Zephyr project." 
324+         ) ; 
325+         void  window . showErrorMessage ( 
326+           "CMake path not set in settings. Cannot setup Zephyr project." 
327+         ) ; 
328+         await  commands . executeCommand ( 
329+           "setContext" , 
330+           ContextKeys . isPicoProject , 
331+           false 
332+         ) ; 
333+ 
334+         return ; 
335+       } 
336+       let  cmakeVersion  =  "" ; 
337+       if  ( cmakePath  &&  cmakePath . includes ( "/.pico-sdk/cmake" ) )  { 
338+         const  version  =  / \/ \. p i c o - s d k \/ c m a k e \/ ( [ v . 0 - 9 A - Z a - z - ] + ) \/ / . exec ( 
339+           cmakePath 
340+         ) ?. [ 1 ] ; 
341+ 
342+         if  ( version  ===  undefined )  { 
343+           Logger . error ( 
344+             LoggerSource . extension , 
345+             "Failed to get CMake version from path in the settings." 
346+           ) ; 
347+           await  commands . executeCommand ( 
348+             "setContext" , 
349+             ContextKeys . isPicoProject , 
350+             false 
351+           ) ; 
352+ 
353+           return ; 
354+         } 
355+ 
356+         cmakeVersion  =  version ; 
357+       } 
358+ 
359+       const  ninjaPath  =  settings . getString ( SettingsKey . ninjaPath ) ; 
360+       let  ninjaVersion  =  "" ; 
361+       if  ( ninjaPath  ===  undefined )  { 
362+         Logger . error ( 
363+           LoggerSource . extension , 
364+           "Ninja path not set in settings. Cannot setup Zephyr project." 
365+         ) ; 
366+         void  window . showErrorMessage ( 
367+           "Ninja path not set in settings. Cannot setup Zephyr project." 
368+         ) ; 
369+         await  commands . executeCommand ( 
370+           "setContext" , 
371+           ContextKeys . isPicoProject , 
372+           false 
373+         ) ; 
374+ 
375+         return ; 
376+       }  else  if  ( ninjaPath  &&  ninjaPath . includes ( "/.pico-sdk/ninja" ) )  { 
377+         const  version  =  / \/ \. p i c o - s d k \/ n i n j a \/ ( [ v . 0 - 9 ] + ) \/ / . exec ( 
378+           ninjaPath 
379+         ) ?. [ 1 ] ; 
380+         if  ( version  ===  undefined )  { 
381+           Logger . error ( 
382+             LoggerSource . extension , 
383+             "Failed to get Ninja version from path in the settings." 
384+           ) ; 
385+           await  commands . executeCommand ( 
386+             "setContext" , 
387+             ContextKeys . isPicoProject , 
388+             false 
389+           ) ; 
390+ 
391+           return ; 
392+         } 
393+ 
394+         ninjaVersion  =  version ; 
395+       } 
396+ 
318397      // TODO: read selected ninja and cmake versions from project 
319398      const  result  =  await  setupZephyr ( { 
320399        extUri : context . extensionUri , 
321-         cmakeMode : 4 , 
322-         cmakePath : "" , 
323-         cmakeVersion : latest [ 1 ] . cmake , 
324-         ninjaMode : 4 , 
325-         ninjaPath : "" , 
326-         ninjaVersion : latest [ 1 ] . ninja , 
400+         cmakeMode : cmakeVersion  !==  ""  ? 2  : 3 , 
401+         cmakePath :
402+           cmakeVersion  !==  "" 
403+             ? "" 
404+             : cmakePath . replace ( HOME_VAR ,  homedir ( ) . replaceAll ( "\\" ,  "/" ) )  ?? 
405+               "" , 
406+         cmakeVersion : cmakeVersion , 
407+         ninjaMode : ninjaVersion  !==  ""  ? 2  : 3 , 
408+         ninjaPath :
409+           ninjaVersion  !==  "" 
410+             ? "" 
411+             : ninjaPath . replace ( HOME_VAR ,  homedir ( ) . replaceAll ( "\\" ,  "/" ) )  ?? 
412+               "" , 
413+         ninjaVersion : ninjaVersion , 
327414      } ) ; 
328415      if  ( result  ===  undefined )  { 
329416        void  window . showErrorMessage ( 
0 commit comments