25 lines
839 B
Shell
Executable file
25 lines
839 B
Shell
Executable file
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
[[ $# -eq 2 ]] || {
|
|
echo "usage: build-native-bios-image.sh <world-root> <output-directory>" >&2
|
|
exit 64
|
|
}
|
|
|
|
world_root=$(readlink -f "$1")
|
|
output_root=$(readlink -m "$2")
|
|
source_root=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
|
|
native_root=${source_root}/native/x86_64-bios
|
|
|
|
command -v nasm >/dev/null
|
|
mkdir -p "${output_root}"
|
|
cargo run --quiet --manifest-path "${source_root}/Cargo.toml" \
|
|
-p hldp-native-compiler -- "${world_root}" "${output_root}/world.inc"
|
|
(
|
|
cd "${output_root}"
|
|
nasm -f bin -I "${output_root}/" -I "${native_root}/" "${native_root}/boot.asm" \
|
|
-o guanghu-os-x86_64-bios.img
|
|
)
|
|
[[ $(stat -c %s "${output_root}/guanghu-os-x86_64-bios.img") -eq 14848 ]]
|
|
sha256sum "${output_root}/guanghu-os-x86_64-bios.img" \
|
|
>"${output_root}/guanghu-os-x86_64-bios.img.sha256"
|