@@ -282,6 +282,8 @@ def apply_template(self, project: Project, identifier: Union[str, BaseTemplate],
282
282
raise dont_send (
283
283
InvalidTemplateException (f'Could not find a template satisfying { identifier } for { project .target } ' ))
284
284
285
+ apply_liblvgl = False # flag to apply liblvgl if upgrading to PROS 4
286
+
285
287
# warn and prompt user if upgrading to PROS 4 or downgrading to PROS 3
286
288
if template .name == 'kernel' :
287
289
isProject = Project .find_project ("" )
@@ -294,26 +296,14 @@ def apply_template(self, project: Project, identifier: Union[str, BaseTemplate],
294
296
if not confirm :
295
297
raise dont_send (
296
298
InvalidTemplateException (f'Not upgrading' ))
299
+ apply_liblvgl = True
297
300
if template .version [0 ] == '3' and curr_proj .kernel [0 ] == '4' :
298
301
confirm = ui .confirm (f'Warning! Downgrading project to PROS 3 will cause breaking changes. '
299
302
f'Do you still want to downgrade?' )
300
303
if not confirm :
301
304
raise dont_send (
302
305
InvalidTemplateException (f'Not downgrading' ))
303
- elif not project .use_early_access and template .version [0 ] == '3' and not self .warn_early_access :
304
- confirm = ui .confirm (f'PROS 4 is now in early access. '
305
- f'Please use the --early-access flag if you would like to use it.\n '
306
- f'Do you want to use PROS 4 instead?' )
307
- self .warn_early_access = True
308
- if confirm : # use pros 4
309
- project .use_early_access = True
310
- project .save ()
311
- kwargs ['version' ] = '>=0'
312
- kwargs ['early_access' ] = True
313
- # Recall the function with early access enabled
314
- return self .apply_template (project , identifier , ** kwargs )
315
-
316
- self .save ()
306
+
317
307
if not isinstance (template , LocalTemplate ):
318
308
with ui .Notification ():
319
309
template = self .fetch_template (self .get_depot (template .metadata ['origin' ]), template , ** kwargs )
@@ -333,6 +323,16 @@ def apply_template(self, project: Project, identifier: Union[str, BaseTemplate],
333
323
force_user = kwargs .pop ('force_user' , False ),
334
324
remove_empty_directories = kwargs .pop ('remove_empty_directories' , False ))
335
325
ui .finalize ('apply' , f'Finished applying { template .identifier } to { project .location } ' )
326
+
327
+ # Apply liblvgl if upgrading to PROS 4
328
+ if apply_liblvgl :
329
+ template = self .resolve_template (identifier = "liblvgl" , allow_online = download_ok , early_access = True )
330
+ if not isinstance (template , LocalTemplate ):
331
+ with ui .Notification ():
332
+ template = self .fetch_template (self .get_depot (template .metadata ['origin' ]), template , ** kwargs )
333
+ assert isinstance (template , LocalTemplate )
334
+ project .apply_template (template )
335
+ ui .finalize ('apply' , f'Finished applying { template .identifier } to { project .location } ' )
336
336
elif valid_action != TemplateAction .AlreadyInstalled :
337
337
raise dont_send (
338
338
InvalidTemplateException (f'Could not install { template .identifier } because it is { valid_action .name } ,'
@@ -358,22 +358,8 @@ def new_project(self, path: str, no_default_libs: bool = False, **kwargs) -> Pro
358
358
else :
359
359
use_early_access = self .use_early_access
360
360
kwargs ["early_access" ] = use_early_access
361
- if kwargs ["version_source" ]: # If true, then the user has not specified a version
362
- if not use_early_access and self .warn_early_access :
363
- ui .echo (f"PROS 4 is now in early access. "
364
- f"If you would like to use it, use the --early-access flag." )
365
- elif not use_early_access and not self .warn_early_access :
366
- confirm = ui .confirm (f'PROS 4 is now in early access. '
367
- f'Please use the --early-access flag if you would like to use it.\n '
368
- f'Do you want to use PROS 4 instead?' )
369
- self .warn_early_access = True
370
- if confirm :
371
- use_early_access = True
372
- kwargs ['early_access' ] = True
373
- elif use_early_access :
374
- ui .echo (f'Early access is enabled. Using PROS 4.' )
375
- elif use_early_access :
376
- ui .echo (f'Early access is enabled.' )
361
+ if use_early_access :
362
+ ui .echo (f'Early access is enabled. Experimental features have been applied.' )
377
363
378
364
if not is_pathname_valid (str (Path (path ).absolute ())):
379
365
raise dont_send (ValueError ('Project path contains invalid characters.' ))
@@ -397,6 +383,9 @@ def new_project(self, path: str, no_default_libs: bool = False, **kwargs) -> Pro
397
383
if not no_default_libs :
398
384
libraries = self .early_access_libraries if proj .use_early_access and (kwargs .get ("version" , ">" ).startswith ("4" ) or kwargs .get ("version" , ">" ).startswith (">" )) else self .default_libraries
399
385
386
+ if kwargs ['version' ][0 ] == '>' or kwargs ['version' ][0 ] == '4' :
387
+ libraries [proj .target ].remove ('okapilib' )
388
+
400
389
for library in libraries [proj .target ]:
401
390
try :
402
391
# remove kernel version so that latest template satisfying query is correctly selected
0 commit comments