nandi/jolt-nativepublic Fork 0
384390d0e216cb6f0e9be8e597b9d16e7a64bb29
Commits
Clone
git clone https://git.rickub.com/nandi/jolt-native.git
git clone ssh://git@rickub.com/nandi/jolt-native.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

Let the media plane cross to the phone, camera and all fd0e21a · on 384390d0e216cb6f0e9be8e597b9d16e7a64bb29 · nandi · 18d ago
ndk.sh · 60 lines · 2.9 KBBash Blame HistoryRaw
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/sh
# The NDK, as the C toolchain for Android, fetched where the action runs.
#
# Unlike zcc.sh, the archive behind this is not an input. That is deliberate:
# unpacked it is three gigabytes, and an input has to travel to a worker
# through the CAS — uploaded from here first, then materialised there. What
# travels instead is DotSlash (under a megabyte) and the manifest naming the
# archive, and the worker fetches the same bytes under the same digest from
# Google. A machine that has already fetched it does nothing.
#
# The cost of that is honest to state: what the compiler *is* stops being part
# of the action's cache digest. The manifest is an input, so a version bump
# still invalidates; a machine whose DotSlash cache holds something else under
# that digest cannot happen, because the digest is what the cache is keyed on.
#
# $1 is the directory holding the DotSlash binary, $2 the manifest to resolve
# and $3 the mode — cc, c++, ar, ranlib or objcopy. buck passes all three.
set -e
dotslash=$1/dotslash
manifest=$2
mode=$3
shift 3

# ANDROID_NDK_HOME still wins, for a machine that has one installed.
ndk=${ANDROID_NDK_HOME:-${ANDROID_NDK_ROOT:-}}
if [ -n "$ndk" ]; then
    for host in linux-x86_64 darwin-x86_64; do
        if [ -d "$ndk/toolchains/llvm/prebuilt/$host/bin" ]; then
            bin=$ndk/toolchains/llvm/prebuilt/$host/bin
            break
        fi
    done
    [ -n "${bin:-}" ] || { echo "toolchains/ndk.sh: no llvm prebuilt under $ndk" >&2; exit 1; }
else
    # The manifest names bin/clang inside the archive; DotSlash unpacks the
    # whole NDK around it, which is what the driver needs — its sysroot and its
    # resource directory are found relative to the binary.
    bin=$(dirname "$("$dotslash" -- fetch "$manifest")")
fi

# API 28 is frq's min_sdk_version, and the floor for what the app needs from
# bionic. The NDK ships a wrapper script per API level that adds this flag and
# nothing else; passing it here keeps this to one executable out of the
# archive, so nothing depends on which permissions survived the unpacking.
target=${JOLT_ANDROID_TARGET:-aarch64-linux-android}${JOLT_ANDROID_API:-28}

# The target goes *after* the caller's arguments, because clang takes the last
# --target it is given and cc-rs passes one of its own. Its version carries no
# API level, so putting ours first silently dropped the app back to the NDK's
# default minimum — where bionic has no `getentropy`, and aws-lc-sys fails to
# compile against a header that does not declare it. The API level is not a
# default to be overridden; it is the floor the app is built for.
case $mode in
    cc) exec "$bin/clang" "$@" --target="$target" ;;
    c++) exec "$bin/clang++" "$@" --target="$target" ;;
    ar) exec "$bin/llvm-ar" "$@" ;;
    ranlib) exec "$bin/llvm-ranlib" "$@" ;;
    objcopy) exec "$bin/llvm-objcopy" "$@" ;;
    *) echo "toolchains/ndk.sh: unknown mode $mode" >&2; exit 1 ;;
esac