-
Notifications
You must be signed in to change notification settings - Fork 16
/
build.sh
executable file
·112 lines (88 loc) · 3.22 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/usr/bin/env bash
#############################
######### Variables #########
#############################
# Edit this variable to change the build options for secp256k1
SECP256K1_BUILD_OPTS="--enable-module-recovery"
#############################
####### End Variables #######
#############################
# Initialize external vars - need this to get around unbound variable errors
SKIP_GRADLE="$SKIP_GRADLE"
# Exit script if you try to use an uninitialized variable.
set -o nounset
# Exit script if a statement returns a non-true return value.
set -o errexit
# Use the error status of the first failure, rather than that of the last item in a pipeline.
set -o pipefail
# Resolve the directory that contains this script. We have to jump through a few
# hoops for this because the usual one-liners for this don't work if the script
# is a symlink
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
SCRIPTDIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"
# Determine core count for parallel make
if [[ "$OSTYPE" == "linux-gnu" ]]; then
CORE_COUNT=$(nproc)
OSARCH=${OSTYPE%%[0-9.]*}-`arch`
fi
if [[ "$OSTYPE" == "darwin"* ]]; then
CORE_COUNT=$(sysctl -n hw.ncpu)
if [[ "`machine`" == "arm"* ]]; then
arch_name="aarch64"
export CFLAGS="-arch arm64"
else
arch_name="x86-64"
export CFLAGS="-arch x86_64"
fi
OSARCH="darwin-$arch_name"
fi
# add to path cargo
[ -f $HOME/.cargo/env ] && . $HOME/.cargo/env
# add to path brew
[ -f $HOME/.zprofile ] && . $HOME/.zprofile
build_ipa_multipoint() {
cat <<EOF
##################################
###### build ipa_multipoint ######
##################################
EOF
cd "$SCRIPTDIR/ipa-multipoint/ipa_multipoint_jni"
# delete old build dir, if exists
rm -rf "$SCRIPTDIR/ipa-multipoint/build" || true
mkdir -p "$SCRIPTDIR/ipa-multipoint/build/${OSARCH}/lib"
cargo clean
if [[ "$OSARCH" == "darwin-x86-64" ]]; then
cargo build --lib --release --target=x86_64-apple-darwin
lipo -create \
-output target/release/libipa_multipoint_jni.dylib \
-arch x86_64 target/x86_64-apple-darwin/release/libipa_multipoint_jni.dylib
lipo -info ./target/release/libipa_multipoint_jni.dylib
elif [[ "$OSARCH" == "darwin-aarch64" ]]; then
cargo build --lib --release --target=aarch64-apple-darwin
lipo -create \
-output target/release/libipa_multipoint_jni.dylib \
-arch arm64 target/aarch64-apple-darwin/release/libipa_multipoint_jni.dylib
lipo -info ./target/release/libipa_multipoint_jni.dylib
else
cargo build --lib --release
fi
mkdir -p "$SCRIPTDIR/ipa-multipoint/build/${OSARCH}/lib"
cp target/release/libipa_multipoint_jni.* "$SCRIPTDIR/ipa-multipoint/build/${OSARCH}/lib"
}
build_jars(){
########################
###### build jars ######
########################
if [[ "$SKIP_GRADLE" != "true" ]]; then
cd $SCRIPTDIR
./gradlew build
fi
}
build_ipa_multipoint
build_jars
exit