forked from Macoron/whisper.unity
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_cpp.sh
185 lines (141 loc) · 5.08 KB
/
build_cpp.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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
#!/bin/bash
whisper_path="$1"
targets=${2:-all}
android_sdk_path="$3"
unity_project="$PWD"
build_path="$1/build"
clean_build(){
rm -rf "$build_path"
mkdir "$build_path"
cd "$build_path"
}
build_mac() {
clean_build
echo "Starting building for Mac..."
cmake -DCMAKE_OSX_ARCHITECTURES="x86_64;arm64" -DWHISPER_METAL=OFF \
-DWHISPER_NO_AVX=ON -DWHISPER_NO_AVX2=ON -DWHISPER_NO_FMA=ON -DWHISPER_NO_F16C=ON \
-DWHISPER_BUILD_TESTS=OFF -DWHISPER_BUILD_EXAMPLES=OFF ../
make
echo "Build for Mac complete!"
artifact_path="$build_path/libwhisper.dylib"
target_path="$unity_project/Packages/com.whisper.unity/Plugins/MacOS/libwhisper.dylib"
cp "$artifact_path" "$target_path"
echo "Build files copied to $target_path"
}
build_mac_metal() {
clean_build
echo "Starting building for Mac (Metal)..."
cmake -DCMAKE_OSX_ARCHITECTURES="x86_64;arm64" -DWHISPER_METAL=ON \
-DWHISPER_NO_AVX=ON -DWHISPER_NO_AVX2=ON -DWHISPER_NO_FMA=ON -DWHISPER_NO_F16C=ON \
-DWHISPER_BUILD_TESTS=OFF -DWHISPER_BUILD_EXAMPLES=OFF ../
make
echo "Build for Mac (Metal) complete!"
artifact_path="$build_path/libwhisper.dylib"
target_path="$unity_project/Packages/com.whisper.unity/Plugins/MacOS/libwhisper_metal.dylib"
cp "$artifact_path" "$target_path"
artifact_path="$build_path/bin/ggml-metal.metal"
target_path="$unity_project/Packages/com.whisper.unity/Plugins/MacOS/ggml-metal.metal"
cp "$artifact_path" "$target_path"
echo "Build files copied to $target_path"
}
build_ios() {
clean_build
echo "Starting building for ios..."
cmake -DBUILD_SHARED_LIBS=OFF -DCMAKE_SYSTEM_NAME=iOS \
-DCMAKE_OSX_ARCHITECTURES="x86_64;arm64" -DWHISPER_METAL=OFF \
-DCMAKE_SYSTEM_PROCESSOR=arm64 -DCMAKE_IOS_INSTALL_COMBINED=YES \
-DWHISPER_BUILD_TESTS=OFF -DWHISPER_BUILD_EXAMPLES=OFF ../
make
echo "Build for ios complete!"
artifact_path="$build_path/libwhisper.a"
target_path="$unity_project/Packages/com.whisper.unity/Plugins/iOS/libwhisper.a"
cp "$artifact_path" "$target_path"
echo "Build files copied to $target_path"
}
build_android_arm64() {
clean_build
echo "Starting building for Android..."
cmake -DCMAKE_TOOLCHAIN_FILE="$android_sdk_path" -DANDROID_ABI=arm64-v8a -DBUILD_SHARED_LIBS=OFF \
-DWHISPER_BUILD_TESTS=OFF -DWHISPER_BUILD_EXAMPLES=OFF ../
make
echo "Build for Android complete!"
artifact_path="$build_path/libwhisper.a"
target_path="$unity_project/Packages/com.whisper.unity/Plugins/Android/arm64/libwhisper.a"
cp "$artifact_path" "$target_path"
echo "Build files copied to $target_path"
}
build_android_armv7() {
clean_build
echo "Starting building for Android..."
cmake -DCMAKE_TOOLCHAIN_FILE="$android_sdk_path" -DANDROID_ABI=armeabi-v7a -DBUILD_SHARED_LIBS=OFF \
-DWHISPER_BUILD_TESTS=OFF -DWHISPER_BUILD_EXAMPLES=OFF ../
make
echo "Build for Android complete!"
artifact_path="$build_path/libwhisper.a"
target_path="$unity_project/Packages/com.whisper.unity/Plugins/Android/armv7/libwhisper.a"
cp "$artifact_path" "$target_path"
echo "Build files copied to $target_path"
}
build_android_x86() {
clean_build
echo "Starting building for Android..."
cmake -DCMAKE_TOOLCHAIN_FILE="$android_sdk_path" -DANDROID_ABI=x86 -DBUILD_SHARED_LIBS=OFF \
-DWHISPER_BUILD_TESTS=OFF -DWHISPER_BUILD_EXAMPLES=OFF ../
make
echo "Build for Android complete!"
artifact_path="$build_path/libwhisper.a"
target_path="$unity_project/Packages/com.whisper.unity/Plugins/Android/x86/libwhisper.a"
cp "$artifact_path" "$target_path"
echo "Build files copied to $target_path"
}
build_android_x86_64() {
clean_build
echo "Starting building for Android..."
cmake -DCMAKE_TOOLCHAIN_FILE="$android_sdk_path" -DANDROID_ABI=x86_64 -DBUILD_SHARED_LIBS=OFF \
-DWHISPER_BUILD_TESTS=OFF -DWHISPER_BUILD_EXAMPLES=OFF ../
make
echo "Build for Android complete!"
artifact_path="$build_path/libwhisper.a"
target_path="$unity_project/Packages/com.whisper.unity/Plugins/Android/x86_64/libwhisper.a"
cp "$artifact_path" "$target_path"
echo "Build files copied to $target_path"
}
build_webgl() {
clean_build
echo "Starting building for WebGL..."
emcmake cmake ..
cmake -DCMAKE_BUILD_TYPE=Release \
-DWHISPER_BUILD_TESTS=OFF -DWHISPER_BUILD_EXAMPLES=OFF ../
make
echo "Build for WebGL complete!"
artifact_path="$build_path/libwhisper.a"
target_path="$unity_project/Packages/com.whisper.unity/Plugins/webGL/libwhisper.a"
cp "$artifact_path" "$target_path"
echo "Build files copied to $target_path"
}
if [ "$targets" = "all" ]; then
build_mac
build_ios
build_android_arm64
build_android_armv7
build_android_x86
build_android_x86_64
elif [ "$targets" = "mac" ]; then
build_mac
elif [ "$targets" = "mac_metal" ]; then
build_mac_metal
elif [ "$targets" = "ios" ]; then
build_ios
elif [ "$targets" = "android-arm64" ]; then
build_android_arm64
elif [ "$targets" = "android-armv7" ]; then
build_android_armv7
elif [ "$targets" = "android-x86" ]; then
build_android_x86
elif [ "$targets" = "android-x86_64" ]; then
build_android_x86_64
elif [ "$targets" = "webgl" ]; then
build_webgl
else
echo "Unknown targets: $targets"
fi