-
Notifications
You must be signed in to change notification settings - Fork 4
/
build.sh
executable file
·76 lines (63 loc) · 1.74 KB
/
build.sh
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
69
70
71
72
73
74
75
76
#!/bin/bash
if [ "x$1" == "x" ]; then
echo "Missing node version"
exit 1
fi
ndkver=
if [ "x$2" == "x" ]; then
ndkver="23.0.7599858"
else
ndkver="$2"
fi
arch=
if [ "x$3" == "x" ]; then
arch="arm64"
else
arch="$3"
fi
sdkver=
if [ "x$4" == "x" ]; then
sdkver="23"
else
sdkver="$4"
fi
nodever="$1"
tarfile="v$nodever.zip"
if [ ! -f "$tarfile" ]; then
curl -OL "https://github.com/nodejs/node/archive/refs/tags/$tarfile"
# curl -OL "https://hub.fastgit.org/nodejs/node/archive/refs/tags/$tarfile"
fi
unzip -d . "$tarfile" >/dev/null
dir="node-$nodever"
cd "$dir"
patch -p0 < ../android-configure.patch
chmod +x ./android-configure
cat ./android-configure
./android-configure "$ANDROID_HOME/ndk/$ndkver" "$arch" "$sdkver"
make
outdir="build"
mkdir -p "../$outdir/lib"
HEADERS_ONLY=1 python3 ./tools/install.py install "../$outdir" /
cp -rpf "./out/Release/libnode.so" "../$outdir/lib/libnode.so"
cd ..
zipname="build-$nodever.zip"
rm -rf "$zipname"
type zip >/dev/null 2>&1
if [ "x$?" == "x0" ]; then
cd "$outdir"
zip -r -y "../$zipname" .
cd ..
else
powershell.exe -nologo -noprofile -command \
'& { param([String]$sourceDirectoryName, [String]$destinationArchiveFileName, [Boolean]$includeBaseDirectory); Add-Type -A "System.IO.Compression.FileSystem"; Add-Type -A "System.Text.Encoding"; [IO.Compression.ZipFile]::CreateFromDirectory($sourceDirectoryName, $destinationArchiveFileName, [IO.Compression.CompressionLevel]::Fastest, $includeBaseDirectory, [System.Text.Encoding]::UTF8); exit !$?;}' \
-sourceDirectoryName "\"$outdir\"" \
-destinationArchiveFileName "$zipname" \
-includeBaseDirectory '$false'
if [ $? -ne 0 ]; then
echo "Zip failed"
exit $?
fi
fi
# rm -rf "$outdir"
# rm -rf "$dir"
# # rm -rf "$tarfile"