-
Notifications
You must be signed in to change notification settings - Fork 19
/
build.sh
executable file
·51 lines (41 loc) · 1.07 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
#!/bin/bash
set -e
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
pushd "$HERE" &> /dev/null
if [[ -z "$1" ]] ; then
echo "Usage: build.sh x86|x64|arm64 [github-token]"
exit 1
fi
rm -rf lib/build lib/install
mkdir -p lib/build
cd lib/build
if [[ `uname -s` == "MINGW"* ]] ; then
if [[ "$1" == "x86" ]] ; then
cmake -A Win32 ..
elif [[ "$1" == "x64" ]] ; then
cmake -A x64 ..
fi
elif [[ `uname -s` == "Darwin" ]] ; then
if [[ "$1" == "x64" ]] ; then
cmake -DCMAKE_OSX_ARCHITECTURES=x86_64 ..
elif [[ "$1" == "arm64" ]] ; then
cmake -DCMAKE_OSX_ARCHITECTURES=arm64 ..
fi
else
cmake ..
fi
cmake --build . --config Release
cmake --install . --prefix ../install
cd ../..
rm -rf prebuilds
node_arch="$1"
if [[ "$1" == "x86" ]] ; then
node_arch="ia32"
fi
eval "npm_config_arch=$node_arch ./node_modules/.bin/node-gyp rebuild"
prebuild_command="./node_modules/.bin/prebuild -r napi --include-regex '.(node|a|dylib|dll|so.*)$' --arch=$node_arch"
if [[ -n "$2" ]] ; then
prebuild_command+=" --upload $2"
fi
eval $prebuild_command
popd &> /dev/null