From 427a64b2c96bdb6384bb921f7ccb6f5d51a387ff Mon Sep 17 00:00:00 2001 From: Markus Kalkbrenner Date: Fri, 31 Oct 2025 22:14:32 +0100 Subject: [PATCH 1/3] Added support for processing library source files closes https://github.com/maxgerhardt/platform-raspberrypi/issues/112 --- builder/frameworks/_build_pioasm.py | 33 ++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/builder/frameworks/_build_pioasm.py b/builder/frameworks/_build_pioasm.py index b5bdafc..b9880c5 100644 --- a/builder/frameworks/_build_pioasm.py +++ b/builder/frameworks/_build_pioasm.py @@ -16,14 +16,27 @@ def pio_to_pioh_cmd(pio_file: Path) -> str: header_file = pio_file.with_suffix(".pio.h") return f'"{pioasm_exe}" -o c-sdk "{pio_file}" "{header_file}"' -# Process all .pio files in PROJECT_SRC_DIR -for pio_file in PROJECT_SRC_DIR.rglob("*.pio"): - header_file = pio_file.with_suffix(".pio.h") +def process_pio_files(src_dir: Path): + """Process all .pio files in the given directory""" + for pio_file in src_dir.rglob("*.pio"): + # Skip if not a file (e.g. directory named .pio) + if not pio_file.is_file(): + continue + + header_file = pio_file.with_suffix(".pio.h") + + # Only rebuild if missing or outdated + if not header_file.exists() or pio_file.stat().st_mtime > header_file.stat().st_mtime: + action = env.VerboseAction(pio_to_pioh_cmd(pio_file), f"Building {header_file}") + ret = env.Execute(action) + if ret != 0: + print(f"[ERROR] Failed to build {pio_file}, stopping.", file=sys.stderr) + sys.exit(1) + +# Process project source files +process_pio_files(PROJECT_SRC_DIR) - # Only rebuild if missing or outdated - if not header_file.exists() or pio_file.stat().st_mtime > header_file.stat().st_mtime: - action = env.VerboseAction(pio_to_pioh_cmd(pio_file), f"Building {header_file}") - ret = env.Execute(action) - if ret != 0: - print(f"[ERROR] Failed to build {pio_file}, stopping.", file=sys.stderr) - sys.exit(1) +# Process library source files +for lib in env.GetLibBuilders(): + if lib.path: + process_pio_files(Path(lib.path)) From 3d9ba25b619653f399b0aa3a7b748acccbbf8248 Mon Sep 17 00:00:00 2001 From: Cpasjuste Date: Sat, 1 Nov 2025 11:17:52 +0100 Subject: [PATCH 2/3] Update _build_pioasm.py --- builder/frameworks/_build_pioasm.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/builder/frameworks/_build_pioasm.py b/builder/frameworks/_build_pioasm.py index b9880c5..2b6e897 100644 --- a/builder/frameworks/_build_pioasm.py +++ b/builder/frameworks/_build_pioasm.py @@ -7,6 +7,7 @@ env = DefaultEnvironment() PROJECT_SRC_DIR = Path(env['PROJECT_SRC_DIR']) +LIB_SRC_DIRS = Path(env['PROJECT_LIBDEPS_DIR']) / env['PIOENV'] # Find the bundled pioasm executable pioasm_dir = env.PioPlatform().get_package_dir("tool-pioasm-rp2040-earlephilhower") @@ -37,6 +38,4 @@ def process_pio_files(src_dir: Path): process_pio_files(PROJECT_SRC_DIR) # Process library source files -for lib in env.GetLibBuilders(): - if lib.path: - process_pio_files(Path(lib.path)) +process_pio_files(LIB_SRC_DIRS) From c7f68d320546210bcbb12e9895e575f31bd7e6b6 Mon Sep 17 00:00:00 2001 From: Markus Kalkbrenner Date: Sat, 1 Nov 2025 14:04:18 +0100 Subject: [PATCH 3/3] Fix variable name for library source directory --- builder/frameworks/_build_pioasm.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/builder/frameworks/_build_pioasm.py b/builder/frameworks/_build_pioasm.py index 2b6e897..0b11bfd 100644 --- a/builder/frameworks/_build_pioasm.py +++ b/builder/frameworks/_build_pioasm.py @@ -7,7 +7,7 @@ env = DefaultEnvironment() PROJECT_SRC_DIR = Path(env['PROJECT_SRC_DIR']) -LIB_SRC_DIRS = Path(env['PROJECT_LIBDEPS_DIR']) / env['PIOENV'] +LIB_SRC_DIR = Path(env['PROJECT_LIBDEPS_DIR']) / env['PIOENV'] # Find the bundled pioasm executable pioasm_dir = env.PioPlatform().get_package_dir("tool-pioasm-rp2040-earlephilhower") @@ -38,4 +38,4 @@ def process_pio_files(src_dir: Path): process_pio_files(PROJECT_SRC_DIR) # Process library source files -process_pio_files(LIB_SRC_DIRS) +process_pio_files(LIB_SRC_DIR)