#!/usr/bin/env bash # # scripts/build.sh — compile the kernel and every external binary. # # The only cargo invocation in the project. One pass builds the kernel # (rsdos.efi) and all /bin binaries (bins/*.efi), which is exactly what # the system image stages. # # Usage: # ./scripts/build.sh release (default — what the image uses) # ./scripts/build.sh --debug debug profile (slower guest, GDB symbols) # ./scripts/build.sh --help # # Output: # target/x86_64-unknown-uefi//rsdos.efi kernel # target/x86_64-unknown-uefi//.efi /bin binaries # # Typical flow: # ./scripts/build.sh && ./scripts/run.sh # set -euo pipefail usage() { awk 'NR > 1 && /^#/ { sub(/^# ?/, ""); print; next } NR > 1 { exit }' "$0" } # PROFILE is read by lib.sh (it derives OUT_DIR/KERNEL from it), so parse # before sourcing. while [ $# -gt 0 ]; do case "$1" in --debug) PROFILE="debug" ;; --release) PROFILE="release" ;; --help | -h) usage exit 0 ;; *) echo "build.sh: unknown argument: $1" >&2 exit 1 ;; esac shift done # shellcheck source=lib.sh source "$(dirname "$0")/lib.sh" build_all echo "kernel: $KERNEL"