forked from jmpews/Dobby
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathauto-build.sh
executable file
·94 lines (65 loc) · 3.7 KB
/
auto-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
#!/bin/sh
# if error, exit
set -
CURRENT_DIR=$(dirname "$0")
compress_dir_array=""
summary_output_dir_name=auto-build-output
rm -rf ${summary_output_dir_name}
# Darwin ================================================================
darwin_library_name=libdobby.a
darwin_fat_library_name=libdobby.a
# build macos x86_64
output_dir_name=auto-build-workspace//darwin-x64-build
echo "prepare build ${output_dir_name}"
mkdir -p ${CURRENT_DIR}/${output_dir_name}
cmake -S . -B ${output_dir_name} -DCMAKE_BUILD_TYPE=Release \
-DDOBBY_GENERATE_SHARED=OFF -DDarwin.GenerateFramework=OFF -DDOBBY_DEBUG=OFF
cmake --build ${output_dir_name} --parallel 4 --target dobby
mkdir -p ${summary_output_dir_name}/darwin/x86_64
cp -r ${output_dir_name}/${darwin_library_name} ${summary_output_dir_name}/darwin/x86_64
# build iphone aarch64
output_dir_name=auto-build-workspace//darwin-arm64-build
compress_dir_array="$compress_dir_array $output_dir_name"
echo "prepare build ${output_dir_name}"
mkdir -p ${CURRENT_DIR}/${output_dir_name}
cmake -S . -B ${output_dir_name} -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_TOOLCHAIN_FILE=cmake/ios.toolchain.cmake \
-DPLATFORM=OS64 -DARCHS="arm64" -DCMAKE_SYSTEM_PROCESSOR=arm64 \
-DENABLE_BITCODE=0 -DENABLE_ARC=0 -DENABLE_VISIBILITY=1 -DDEPLOYMENT_TARGET=9.3 \
-DDOBBY_GENERATE_SHARED=OFF -DDarwin.GenerateFramework=OFF -DDOBBY_DEBUG=OFF
cmake --build ${output_dir_name} --parallel 4 --target dobby
mkdir -p ${summary_output_dir_name}/darwin/arm64
cp -r ${output_dir_name}/${darwin_library_name} ${summary_output_dir_name}/darwin/arm64
# build darwin universal
output_dir_name=auto-build-workspace//darwin-universal-build
echo "prepare build ${output_dir_name}"
mkdir -p ${CURRENT_DIR}/${output_dir_name}
cp -r ${summary_output_dir_name}/darwin/arm64/${darwin_library_name} ${output_dir_name}
lipo -create ${summary_output_dir_name}/darwin/arm64/${darwin_fat_library_name} ${summary_output_dir_name}/darwin/x86_64/${darwin_fat_library_name} -output ${output_dir_name}/${darwin_fat_library_name}
mkdir -p ${summary_output_dir_name}/darwin/universal
cp -r ${output_dir_name}/${darwin_library_name} ${summary_output_dir_name}/darwin/universal
# Android ================================================================
android_library_name=libdobby.a
# build android aarch64
output_dir_name=auto-build-workspace//android-arm64-build
compress_dir_array="$compress_dir_array $output_dir_name"
echo "prepare build ${output_dir_name}"
cmake -S . -B ${output_dir_name} -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_SYSTEM_NAME=Android -DCMAKE_ANDROID_ARCH_ABI="arm64-v8a" -DCMAKE_ANDROID_NDK=$ANDROID_NDK_DIR -DCMAKE_SYSTEM_VERSION=21 -DCMAKE_ANDROID_NDK_TOOLCHAIN_VERSION=clang \
-DDOBBY_GENERATE_SHARED=OFF -DDOBBY_DEBUG=OFF
cmake --build ${output_dir_name} --parallel 4 --target dobby
mkdir -p ${summary_output_dir_name}/android/arm64
mv ${output_dir_name}/${android_library_name} ${summary_output_dir_name}/android/arm64/${android_library_name}
# build android armv7
output_dir_name=auto-build-workspace//android-armv7-build
compress_dir_array="$compress_dir_array $output_dir_name"
echo "prepare build ${output_dir_name}"
cmake -S . -B ${output_dir_name} -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_SYSTEM_NAME=Android -DCMAKE_ANDROID_ARCH_ABI="armeabi-v7a" -DCMAKE_ANDROID_NDK=$ANDROID_NDK_DIR -DCMAKE_SYSTEM_VERSION=16 -DCMAKE_ANDROID_NDK_TOOLCHAIN_VERSION=clang \
-DDOBBY_GENERATE_SHARED=OFF -DDOBBY_DEBUG=OFF
cmake --build ${output_dir_name} --parallel 4 --target dobby
mkdir -p ${summary_output_dir_name}/android/armv7
mv ${output_dir_name}/${android_library_name} ${summary_output_dir_name}/android/armv7/${android_library_name}
if [ $DOBBY_BUILD_OUTPUT_NAME ]; then
tar czvf ${DOBBY_BUILD_OUTPUT_NAME} ${summary_output_dir_name}
fi