forked from Macoron/whisper.unity
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_cpp.sh
80 lines (62 loc) · 1.99 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
#!/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_BUILD_TESTS=OFF -DWHISPER_BUILD_EXAMPLES=OFF \
-DWHISPER_NO_AVX=ON -DWHISPER_NO_AVX2=ON -DWHISPER_NO_FMA=ON -DWHISPER_NO_F16C=ON ../
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_ios() {
clean_build
echo "Starting building for ios..."
cmake -DBUILD_SHARED_LIBS=OFF -DCMAKE_SYSTEM_NAME=iOS \
-DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" \
-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() {
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/libwhisper.a"
cp "$artifact_path" "$target_path"
echo "Build files copied to $target_path"
}
if [ "$targets" = "all" ]; then
build_mac
build_ios
build_android
elif [ "$targets" = "mac" ]; then
build_mac
elif [ "$targets" = "ios" ]; then
build_ios
elif [ "$targets" = "android" ]; then
build_android
else
echo "Unknown targets: $targets"
fi