@@ -15,6 +15,7 @@ import { homedir } from "os";
15
15
import { join as joinPosix } from "path/posix" ;
16
16
import Settings from "../settings.mjs" ;
17
17
import Logger from "../logger.mjs" ;
18
+ import { compare } from "../utils/semverUtil.mjs" ;
18
19
import type { WebviewMessage } from "./newProjectPanel.mjs" ;
19
20
import {
20
21
getNonce ,
@@ -28,7 +29,7 @@ import { PythonExtension } from "@vscode/python-extension";
28
29
import { unknownErrorToString } from "../utils/errorHelper.mjs" ;
29
30
import { buildZephyrWorkspacePath } from "../utils/download.mjs" ;
30
31
import { setupZephyr , type ZephyrSetupOutputs } from "../utils/setupZephyr.mjs" ;
31
- import { getCmakeReleases } from "../utils/githubREST.mjs" ;
32
+ import { getCmakeReleases , getNinjaReleases } from "../utils/githubREST.mjs" ;
32
33
33
34
enum BoardType {
34
35
pico = "pico" ,
@@ -49,6 +50,9 @@ interface SubmitMessageValue {
49
50
wifiFeature : boolean ;
50
51
sensorFeature : boolean ;
51
52
shellFeature : boolean ;
53
+ ninjaMode : number ;
54
+ ninjaPath : string ;
55
+ ninjaVersion : string ;
52
56
cmakeMode : number ;
53
57
cmakePath : string ;
54
58
cmakeVersion : string ;
@@ -139,7 +143,8 @@ export class NewZephyrProjectPanel {
139
143
// CMake, Ninja, Python, etc
140
144
private static createSettingsJson (
141
145
homePath : string ,
142
- cmakePath : string
146
+ cmakePath : string ,
147
+ ninjaPath : string
143
148
) : string {
144
149
// Helper functions
145
150
const getDirName = ( s : string ) : string => dirname ( joinPosix ( s ) ) ;
@@ -149,6 +154,11 @@ export class NewZephyrProjectPanel {
149
154
) ;
150
155
console . log ( subbedCmakePath ) ;
151
156
157
+ const subbedNinjaPath = getDirName (
158
+ ninjaPath . replace ( homePath , "${userHome}" )
159
+ ) ;
160
+ console . log ( subbedNinjaPath ) ;
161
+
152
162
const settingsJson = {
153
163
/* eslint-disable @typescript-eslint/naming-convention */
154
164
"cmake.options.statusBarVisibility" : "hidden" ,
@@ -175,30 +185,35 @@ export class NewZephyrProjectPanel {
175
185
Path :
176
186
"${env:USERPROFILE}/.pico-sdk/toolchain/14_2_Rel1/bin;${env:USERPROFILE}/.pico-sdk/picotool/2.1.1/picotool;" +
177
187
`${ getDirName ( cmakePath . replace ( homePath , "${env:USERPROFILE}" ) ) } ;` +
178
- "${env:USERPROFILE}/.pico-sdk/ninja/v1.12.1;${env:PATH}" ,
188
+ `${ getDirName ( ninjaPath . replace ( homePath , "${env:USERPROFILE}" ) ) } ;` +
189
+ "${env:PATH}" ,
179
190
} ,
180
191
"terminal.integrated.env.osx" : {
181
192
PICO_SDK_PATH : "${env:HOME}/.pico-sdk/sdk/2.1.1" ,
182
193
PICO_TOOLCHAIN_PATH : "${env:HOME}/.pico-sdk/toolchain/14_2_Rel1" ,
183
194
PATH :
184
195
"${env:HOME}/.pico-sdk/toolchain/14_2_Rel1/bin:${env:HOME}/.pico-sdk/picotool/2.1.1/picotool:" +
185
196
`${ getDirName ( cmakePath . replace ( homePath , "{env:HOME}" ) ) } :` +
186
- "${env:HOME}/.pico-sdk/ninja/v1.12.1:${env:PATH}" ,
197
+ `${ getDirName ( ninjaPath . replace ( homePath , "{env:HOME}" ) ) } :` +
198
+ "${env:PATH}" ,
187
199
} ,
188
200
"terminal.integrated.env.linux" : {
189
201
PICO_SDK_PATH : "${env:HOME}/.pico-sdk/sdk/2.1.1" ,
190
202
PICO_TOOLCHAIN_PATH : "${env:HOME}/.pico-sdk/toolchain/14_2_Rel1" ,
191
203
PATH :
192
204
"${env:HOME}/.pico-sdk/toolchain/14_2_Rel1/bin:${env:HOME}/.pico-sdk/picotool/2.1.1/picotool:" +
193
205
`${ getDirName ( cmakePath . replace ( homePath , "{env:HOME}" ) ) } :` +
194
- "${env:HOME}/.pico-sdk/ninja/v1.12.1:${env:PATH}" ,
206
+ `${ getDirName ( ninjaPath . replace ( homePath , "{env:HOME}" ) ) } :` +
207
+ "${env:PATH}" ,
195
208
} ,
196
209
"raspberry-pi-pico.cmakeAutoConfigure" : true ,
197
210
"raspberry-pi-pico.useCmakeTools" : false ,
198
211
"raspberry-pi-pico.cmakePath" : `${ getDirName (
199
212
cmakePath . replace ( homePath , "${HOME}" )
200
213
) } ;`,
201
- "raspberry-pi-pico.ninjaPath" : "${HOME}/.pico-sdk/ninja/v1.12.1/ninja" ,
214
+ "raspberry-pi-pico.ninjaPath" : `${ getDirName (
215
+ ninjaPath . replace ( homePath , "${HOME}" )
216
+ ) } ;`,
202
217
} ;
203
218
204
219
/* eslint-enable @typescript-eslint/naming-convention */
@@ -478,6 +493,9 @@ export class NewZephyrProjectPanel {
478
493
cmakeMode : data . cmakeMode ,
479
494
cmakePath : data . cmakePath ,
480
495
cmakeVersion : data . cmakeVersion ,
496
+ ninjaMode : data . ninjaMode ,
497
+ ninjaPath : data . ninjaPath ,
498
+ ninjaVersion : data . ninjaVersion ,
481
499
} ) ;
482
500
483
501
if ( zephyrSetupOutputs === null ) {
@@ -581,7 +599,8 @@ export class NewZephyrProjectPanel {
581
599
// Create settings JSON and write to new folder
582
600
const settingsJson = NewZephyrProjectPanel . createSettingsJson (
583
601
homeDirectory . replaceAll ( "\\" , "/" ) ,
584
- zephyrSetupOutputs ?. cmakeExecutable || ""
602
+ zephyrSetupOutputs ?. cmakeExecutable || "" ,
603
+ zephyrSetupOutputs ?. ninjaExecutable || ""
585
604
) ;
586
605
await workspace . fs . writeFile (
587
606
Uri . file ( settingJsonFile ) ,
@@ -693,6 +712,18 @@ export class NewZephyrProjectPanel {
693
712
const knownEnvironments = environments ?. known ;
694
713
const activeEnv = environments ?. getActiveEnvironmentPath ( ) ;
695
714
715
+ let ninjasHtml = "" ;
716
+ const ninjaReleases = await getNinjaReleases ( ) ;
717
+ console . debug ( ninjaReleases ) ;
718
+ const latestNinjaRelease = ninjaReleases [ 0 ] ;
719
+ ninjaReleases
720
+ . sort ( ( a , b ) => compare ( b . replace ( "v" , "" ) , a . replace ( "v" , "" ) ) )
721
+ . forEach ( ninja => {
722
+ ninjasHtml += `<option ${
723
+ ninjasHtml . length === 0 ? "selected " : ""
724
+ } value="${ ninja } ">${ ninja } </option>`;
725
+ } ) ;
726
+
696
727
let cmakesHtml = "" ;
697
728
const cmakeReleases = await getCmakeReleases ( ) ;
698
729
console . debug ( cmakeReleases ) ;
@@ -708,6 +739,9 @@ export class NewZephyrProjectPanel {
708
739
( await which ( "python3" , { nothrow : true } ) ) !== null ||
709
740
( await which ( "python" , { nothrow : true } ) ) !== null ;
710
741
742
+ const isNinjaSystemAvailable =
743
+ ( await which ( "ninja" , { nothrow : true } ) ) !== null ;
744
+
711
745
const isCmakeSystemAvailable =
712
746
( await which ( "cmake" , { nothrow : true } ) ) !== null ;
713
747
@@ -974,6 +1008,41 @@ export class NewZephyrProjectPanel {
974
1008
</div>
975
1009
</div>
976
1010
1011
+ <div class="col-span-2">
1012
+ <label class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Ninja Version:</label>
1013
+ ${
1014
+ latestNinjaRelease !== undefined
1015
+ ? `<div class="flex items-center mb-2">
1016
+ <input type="radio" id="ninja-radio-default-version" name="ninja-version-radio" value="0" class="mr-1 text-blue-500" checked="checked">
1017
+ <label id="ninja-radio-latest-version" name=${ latestNinjaRelease } for="ninja-radio-default-version" class="text-gray-900 dark:text-white">Default version</label>
1018
+ </div>`
1019
+ : ""
1020
+ }
1021
+
1022
+ ${
1023
+ isNinjaSystemAvailable
1024
+ ? `<div class="flex items-center mb-2" >
1025
+ <input type="radio" id="ninja-radio-system-version" name="ninja-version-radio" value="1" class="mr-1 text-blue-500">
1026
+ <label for="ninja-radio-system-version" class="text-gray-900 dark:text-white">Use system version</label>
1027
+ </div>`
1028
+ : ""
1029
+ }
1030
+
1031
+ <div class="flex items-center mb-2">
1032
+ <input type="radio" id="ninja-radio-select-version" name="ninja-version-radio" value="2" class="mr-1 text-blue-500">
1033
+ <label for="ninja-radio-select-version" class="text-gray-900 dark:text-white">Select version:</label>
1034
+ <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">
1035
+ ${ ninjasHtml }
1036
+ </select>
1037
+ </div>
1038
+
1039
+ <div class="flex items-center mb-2">
1040
+ <input type="radio" id="ninja-radio-path-executable" name="ninja-version-radio" value="3" class="mr-1 text-blue-500">
1041
+ <label for="ninja-radio-path-executable" class="text-gray-900 dark:text-white">Path to executable:</label>
1042
+ <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">
1043
+ </div>
1044
+ </div>
1045
+
977
1046
<div class="bottom-3 mt-8 mb-12 w-full flex justify-end">
978
1047
<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>
979
1048
<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