-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfetch-libnode.sh
More file actions
executable file
·68 lines (58 loc) · 2.01 KB
/
fetch-libnode.sh
File metadata and controls
executable file
·68 lines (58 loc) · 2.01 KB
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
61
62
63
64
65
66
67
68
#!/usr/bin/env bash
#
# fetch-libnode.sh — vendor libnode.so + headers from nodejs-mobile releases
#
# Downloads the prebuilt Android binaries from
# https://github.com/nodejs-mobile/nodejs-mobile/releases and unpacks them
# into app/libnode/. Both bin/<abi>/libnode.so and include/ are referenced
# by app/src/main/cpp/CMakeLists.txt; gradle's externalNativeBuild reads them
# from there.
#
# Usage:
# ./scripts/fetch-libnode.sh # latest release
# ./scripts/fetch-libnode.sh v18.20.4 # pinned version
#
# The libnode/ directory is gitignored; CI and dev boxes run this once per
# version pin. ABI filter (arm64-v8a, armeabi-v7a) is applied at the gradle
# layer; this script unpacks all four ABIs from the upstream zip.
set -euo pipefail
REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
DEST="$REPO_ROOT/app/libnode"
VERSION="${1:-v18.20.4}"
RELEASE_URL="https://github.com/nodejs-mobile/nodejs-mobile/releases/download/$VERSION/nodejs-mobile-${VERSION}-android.zip"
TMPDIR="$(mktemp -d)"
trap 'rm -rf "$TMPDIR"' EXIT
echo "==> Downloading $VERSION from $RELEASE_URL"
curl -fL --progress-bar "$RELEASE_URL" -o "$TMPDIR/libnode.zip"
echo "==> Unpacking to $DEST"
mkdir -p "$DEST"
rm -rf "${DEST:?}"/*
unzip -q "$TMPDIR/libnode.zip" -d "$DEST"
# The release ships a top-level dir; flatten it so app/libnode/{bin,include}
# matches the CMakeLists path expectation.
shopt -s dotglob nullglob
for inner in "$DEST"/nodejs-mobile-*; do
if [ -d "$inner" ]; then
mv "$inner"/* "$DEST/"
rmdir "$inner"
fi
done
# Sanity: at least the arm64-v8a and armeabi-v7a libnode.so should exist
for abi in arm64-v8a armeabi-v7a; do
so="$DEST/bin/$abi/libnode.so"
if [ ! -f "$so" ]; then
echo "ERROR: missing $so after unpack" >&2
exit 1
fi
size=$(stat -c%s "$so")
printf " %-15s %s (%d bytes)\n" "$abi" "$so" "$size"
done
cat > "$DEST/.libnode-info" <<EOF
nodejs-mobile $VERSION
fetched at $(date -u +%Y-%m-%dT%H:%M:%SZ)
source: $RELEASE_URL
EOF
echo
echo "Done."
echo " Version: $VERSION"
echo " Path: $DEST"