Publish firmware artifacts after build

This commit is contained in:
Joey Yakimowich-Payne 2026-08-29 13:39:44 -06:00
commit b2d2becc34
4 changed files with 12 additions and 1 deletions

View file

@ -106,7 +106,8 @@ Prereqs: Pico SDK + CMake toolchain set up.
### Using `build.py`
`build.py` configures CMake, builds the firmware, checks that both output formats
were created, and flashes the ELF with `picotool`.
were created, copies the release artifacts into `firmware/`, and flashes the ELF
with `picotool`.
Before running it:
@ -122,6 +123,8 @@ The generated files are:
- `build/switch-pico.elf`, which `build.py` passes to `picotool`.
- `build/switch-pico.uf2`, which can also be copied to the Pico manually.
- `firmware/switch-pico.elf` and `firmware/switch-pico.uf2`, refreshed from the
corresponding `build/` artifacts after every successful build.
To customize the controller grip color while building, pass one of these mutually
exclusive options:

View file

@ -12,6 +12,9 @@ from pathlib import Path
SCRIPT_DIR = Path(__file__).resolve().parent
CONFIG_FILE = SCRIPT_DIR / "controller_color_config.h"
BUILD_DIR = SCRIPT_DIR / "build"
FIRMWARE_DIR = SCRIPT_DIR / "firmware"
FIRMWARE_ELF_PATH = FIRMWARE_DIR / "switch-pico.elf"
FIRMWARE_UF2_PATH = FIRMWARE_DIR / "switch-pico.uf2"
ELF_PATH = Path(os.environ.get("ELF_PATH", BUILD_DIR / "switch-pico.elf")).expanduser()
UF2_PATH = Path(os.environ.get("UF2_PATH", BUILD_DIR / "switch-pico.uf2")).expanduser()
@ -126,9 +129,14 @@ def build():
missing = ", ".join(str(path) for path in missing_artifacts)
sys.stderr.write(f"Error: Build did not produce required artifact(s): {missing}\n")
sys.exit(1)
FIRMWARE_DIR.mkdir(parents=True, exist_ok=True)
shutil.copy2(ELF_PATH, FIRMWARE_ELF_PATH)
shutil.copy2(UF2_PATH, FIRMWARE_UF2_PATH)
print(f"Built ELF: {ELF_PATH}")
print(f"Built UF2: {UF2_PATH}")
print(f"Copied ELF: {FIRMWARE_ELF_PATH}")
print(f"Copied UF2: {FIRMWARE_UF2_PATH}")
def flash():
picotool = resolve_picotool()

Binary file not shown.

Binary file not shown.