@@ -14,6 +14,7 @@ import {
1414import  {  join  as  joinPosix  }  from  "path/posix" ; 
1515import  Settings  from  "../settings.mjs" ; 
1616import  Logger  from  "../logger.mjs" ; 
17+ import  {  compare  }  from  "../utils/semverUtil.mjs" ; 
1718import  type  {  WebviewMessage  }  from  "./newProjectPanel.mjs" ; 
1819import  { 
1920  getNonce , 
@@ -25,7 +26,7 @@ import { join, dirname } from "path";
2526import  {  PythonExtension  }  from  "@vscode/python-extension" ; 
2627import  {  unknownErrorToString  }  from  "../utils/errorHelper.mjs" ; 
2728import  {  setupZephyr  }  from  "../utils/setupZephyr.mjs" ; 
28- import  {  getCmakeReleases  }  from  "../utils/githubREST.mjs" ; 
29+ import  {  getCmakeReleases ,   getNinjaReleases  }  from  "../utils/githubREST.mjs" ; 
2930import  {  getSystemCmakeVersion  }  from  "../utils/cmakeUtil.mjs" ; 
3031import  {  generateZephyrProject  }  from  "../utils/projectGeneration/projectZephyr.mjs" ; 
3132import  { 
@@ -53,7 +54,8 @@ export class NewZephyrProjectPanel {
5354  // CMake, Ninja, Python, etc 
5455  private  static  createSettingsJson ( 
5556    homePath : string , 
56-     cmakePath : string 
57+     cmakePath : string , 
58+     ninjaPath : string 
5759  ) : string  { 
5860    // Helper functions 
5961    const  getDirName  =  ( s : string ) : string  =>  dirname ( joinPosix ( s ) ) ; 
@@ -63,6 +65,11 @@ export class NewZephyrProjectPanel {
6365    ) ; 
6466    console . log ( subbedCmakePath ) ; 
6567
68+     const  subbedNinjaPath  =  getDirName ( 
69+       ninjaPath . replace ( homePath ,  "${userHome}" ) 
70+     ) ; 
71+     console . log ( subbedNinjaPath ) ; 
72+ 
6673    const  settingsJson  =  { 
6774      /* eslint-disable @typescript-eslint/naming-convention */ 
6875      "cmake.options.statusBarVisibility" : "hidden" , 
@@ -89,30 +96,35 @@ export class NewZephyrProjectPanel {
8996        Path :
9097          "${env:USERPROFILE}/.pico-sdk/toolchain/14_2_Rel1/bin;${env:USERPROFILE}/.pico-sdk/picotool/2.1.1/picotool;"  + 
9198          `${ getDirName ( cmakePath . replace ( homePath ,  "${env:USERPROFILE}" ) ) }   + 
92-           "${env:USERPROFILE}/.pico-sdk/ninja/v1.12.1;${env:PATH}" , 
99+           `${ getDirName ( ninjaPath . replace ( homePath ,  "${env:USERPROFILE}" ) ) }   + 
100+           "${env:PATH}" , 
93101      } , 
94102      "terminal.integrated.env.osx" : { 
95103        PICO_SDK_PATH : "${env:HOME}/.pico-sdk/sdk/2.1.1" , 
96104        PICO_TOOLCHAIN_PATH : "${env:HOME}/.pico-sdk/toolchain/14_2_Rel1" , 
97105        PATH :
98106          "${env:HOME}/.pico-sdk/toolchain/14_2_Rel1/bin:${env:HOME}/.pico-sdk/picotool/2.1.1/picotool:"  + 
99107          `${ getDirName ( cmakePath . replace ( homePath ,  "{env:HOME}" ) ) }   + 
100-           "${env:HOME}/.pico-sdk/ninja/v1.12.1:${env:PATH}" , 
108+           `${ getDirName ( ninjaPath . replace ( homePath ,  "{env:HOME}" ) ) }   + 
109+           "${env:PATH}" , 
101110      } , 
102111      "terminal.integrated.env.linux" : { 
103112        PICO_SDK_PATH : "${env:HOME}/.pico-sdk/sdk/2.1.1" , 
104113        PICO_TOOLCHAIN_PATH : "${env:HOME}/.pico-sdk/toolchain/14_2_Rel1" , 
105114        PATH :
106115          "${env:HOME}/.pico-sdk/toolchain/14_2_Rel1/bin:${env:HOME}/.pico-sdk/picotool/2.1.1/picotool:"  + 
107116          `${ getDirName ( cmakePath . replace ( homePath ,  "{env:HOME}" ) ) }   + 
108-           "${env:HOME}/.pico-sdk/ninja/v1.12.1:${env:PATH}" , 
117+           `${ getDirName ( ninjaPath . replace ( homePath ,  "{env:HOME}" ) ) }   + 
118+           "${env:PATH}" , 
109119      } , 
110120      "raspberry-pi-pico.cmakeAutoConfigure" : true , 
111121      "raspberry-pi-pico.useCmakeTools" : false , 
112122      "raspberry-pi-pico.cmakePath" : `${ getDirName (  
113123        cmakePath . replace ( homePath ,  "${HOME}" )  
114124      ) }  ;`, 
115-       "raspberry-pi-pico.ninjaPath" : "${HOME}/.pico-sdk/ninja/v1.12.1/ninja" , 
125+       "raspberry-pi-pico.ninjaPath" : `${ getDirName (  
126+         ninjaPath . replace ( homePath ,  "${HOME}" )  
127+       ) }  ;`, 
116128    } ; 
117129
118130    /* eslint-enable @typescript-eslint/naming-convention */ 
@@ -512,6 +524,18 @@ export class NewZephyrProjectPanel {
512524    //const knownEnvironments = environments?.known; 
513525    //const activeEnv = environments?.getActiveEnvironmentPath(); 
514526
527+     let  ninjasHtml  =  "" ; 
528+     const  ninjaReleases  =  await  getNinjaReleases ( ) ; 
529+     console . debug ( ninjaReleases ) ; 
530+     const  latestNinjaRelease  =  ninjaReleases [ 0 ] ; 
531+     ninjaReleases 
532+       . sort ( ( a ,  b )  =>  compare ( b . replace ( "v" ,  "" ) ,  a . replace ( "v" ,  "" ) ) ) 
533+       . forEach ( ninja  =>  { 
534+         ninjasHtml  +=  `<option ${  
535+           ninjasHtml . length  ===  0  ? "selected "  : ""  
536+         }  value="${ ninja } ${ ninja } ; 
537+       } ) ; 
538+ 
515539    let  cmakesHtml  =  "" ; 
516540    const  cmakeReleases  =  await  getCmakeReleases ( ) ; 
517541    cmakeReleases . forEach ( cmake  =>  { 
@@ -841,6 +865,41 @@ export class NewZephyrProjectPanel {
841865              </fieldset> 
842866          </div> 
843867
868+           <div class="col-span-2"> 
869+             <label class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Ninja Version:</label> 
870+             ${  
871+               latestNinjaRelease  !==  undefined  
872+                 ? `<div class="flex items-center mb-2">  
873+                     <input type="radio" id="ninja-radio-default-version" name="ninja-version-radio" value="0" class="mr-1 text-blue-500" checked="checked"> 
874+                     <label id="ninja-radio-latest-version" name=${ latestNinjaRelease }  
875+                   </div>` 
876+                 : ""  
877+             }  
878+ 
879+             ${  
880+               isNinjaSystemAvailable  
881+                 ? `<div class="flex items-center mb-2" >  
882+                     <input type="radio" id="ninja-radio-system-version" name="ninja-version-radio" value="1" class="mr-1 text-blue-500"> 
883+                     <label for="ninja-radio-system-version" class="text-gray-900 dark:text-white">Use system version</label> 
884+                   </div>` 
885+                 : ""  
886+             }  
887+ 
888+             <div class="flex items-center mb-2"> 
889+               <input type="radio" id="ninja-radio-select-version" name="ninja-version-radio" value="2" class="mr-1 text-blue-500"> 
890+               <label for="ninja-radio-select-version" class="text-gray-900 dark:text-white">Select version:</label> 
891+               <select id="sel-ninja" class="ml-2 bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"> 
892+                 ${ ninjasHtml }  
893+               </select> 
894+             </div> 
895+ 
896+             <div class="flex items-center mb-2"> 
897+               <input type="radio" id="ninja-radio-path-executable" name="ninja-version-radio" value="3" class="mr-1 text-blue-500"> 
898+               <label for="ninja-radio-path-executable" class="text-gray-900 dark:text-white">Path to executable:</label> 
899+               <input type="file" id="ninja-path-executable" multiple="false" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500 ms-2"> 
900+             </div> 
901+           </div> 
902+ 
844903          <div class="bottom-3 mt-8 mb-12 w-full flex justify-end"> 
845904              <button id="btn-cancel" class="focus:outline-none bg-transparent ring-2 focus:ring-4 ring-red-400 dark:ring-red-700 font-medium rounded-lg text-lg px-4 py-2 mr-4 hover:bg-red-500 dark:hover:bg-red-700 focus:ring-red-600 dark:focus:ring-red-800">Cancel</button> 
846905              <button id="btn-create" class="focus:outline-none bg-transparent ring-2 focus:ring-4 ring-green-400 dark:ring-green-700 font-medium rounded-lg text-lg px-4 py-2 mr-2 hover:bg-green-500 dark:hover:bg-green-700 focus:ring-green-600 dark:focus:ring-green-800"> 
0 commit comments