Skip to content

Commit ea8dfa1

Browse files
committed
Use config folder, but fallback to known path for esp
1 parent a51bab0 commit ea8dfa1

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

build_platform.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -459,9 +459,7 @@ def install_boards_local_txt(core_fqbn, boards_local_txt):
459459
try:
460460
local_app_data_dir = os.environ.get('HOME', '')
461461
data_dir = None
462-
if os.path.exists(os.path.join(local_app_data_dir, 'Arduino')):
463-
data_dir = os.path.join(local_app_data_dir, 'Arduino')
464-
elif os.path.exists(os.path.join(local_app_data_dir, '.arduino15')):
462+
if os.path.exists(os.path.join(local_app_data_dir, '.arduino15')):
465463
data_dir = os.path.join(local_app_data_dir, '.arduino15')
466464
elif os.path.exists(os.path.join(local_app_data_dir, '.arduino')):
467465
data_dir = os.path.join(local_app_data_dir, '.arduino')
@@ -476,10 +474,13 @@ def install_boards_local_txt(core_fqbn, boards_local_txt):
476474
ColorPrint.print_info(f"Using arduino-cli config: {config_output.strip()}")
477475

478476
# Extract data directory, with fallback to default
479-
data_dir = config.get("directories", {}).get("data", data_dir)
477+
data_dir = config.get("directories", {}).get("data", "")
480478
if not data_dir:
481-
ColorPrint.print_warn("No valid data directory found, cannot copy boards.local.txt")
482-
return
479+
if os.path.exists(os.path.join(local_app_data_dir, 'Arduino')):
480+
data_dir = os.path.join(local_app_data_dir, 'Arduino')
481+
else:
482+
ColorPrint.print_warn("No valid data directory found, cannot copy boards.local.txt")
483+
return
483484

484485
ColorPrint.print_info(f"Using data directory: {data_dir}")
485486

@@ -501,8 +502,7 @@ def install_boards_local_txt(core_fqbn, boards_local_txt):
501502
os.path.exists(os.path.join(data_dir, "packages", architecture, "hardware", architecture)) else \
502503
os.path.join(data_dir, "hardware", vendor, architecture) if \
503504
os.path.exists(os.path.join(data_dir, "hardware", vendor, architecture)) else \
504-
os.path.join(data_dir, "hardware",
505-
architecture, architecture)
505+
os.path.join(data_dir, "hardware", architecture, architecture)
506506

507507
# Find the latest version directory
508508
if os.path.exists(platform_base):
@@ -511,9 +511,10 @@ def install_boards_local_txt(core_fqbn, boards_local_txt):
511511
ColorPrint.print_info(f"Copied boards.local.txt to {os.path.join(platform_base, 'boards.local.txt')}")
512512
else:
513513
versions = [d for d in os.listdir(platform_base) if os.path.isdir(os.path.join(platform_base, d))]
514-
ColorPrint.print_info(f"Found versions: {versions}")
514+
ColorPrint.print_info(f"Found subdirectories for {platform_base}:\n {versions}")
515515
# Filter out non-version directories (e.g., 'tools', 'libraries') while supporting 1.0-dev 1.0.0-offline-mode.102 etc
516516
versions = [v for v in versions if re.match(r'^(v)?\d+\.\d+(\.\d+(-\w+)?)?(\.\d+)?$', v)]
517+
ColorPrint.print_info(f"Filtered versions: {versions}")
517518
if versions:
518519
# Sort versions and take the latest (could be improved with proper version sorting)
519520
latest_version = sorted(versions)[-1]

0 commit comments

Comments
 (0)