runtime/example/build.sh

44 lines
732 B
Bash
Raw Normal View History

2025-01-04 05:34:24 -05:00
#!/bin/sh
set -e
2025-02-15 00:03:19 -05:00
cd "$(dirname "$0")"
2025-01-04 05:34:24 -05:00
# Run Script
RUN="$(pwd)/run.sh"
rm -f "${RUN}"
out() {
echo "$1" >> "${RUN}"
}
out '#!/bin/sh'
out 'set -e'
2025-02-15 00:03:19 -05:00
out 'cd "$(dirname "$0")"'
2025-01-04 05:34:24 -05:00
chmod +x "${RUN}"
# Create Build Directory
dir() {
2025-02-14 23:10:29 -05:00
mkdir -p "$1"
2025-01-04 05:34:24 -05:00
cd "$1"
}
dir build
# Build Host Component
build_example_part() {
dir "$1"
2025-02-14 23:10:29 -05:00
cmake -GNinja "../../$1"
cmake --build .
2025-01-04 05:34:24 -05:00
}
build_example_part host
out "export LD_LIBRARY_PATH=\"$(pwd):\${LD_LIBRARY_PATH}\""
2025-02-14 23:10:29 -05:00
out "export PATH=\"$(pwd)/runtime:\${PATH}\""
2025-01-04 05:34:24 -05:00
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'