@@ -473,8 +473,30 @@ def main():
473
473
fqbn = ALL_PLATFORMS [platform ][0 ]
474
474
print ('#' * 80 )
475
475
ColorPrint .print_info ("SWITCHING TO " + fqbn )
476
- install_platform (":" .join (fqbn .split (':' , 2 )[0 :2 ]), ALL_PLATFORMS [platform ]) # take only first two elements
476
+ core_fqbn = ":" .join (fqbn .split (':' , 2 )[0 :2 ])
477
+ install_platform (core_fqbn , ALL_PLATFORMS [platform ]) # take only first two elements
478
+
479
+ # Inject boards.local.txt if enabled
480
+ if COPY_BOARDS_LOCAL_TXT and boards_local_txt :
481
+ try :
482
+ # Find platform path via `arduino-cli core list --format json`
483
+ import json
484
+ output = subprocess .check_output (["arduino-cli" , "core" , "list" , "--format" , "json" ]).decode ()
485
+ core_list = json .loads (output )
486
+ for core in core_list :
487
+ if core ["id" ] == core_fqbn :
488
+ platform_path = core ["install_dir" ]
489
+ dest_path = os .path .join (platform_path , "boards.local.txt" )
490
+ shutil .copyfile (boards_local_txt , dest_path )
491
+ ColorPrint .print_info (f"Copied boards.local.txt to { dest_path } " )
492
+ break
493
+ else :
494
+ ColorPrint .print_warn (f"Could not find platform path for { core_fqbn } - not copying boards.local.txt" )
495
+ except Exception as e :
496
+ ColorPrint .print_fail (f"Error injecting boards.local.txt for { core_fqbn } : { e } " )
477
497
print ('#' * 80 )
498
+
499
+ # Test examples in the platform folder
478
500
if not IS_LEARNING_SYS :
479
501
test_examples_in_folder (platform , BUILD_DIR + "/examples" )
480
502
else :
0 commit comments