#!/bin/bash # Build script for the Pico firmware. # Creates an out-of-source build directory to keep generated files # separate from the project source code. # # Directory layout expected at project root: # cmake/ - all build-system files (CMakeLists.txt + cmake_config/) # src/ - application source code # build/ - created by this script, holds all CMake/Make output # # Using -S and -B lets us point CMake at the cmake/ source folder while # keeping the build artifacts in a sibling build/ folder at the project root. # Fail fast on any error so a broken configure step doesn't silently lead # to a confusing make error further down. set -e # Configure the build: tell CMake the source directory is cmake/ and the # binary (build) directory is build/. CMake will create build/ if needed. cmake -S cmake -B build # Compile everything using all available CPU cores. The final output is a # .uf2 file in build/ that can be dragged onto the Pico's USB mass storage. cmake --build build -j"$(nproc)"