Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 22 additions & 10 deletions builder/frameworks/_build_pioasm.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
env = DefaultEnvironment()

PROJECT_SRC_DIR = Path(env['PROJECT_SRC_DIR'])
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")
Expand All @@ -16,14 +17,25 @@ 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
process_pio_files(LIB_SRC_DIR)