Files
unkernel/guest/lib/env.sh

36 lines
1.6 KiB
Bash

# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright (C) 2026 Pooya Parsa <pooya@pi0.io>
# Sourced by the guest/ build scripts (bash). Sources kernel/tools/env.sh
# (root, vendor, build, zig, fetch_verified, need_zig, ...) and sets:
# guest this directory's parent (guest/)
# dl vendor/downloads
# base_out the base initramfs's outputs (base.cpio, base-test.cpio and
# their staging trees): $KW_BASE_OUT if set, else
# $build/initramfs
# base_bundle the distroless bundle the base build ends in (kernel/build.sh
# base): $KW_BASE_OUT/unkernel.wasm if set, else
# $build/bundle/unkernel.wasm
# cc_guest zig cc for the guest programs: static aarch64 musl for the
# generic CPU (ARMv8.0, what kwemu runs), with no build
# directory in the output
. "$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)/kernel/tools/env.sh"
guest="$root/guest"
dl="$vendor/downloads"
kw_arch="${KW_ARCH:-a64}"
if [ -n "${KW_BASE_OUT:-}" ]; then
base_out="$(realpath -m "$KW_BASE_OUT")"
base_bundle="$base_out/unkernel.wasm"
elif [ "$kw_arch" = x64 ]; then
base_out="$build/initramfs-x64"
base_bundle="$build/bundle-x64/unkernel.wasm"
else
base_out="$build/initramfs"
base_bundle="$build/bundle/unkernel.wasm"
fi
if [ "$kw_arch" = x64 ]; then
cc_guest=("$zig" cc -target x86_64-linux-musl -mcpu=x86_64_v3 -static -O2 -s "-ffile-prefix-map=$root/=")
cc_guest32=("$zig" cc -target x86-linux-musl -mcpu=i686 -static -O2 -s "-ffile-prefix-map=$root/=")
else
cc_guest=("$zig" cc -target aarch64-linux-musl -mcpu=generic -static -O2 -s "-ffile-prefix-map=$root/=")
fi