runtime/example/build.sh
2025-01-04 05:34:24 -05:00

51 lines
759 B
Bash
Executable File

#!/bin/sh
set -e
# Run Script
RUN="$(pwd)/run.sh"
rm -f "${RUN}"
out() {
echo "$1" >> "${RUN}"
}
out '#!/bin/sh'
out 'set -e'
chmod +x "${RUN}"
# Create Build Directory
rm -rf build
dir() {
mkdir "$1"
cd "$1"
}
dir build
# Build Runtime
dir runtime
build() {
cmake -GNinja "../../$1"
cmake --build .
}
build ../
out "export PATH=\"$(pwd):\${PATH}\""
cd ../
# Build Host Component
build_example_part() {
dir "$1"
build "$1"
}
build_example_part host
out "export LD_LIBRARY_PATH=\"$(pwd):\${LD_LIBRARY_PATH}\""
cd ../
# Build Guest Component
build_example_part guest
# Finalize Script
out "export QEMU_LD_PREFIX=/usr/arm-linux-gnueabihf"
out "exec runtime \"$(pwd)/example\""
# Done
echo 'BUILD COMPLETE!'
echo 'See ./run.sh'