Skip to content

Commit 7a10d6d

Browse files
committed
Add copy step for boards.local.txt
1 parent f95039b commit 7a10d6d

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

build_platform.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,8 +473,30 @@ def main():
473473
fqbn = ALL_PLATFORMS[platform][0]
474474
print('#'*80)
475475
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}")
477497
print('#'*80)
498+
499+
# Test examples in the platform folder
478500
if not IS_LEARNING_SYS:
479501
test_examples_in_folder(platform, BUILD_DIR+"/examples")
480502
else:

0 commit comments

Comments
 (0)