This repository has been archived by the owner on Aug 17, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 10
299 lines (273 loc) · 13.3 KB
/
build_ncnn.yaml
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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
name: Build ncnn
on:
workflow_dispatch:
env:
NCNN_VERSION: 20220216
DEVELOPER_DIR: /Applications/Xcode_12.4.app/Contents/Developer
jobs:
android:
runs-on: ubuntu-latest
env:
PACKAGENAME: ncnn-android
steps:
- name: Clone ncnn
run: |
git clone https://github.com/Tencent/ncnn.git -b $NCNN_VERSION --depth 1
cd ncnn
git submodule update --init
- name: ndk-fix-debug
run: sed -i -e '/^ -g$/d' $ANDROID_HOME/ndk-bundle/build/cmake/android.toolchain.cmake
- name: build-armv7
run: |
cd ncnn
mkdir build-armv7 && cd build-armv7
cmake -DCMAKE_TOOLCHAIN_FILE=$ANDROID_HOME/ndk-bundle/build/cmake/android.toolchain.cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=install -DNCNN_VERSION_STRING="${{ needs.setup.outputs.VERSION }}" \
-DANDROID_ABI="armeabi-v7a" -DANDROID_ARM_NEON=ON -DANDROID_PLATFORM=android-14 \
-DNCNN_BUILD_BENCHMARK=OFF \
-DNCNN_SIMPLEOCV=ON \
-DNCNN_DISABLE_RTTI=OFF ..
cmake --build . -j 2
cmake --build . --target install
- name: build-aarch64
run: |
cd ncnn
mkdir build-aarch64 && cd build-aarch64
cmake -DCMAKE_TOOLCHAIN_FILE=$ANDROID_HOME/ndk-bundle/build/cmake/android.toolchain.cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=install -DNCNN_VERSION_STRING="${{ needs.setup.outputs.VERSION }}" \
-DANDROID_ABI="arm64-v8a" -DANDROID_PLATFORM=android-21 \
-DNCNN_BUILD_BENCHMARK=OFF \
-DNCNN_SIMPLEOCV=ON \
-DNCNN_DISABLE_RTTI=OFF ..
cmake --build . -j 2
cmake --build . --target install
- name: build-x86
run: |
cd ncnn
mkdir build-x86 && cd build-x86
cmake -DCMAKE_TOOLCHAIN_FILE=$ANDROID_HOME/ndk-bundle/build/cmake/android.toolchain.cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=install -DNCNN_VERSION_STRING="${{ needs.setup.outputs.VERSION }}" \
-DANDROID_ABI="x86" -DANDROID_PLATFORM=android-14 \
-DNCNN_BUILD_BENCHMARK=OFF \
-DNCNN_SIMPLEOCV=ON \
-DNCNN_DISABLE_RTTI=OFF ..
cmake --build . -j 2
cmake --build . --target install
- name: build-x86_64
run: |
cd ncnn
mkdir build-x86_64 && cd build-x86_64
cmake -DCMAKE_TOOLCHAIN_FILE=$ANDROID_HOME/ndk-bundle/build/cmake/android.toolchain.cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=install -DNCNN_VERSION_STRING="${{ needs.setup.outputs.VERSION }}" \
-DANDROID_ABI="x86_64" -DANDROID_PLATFORM=android-21 \
-DNCNN_BUILD_BENCHMARK=OFF \
-DNCNN_SIMPLEOCV=ON \
-DNCNN_DISABLE_RTTI=OFF ..
cmake --build . -j 2
cmake --build . --target install
- name: package
run: |
cd ncnn
rm -rf ${{ env.PACKAGENAME }}
mkdir -p ${{ env.PACKAGENAME }}
mkdir -p ${{ env.PACKAGENAME }}/armeabi-v7a
mkdir -p ${{ env.PACKAGENAME }}/arm64-v8a
mkdir -p ${{ env.PACKAGENAME }}/x86
mkdir -p ${{ env.PACKAGENAME }}/x86_64
cp -r build-armv7/install/* ${{ env.PACKAGENAME }}/armeabi-v7a/
cp -r build-aarch64/install/* ${{ env.PACKAGENAME }}/arm64-v8a/
cp -r build-x86/install/* ${{ env.PACKAGENAME }}/x86/
cp -r build-x86_64/install/* ${{ env.PACKAGENAME }}/x86_64/
rm -f ${{ env.PACKAGENAME }}.zip
zip -9 -r ${{ env.PACKAGENAME }}.zip ${{ env.PACKAGENAME }}
- name: upload-zip
uses: actions/[email protected]
with:
name: ${{ env.PACKAGENAME }}
path: ncnn/${{ env.PACKAGENAME }}
openmp-ios-bitcode:
runs-on: macos-latest
steps:
- name: cache-openmp
id: cache-openmp
uses: actions/[email protected]
with:
path: openmp-install
key: openmp-ios-bitcode-release-11.0.0-e418b04a153cea781c7e92e04b8a111cc8d224a1
- name: Clone ncnn
if: steps.cache-openmp.outputs.cache-hit != 'true'
run: |
git clone https://github.com/Tencent/ncnn.git -b $NCNN_VERSION --depth 1
cd ncnn
git submodule update --init
- name: openmp
if: steps.cache-openmp.outputs.cache-hit != 'true'
run: |
wget https://github.com/llvm/llvm-project/releases/download/llvmorg-11.0.0/openmp-11.0.0.src.tar.xz
tar -xf openmp-11.0.0.src.tar.xz
cd openmp-11.0.0.src
sed -i'' -e '/.size __kmp_unnamed_critical_addr/d' runtime/src/z_Linux_asm.S
sed -i'' -e 's/__kmp_unnamed_critical_addr/___kmp_unnamed_critical_addr/g' runtime/src/z_Linux_asm.S
- name: build
if: steps.cache-openmp.outputs.cache-hit != 'true'
run: |
cd openmp-11.0.0.src
mkdir build && cd build
cmake -DCMAKE_TOOLCHAIN_FILE=../ncnn/toolchains/ios.toolchain.cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=install \
-DIOS_PLATFORM=OS64 -DENABLE_BITCODE=1 -DENABLE_ARC=0 -DENABLE_VISIBILITY=0 -DIOS_ARCH="arm64;arm64e" \
-DPERL_EXECUTABLE=/usr/local/bin/perl \
-DLIBOMP_ENABLE_SHARED=OFF -DLIBOMP_OMPT_SUPPORT=OFF -DLIBOMP_USE_HWLOC=OFF ..
cmake --build . -j 3
cmake --build . --target install
- name: build-simulator
if: steps.cache-openmp.outputs.cache-hit != 'true'
run: |
cd openmp-11.0.0.src
mkdir build-simulator && cd build-simulator
cmake -DCMAKE_TOOLCHAIN_FILE=../ncnn/toolchains/ios.toolchain.cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=install \
-DIOS_PLATFORM=SIMULATOR64 -DENABLE_BITCODE=1 -DENABLE_ARC=0 -DENABLE_VISIBILITY=0 -DIOS_ARCH="x86_64" \
-DPERL_EXECUTABLE=/usr/local/bin/perl \
-DLIBOMP_ENABLE_SHARED=OFF -DLIBOMP_OMPT_SUPPORT=OFF -DLIBOMP_USE_HWLOC=OFF ..
cmake --build . -j 3
cmake --build . --target install
- name: merge-fat-library
if: steps.cache-openmp.outputs.cache-hit != 'true'
run: |
rm -rf $GITHUB_WORKSPACE/openmp-install
mkdir -p $GITHUB_WORKSPACE/openmp-install
cp -r openmp-11.0.0.src/build/install/include $GITHUB_WORKSPACE/openmp-install
mkdir -p $GITHUB_WORKSPACE/openmp-install/lib
lipo -create openmp-11.0.0.src/build/install/lib/libomp.a openmp-11.0.0.src/build-simulator/install/lib/libomp.a -o $GITHUB_WORKSPACE/openmp-install/lib/libomp.a
- name: upload
uses: actions/[email protected]
with:
name: openmp-ios-bitcode
path: openmp-install
ios-bitcode:
needs: [openmp-ios-bitcode]
runs-on: macos-latest
env:
PACKAGENAME: ncnn-ios-bitcode
steps:
- name: Clone ncnn
run: |
git clone https://github.com/Tencent/ncnn.git -b $NCNN_VERSION --depth 1
cd ncnn
git submodule update --init
- name: download-openmp-ios-bitcode
uses: actions/download-artifact@v3
with:
name: openmp-ios-bitcode
path: openmp-ios-bitcode
- name: install-openmp
run: |
sudo cp openmp-ios-bitcode/include/* $DEVELOPER_DIR/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include
sudo cp openmp-ios-bitcode/lib/libomp.a $DEVELOPER_DIR/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/lib
sudo cp openmp-ios-bitcode/include/* $DEVELOPER_DIR/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/include
sudo cp openmp-ios-bitcode/lib/libomp.a $DEVELOPER_DIR/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/lib
- name: build
run: |
cd ncnn
mkdir build && cd build
cmake -DCMAKE_TOOLCHAIN_FILE=../toolchains/ios.toolchain.cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=install -DNCNN_VERSION_STRING="${{ needs.setup.outputs.VERSION }}" \
-DIOS_PLATFORM=OS64 -DENABLE_BITCODE=1 -DENABLE_ARC=0 -DENABLE_VISIBILITY=0 -DIOS_ARCH="arm64;arm64e" \
-DOpenMP_C_FLAGS="-Xclang -fopenmp" -DOpenMP_CXX_FLAGS="-Xclang -fopenmp" \
-DOpenMP_C_LIB_NAMES="libomp" -DOpenMP_CXX_LIB_NAMES="libomp" \
-DOpenMP_libomp_LIBRARY="$DEVELOPER_DIR/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/lib/libomp.a" \
-DNCNN_BUILD_BENCHMARK=OFF \
-DNCNN_SIMPLEOCV=ON \
-DNCNN_DISABLE_RTTI=OFF ..
cmake --build . -j 3
cmake --build . --target install
- name: build-simulator
run: |
cd ncnn
mkdir build-simulator && cd build-simulator
cmake -DCMAKE_TOOLCHAIN_FILE=../toolchains/ios.toolchain.cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=install -DNCNN_VERSION_STRING="${{ needs.setup.outputs.VERSION }}" \
-DIOS_PLATFORM=SIMULATOR64 -DENABLE_BITCODE=1 -DENABLE_ARC=0 -DENABLE_VISIBILITY=0 -DIOS_ARCH="x86_64" \
-DOpenMP_C_FLAGS="-Xclang -fopenmp" -DOpenMP_CXX_FLAGS="-Xclang -fopenmp" \
-DOpenMP_C_LIB_NAMES="libomp" -DOpenMP_CXX_LIB_NAMES="libomp" \
-DOpenMP_libomp_LIBRARY="$DEVELOPER_DIR/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/lib/libomp.a" \
-DNCNN_BUILD_BENCHMARK=OFF \
-DNCNN_SIMPLEOCV=ON \
-DNCNN_DISABLE_RTTI=OFF ..
cmake --build . -j 3
cmake --build . --target install
- name: package-openmp
run: |
cd ncnn
rm -rf openmp.framework
mkdir -p openmp.framework/Versions/A/Headers
mkdir -p openmp.framework/Versions/A/Resources
ln -s A openmp.framework/Versions/Current
ln -s Versions/Current/Headers openmp.framework/Headers
ln -s Versions/Current/Resources openmp.framework/Resources
ln -s Versions/Current/openmp openmp.framework/openmp
cp ../openmp-ios-bitcode/lib/libomp.a openmp.framework/Versions/A/openmp
cp -r ../openmp-ios-bitcode/include/* openmp.framework/Versions/A/Headers/
sed -e 's/__NAME__/openmp/g' -e 's/__IDENTIFIER__/org.llvm.openmp/g' -e 's/__VERSION__/11.0/g' Info.plist > openmp.framework/Versions/A/Resources/Info.plist
- name: package
run: |
cd ncnn
rm -rf ncnn.framework
mkdir -p ncnn.framework/Versions/A/Headers
mkdir -p ncnn.framework/Versions/A/Resources
ln -s A ncnn.framework/Versions/Current
ln -s Versions/Current/Headers ncnn.framework/Headers
ln -s Versions/Current/Resources ncnn.framework/Resources
ln -s Versions/Current/ncnn ncnn.framework/ncnn
lipo -create build/install/lib/libncnn.a build-simulator/install/lib/libncnn.a -o ncnn.framework/Versions/A/ncnn
cp -r build/install/include/* ncnn.framework/Versions/A/Headers/
sed -e 's/__NAME__/ncnn/g' -e 's/__IDENTIFIER__/com.tencent.ncnn/g' -e 's/__VERSION__/1.0/g' Info.plist > ncnn.framework/Versions/A/Resources/Info.plist
rm -f ${{ env.PACKAGENAME }}.zip
zip -9 -y -r ${{ env.PACKAGENAME }}.zip openmp.framework ncnn.framework
- name: upload-zip
uses: actions/[email protected]
with:
name: ${{ env.PACKAGENAME }}
path: ncnn/${{ env.PACKAGENAME }}.zip
- name: split fat-framework
run: |
cd ncnn
rm -rf ncnn
rm -rf ncnn.xcframework
mkdir ncnn
mkdir ncnn/ios
cp -R ncnn.framework/ ncnn/ios/ncnn.framework
lipo \
-extract "arm64" \
-extract "arm64e" \
ncnn/ios/ncnn.framework/Versions/A/ncnn \
-o ncnn/ios/ncnn.framework/Versions/A/ncnn
mkdir ncnn/simulator
cp -R ncnn.framework/ ncnn/simulator/ncnn.framework
lipo \
-extract "x86_64" \
ncnn/simulator/ncnn.framework/Versions/A/ncnn \
-o ncnn/simulator/ncnn.framework/Versions/A/ncnn
xcodebuild -create-xcframework \
-framework ncnn/ios/ncnn.framework \
-framework ncnn/simulator/ncnn.framework \
-output "ncnn.xcframework"
rm -rf openmp
rm -rf openmp.xcframework
mkdir openmp
mkdir openmp/ios
cp -R openmp.framework/ openmp/ios/openmp.framework
lipo \
-extract "arm64" \
-extract "arm64e" \
openmp/ios/openmp.framework/Versions/A/openmp \
-o openmp/ios/openmp.framework/Versions/A/openmp
mkdir openmp/simulator
cp -R openmp.framework/ openmp/simulator/openmp.framework
lipo \
-extract "x86_64" \
openmp/simulator/openmp.framework/Versions/A/openmp \
-o openmp/simulator/openmp.framework/Versions/A/openmp
xcodebuild -create-xcframework \
-framework openmp/ios/openmp.framework \
-framework openmp/simulator/openmp.framework \
-output "openmp.xcframework"
zip -9 -y -r ${{ env.PACKAGENAME }}_xcframework.zip openmp.xcframework ncnn.xcframework
- name: upload-zip
uses: actions/[email protected]
with:
name: ${{ env.PACKAGENAME }}_xcframework
path: ncnn/${{ env.PACKAGENAME }}_xcframework.zip