foundry
Foundry OS: the operating system built on the Rustbelt kernel
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | #!/usr/bin/env bash
# Build the pinned Rustbelt kernel for Foundry OS, without touching the
# kernel repo's working tree or its target/ directory.
#
# 1. `git archive KERNEL_REV` reads the commit straight from the kernel
# repo's git object store and unpacks it into out/kernel-src. Nothing in
# KERNEL_DIR is written.
# 2. cargo builds it there with CARGO_TARGET_DIR=out/kernel-target.
# (Cargo reads .cargo/config.toml and rust-toolchain.toml from the
# directory it runs in, so we must cd into the kernel source first.)
# 3. Two boot images are kept: out/kernel/bootimage-headless.bin (runs the
# self-test, then powers QEMU off) and out/kernel/bootimage.bin
# (interactive).
#
# Side effect we rely on: the kernel's build.rs also writes its own disk
# images into out/kernel-target: disk.img (the reference for `make compare`)
# and the kernel-owned test disks ext2.img, exfat.img, btrfs.img, which
# `make run`/`make test` attach as drives C:, D:, E: (contract v1, point 5).
# So this build must NOT set RUSTBELT_DISK0 (K1, kernel 0.21.0+): that would
# replace the reference disk.img with ours. `make k1-check` does that in a
# separate target dir instead.
#
# Usage: scripts/build-kernel.sh KERNEL_DIR KERNEL_REV OUT_DIR [--export-only]
KERNEL_DIR= KERNEL_REV= OUT=
SRC=/kernel-src TARGET=/kernel-target DEST=/kernel
want=
if [; then
&&
|
fi
[ &&
ELF=/x86_64-rust_kernel/debug/rustbelt
BOOT=/x86_64-rust_kernel/debug/bootimage-rustbelt.bin
for; do
if [; then feat=(--features headless); out=/bootimage-headless.bin
else feat=(); out=/bootimage.bin; fi
# bootimage caches by timestamp; switching features can reuse an old
# ELF, so touch it (the kernel's scripts/runner.sh does the same).
done
|