42 lines
1.8 KiB
Bash
Executable File
42 lines
1.8 KiB
Bash
Executable File
#!/bin/sh
|
|
set -eu
|
|
ziran=${1:?pass the ziran command}
|
|
# Like the other Android cross-links, this runs where an NDK is installed.
|
|
ndk=${ZIRAN_THREAD_ANDROID_NDK:-${ANDROID_NDK_HOME:-}}
|
|
if test -z "$ndk"; then
|
|
echo 'Android thread cross-links skipped: set ANDROID_NDK_HOME or ZIRAN_THREAD_ANDROID_NDK'
|
|
exit 0
|
|
fi
|
|
work=${ZIRAN_THREAD_ANDROID_BUILD:-"$(pwd)/build/thread-android"}
|
|
mkdir -p "$work"
|
|
exec 9>"$work/check.lock"
|
|
flock -n 9 || { echo 'Android thread cross-links are already running' >&2; exit 1; }
|
|
unset DISPLAY WAYLAND_DISPLAY XAUTHORITY DBUS_SESSION_BUS_ADDRESS LD_PRELOAD
|
|
export YUE_DESKTOP_RECOVERY=0
|
|
bin="$ndk/toolchains/llvm/prebuilt/linux-x86_64/bin"
|
|
for target in arm64:aarch64-linux-android24 none:armv7a-linux-androideabi24; do
|
|
cpu=${target%%:*}
|
|
triple=${target#*:}
|
|
ir="$work/$cpu/ir"
|
|
"$ziran" ir --target=c --target-os android --target-cpu "$cpu" \
|
|
--root tests/spec --module-path std -o "$ir" tests/spec/thread_linux_test.zi
|
|
for form in source saved; do
|
|
entry=tests/spec/thread_linux_test.zi
|
|
root=tests/spec
|
|
modules=std
|
|
if test "$form" = saved; then
|
|
entry="$ir/thread_linux_test.zir"
|
|
root="$ir"
|
|
modules="$ir"
|
|
fi
|
|
output="$work/$cpu/$form-c"
|
|
"$ziran" build --target=c --target-os android --target-cpu "$cpu" --no-main \
|
|
--root "$root" --module-path "$modules" -o "$output" "$entry"
|
|
"$bin/clang" --target="$triple" -std=c11 -fPIC -shared -Iinclude -I"$output" \
|
|
tests/thread_completion_test.c "$output"/*.c -pthread \
|
|
-Wl,--wrap=pthread_join -Wl,--wrap=pthread_mutex_lock -Wl,--no-undefined \
|
|
-o "$output/$triple.so"
|
|
echo "PASS: OS=.ANDROID CPU=.$cpu $form c $triple thread cross-link"
|
|
done
|
|
done
|