hololake-system-architecture/product-source/hololake-platform/guanghu-os/scripts/build-native-physical-probe.sh

34 lines
1.1 KiB
Shell
Raw Normal View History

#!/usr/bin/env bash
set -euo pipefail
[[ $# -eq 3 ]] || {
echo "usage: build-native-physical-probe.sh <world-root> <output-directory> <probe-stage>" >&2
exit 64
}
world_root=$(readlink -f "$1")
output_root=$(readlink -m "$2")
probe_stage=$3
[[ ${probe_stage} =~ ^[1-9]$ ]]
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"
layout_args=()
while IFS= read -r argument; do layout_args+=("${argument}"); done \
< <("${source_root}/scripts/native-layout-nasm-args.sh" "${world_root}")
(
cd "${output_root}"
nasm -f bin -I "${output_root}/" -I "${native_root}/" \
"${layout_args[@]}" \
-dGHOS_PHYSICAL_CANDIDATE=1 \
-dGHOS_GHAL_PROBE_STAGE="${probe_stage}" \
"${native_root}/boot.asm" \
-o "guanghu-os-x86_64-bios-probe-${probe_stage}.img"
)
image=${output_root}/guanghu-os-x86_64-bios-probe-${probe_stage}.img
[[ $(stat -c %s "${image}") -eq 14848 ]]
sha256sum "${image}" >"${image}.sha256"