-
Notifications
You must be signed in to change notification settings - Fork 4
/
build.sh
executable file
·136 lines (123 loc) · 3.32 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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#!/bin/bash
# Fail on any error
set -e
ios_archs=("arm64-ios" "arm64-ios-simulator" "x64-ios-simulator")
android_archs=("arm64-v8a" "armeabi-v7a" "x86_64" "x86")
build_ios() {
local arch=$1
if [ -z "$arch" ]; then
echo "Building for all iOS architectures..."
for arch in "${ios_archs[@]}"; do
echo "Building for iOS architecture: $arch"
./scripts/build_apple.sh "$arch"
done
else
echo "Building for iOS architecture: $arch"
./scripts/build_apple.sh "$arch"
fi
}
build_android() {
local arch=$1
if [ -z "$arch" ]; then
echo "Building for all Android architectures..."
for arch in "${android_archs[@]}"; do
echo "Building for Android architecture: $arch"
./scripts/build_android.sh "$arch"
done
else
echo "Building for Android architecture: $arch"
./scripts/build_android.sh "$arch"
fi
}
move_android_so() {
local arch=$1
if [ -z "$arch" ]; then
echo "Moving .so files for all Android architectures..."
for a in "${android_archs[@]}"; do
./scripts/move_android_so.sh "$a"
done
else
echo "Moving .so files for Android architecture: $arch"
./scripts/move_android_so.sh "$arch"
fi
}
if [ -d "$(pwd)/vcpkg" ]; then
export VCPKG_ROOT="$(pwd)/vcpkg"
else
# If VCPKG_ROOT is not set and vcpkg directory doesn't exist locally
if [ -z "${VCPKG_ROOT+x}" ]; then
echo "VCPKG_ROOT is not set and vcpkg directory not found in the current working directory."
echo "Review setup in README.md or export a custom $VCPKG_ROOT."
exit 1
fi
fi
platform=""
arch=""
clean=false
while [[ $# -gt 0 ]]; do
case $1 in
ios|android|all)
platform=$1
;;
--ios)
platform="ios"
arch=$2
shift
;;
--android)
platform="android"
arch=$2
shift
;;
clean)
clean=true
;;
*)
echo "Unknown option: $1"
exit 1
;;
esac
shift
done
# if the first argument is clean, then clean the build directory
if [ "$2" == "clean" ]; then
if [ "$1" == "ios" ]; then
echo "Cleaning the iOS build directory..."
rm -rf build/apple
elif [ "$1" == "android" ]; then
echo "Cleaning the Android build directory..."
rm -rf build/android
else
echo "Cleaning the build directory..."
rm -rf build
fi
fi
# Handle cleaning
if $clean_all; then
echo "Cleaning all build directories..."
rm -rf build
elif $clean; then
if [ "$platform" == "ios" ]; then
echo "Cleaning the iOS build directory..."
rm -rf build/apple
elif [ "$platform" == "android" ]; then
echo "Cleaning the Android build directory..."
rm -rf build/android
else
echo "Cleaning the build directory..."
rm -rf build
fi
fi
# Build based on platform
if [ "$platform" == "ios" ] || [ "$platform" == "all" ]; then
build_ios "$arch"
if [ -z "$arch" ]; then
echo "Creating xcframework..."
./scripts/create_xcframework.sh
fi
fi
if [ "$platform" == "android" ] || [ "$platform" == "all" ]; then
build_android "$arch"
move_android_so "$arch"
fi
echo "Done!"