forked from VOICEVOX/onnxruntime-builder
-
Notifications
You must be signed in to change notification settings - Fork 0
351 lines (324 loc) · 13.3 KB
/
build.yml
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
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
name: Build minimal ONNX Runtime
on:
release:
types:
- published
workflow_dispatch:
inputs:
version:
description: "Semantic version (e.g., 1.18.1)"
required: true
repository:
description: "Name of a target repository"
default: 'microsoft/onnxruntime'
required: false
env:
ORT_PYTHON_VERSION: '3.10'
TARGET_LIBRARY: 'onnxruntime'
ONNXRUNTIME_VERSION:
|- # Enter release tag name or version in workflow_dispatch. Recent version if not specified
${{ github.event.release.tag_name || github.event.inputs.version || '1.18.1' }}
REPOSITORY:
${{ github.event.inputs.repository || 'microsoft/onnxruntime' }}
defaults:
run:
shell: bash
jobs:
build:
strategy:
fail-fast: false
matrix:
include:
- artifact_name: onnxruntime-win-x64-minimal
os: windows-2022
build_opts: |-
--minimal_build
--disable_ml_ops
--enable_reduced_operator_type_support
--enable_msvc_static_runtime
--cmake_extra_defines
CMAKE_SYSTEM_NAME=Windows
CMAKE_SYSTEM_PROCESSOR=x86_64 # required for `cpuinfo`
result_dir: build/Release
release_config: Release
- artifact_name: onnxruntime-win-x86-minimal
os: windows-2022
build_opts: |-
--minimal_build
--disable_ml_ops
--enable_reduced_operator_type_support
--enable_msvc_static_runtime
--x86
--cmake_extra_defines
CMAKE_SYSTEM_NAME=Windows
CMAKE_SYSTEM_PROCESSOR=x86 # required for `cpuinfo`
result_dir: build/Release
release_config: Release
- artifact_name: onnxruntime-linux-x64-minimal
os: ubuntu-20.04
cmake_arch: linux-x86_64
build_opts: |-
--minimal_build
--disable_ml_ops
--enable_reduced_operator_type_support
--cmake_extra_defines
CMAKE_SYSTEM_NAME=Linux
CMAKE_SYSTEM_PROCESSOR=x86_64 # required for `cpuinfo`
result_dir: build
release_config: Release
# - artifact_name: onnxruntime-linux-armhf-minimal
# os: ubuntu-22.04-arm
# cmake_arch: linux-aarch64
# build_opts: |-
# --minimal_build
# --disable_ml_ops
# --enable_reduced_operator_type_support
# --arm
# --cmake_extra_defines
# CMAKE_SYSTEM_NAME=Linux
# CMAKE_SYSTEM_PROCESSOR=armv7l # required for `cpuinfo`
# result_dir: build
# release_config: Release
- artifact_name: onnxruntime-linux-arm64-minimal
os: ubuntu-22.04-arm
cmake_arch: linux-aarch64
build_opts: |-
--minimal_build
--disable_ml_ops
--enable_reduced_operator_type_support
--arm64
--cmake_extra_defines
CMAKE_SYSTEM_NAME=Linux
CMAKE_SYSTEM_PROCESSOR=aarch64 # required for `cpuinfo`
result_dir: build
release_config: Release
- artifact_name: onnxruntime-osx-arm64-minimal
os: macos-13
build_opts: |-
--minimal_build
--disable_ml_ops
--enable_reduced_operator_type_support
--cmake_extra_defines
CMAKE_SYSTEM_NAME=Darwin
CMAKE_OSX_ARCHITECTURES=arm64
CMAKE_SYSTEM_PROCESSOR=aarch64 # required for `cpuinfo`
result_dir: build
release_config: Release
- artifact_name: onnxruntime-osx-x86_64-minimal
os: macos-13
build_opts: |-
--minimal_build
--disable_ml_ops
--enable_reduced_operator_type_support
--cmake_extra_defines
CMAKE_SYSTEM_NAME=Darwin
CMAKE_OSX_ARCHITECTURES=x86_64
CMAKE_SYSTEM_PROCESSOR=x86_64 # required for `cpuinfo`
result_dir: build
release_config: Release
- artifact_name: onnxruntime-osx-universal2-minimal
os: macos-13
build_opts: |-
--minimal_build
--disable_ml_ops
--enable_reduced_operator_type_support
--cmake_extra_defines
CMAKE_SYSTEM_NAME=Darwin
CMAKE_OSX_ARCHITECTURES="x86_64;arm64"
result_dir: build
release_config: Release
- artifact_name: onnxruntime-android-x86_64-minimal
os: ubuntu-22.04
cmake_arch: linux-x86_64
build_opts: |-
--minimal_build=extended
--use_nnapi
--disable_ml_ops
--disable_exceptions
--disable_rtti
--enable_reduced_operator_type_support
--android
--android_abi x86_64
--cmake_extra_defines
CMAKE_SYSTEM_NAME=Android
CMAKE_SYSTEM_PROCESSOR=x86_64 # required for `cpuinfo`
result_dir: build
release_config: Release
- artifact_name: onnxruntime-android-arm64-minimal
os: ubuntu-22.04
cmake_arch: linux-x86_64
build_opts: |-
--minimal_build=extended
--use_nnapi
--disable_ml_ops
--disable_exceptions
--disable_rtti
--enable_reduced_operator_type_support
--android
--android_abi arm64-v8a
--cmake_extra_defines
CMAKE_SYSTEM_NAME=Android
CMAKE_SYSTEM_PROCESSOR=aarch64 # required for `cpuinfo`
result_dir: build
release_config: Release
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
repository: ${{ env.REPOSITORY }}
ref: v${{ env.ONNXRUNTIME_VERSION }}
submodules: recursive
github-server-url: https://github.com
- name: Checkout builder
uses: actions/checkout@v4
with:
path: builder
- uses: actions/setup-python@v5
with:
python-version: ${{ env.ORT_PYTHON_VERSION }}
- name: Install build dependencies on macos
if: startsWith(matrix.os, 'macos')
run: |
pip install --no-cache-dir flatbuffers
# ONNX Runtime v1.16.1 requires CMake 3.27 or higher.
- name: Install CMake
if: startsWith(matrix.os, 'ubuntu')
env:
CMAKE_VERSION: 3.27.7
run: |
wget -O cmake.sh "https://github.com/Kitware/CMake/releases/download/v$CMAKE_VERSION/cmake-$CMAKE_VERSION-${{ matrix.cmake_arch }}.sh"
sudo bash cmake.sh --skip-license --prefix=/usr/local
- name: Configure to use latest Android NDK
if: startsWith(matrix.os, 'ubuntu') && startsWith(matrix.artifact_name, 'onnxruntime-android')
run: |
# https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2004-Readme.md#environment-variables-2
echo "ANDROID_NDK_HOME=$ANDROID_NDK_LATEST_HOME" >> "$GITHUB_ENV"
- name: Build ONNX Runtime
run: |
build_opts=(
${{ matrix.build_opts }}
)
python ./tools/ci_build/build.py \
--build_dir ./build \
--config Release \
--update \
--build \
--parallel \
--build_shared_lib \
--compile_no_warning_as_error \
--skip_tests \
"${build_opts[@]}"
- name: Organize artifact
run: |
# Set library name
ARTIFACT_NAME=${{ matrix.artifact_name }}
if [[ "$ARTIFACT_NAME" == "$TARGET_LIBRARY"-win-* ]]; then
# FIXME: この分岐はもう使わないのでは?
onnxruntime_filename=$TARGET_LIBRARY.dll
elif [[ "$ARTIFACT_NAME" == "$TARGET_LIBRARY"-linux-* ]]; then
onnxruntime_filename="lib$TARGET_LIBRARY.so.$ONNXRUNTIME_VERSION"
elif [[ "$ARTIFACT_NAME" == "$TARGET_LIBRARY"-android-* ]]; then
onnxruntime_filename="lib$TARGET_LIBRARY.so"
elif [[ "$ARTIFACT_NAME" == "$TARGET_LIBRARY"-osx-* ]] || [[ "$ARTIFACT_NAME" == "$TARGET_LIBRARY"-ios-* ]]; then
onnxruntime_filename="lib$TARGET_LIBRARY.$ONNXRUNTIME_VERSION.dylib"
else
echo "Unknown target found : ${{ matrix.artifact_name }}"
return 1
fi
# PDBファイル, Privacy.md, include/は不要なので省く
if [ ${{ runner.os }} = Windows ]; then
# https://github.com/microsoft/onnxruntime/blob/v1.16.3/tools/ci_build/github/azure-pipelines/templates/c-api-artifacts-package-and-publish-steps-windows.yml#L34-L72
mkdir -p ./${{ matrix.result_dir }}/${{ matrix.artifact_name }}/lib
git rev-parse HEAD > ./${{ matrix.result_dir }}/${{ matrix.artifact_name }}/GIT_COMMIT_ID
cp ./{LICENSE,README.md,ThirdPartyNotices.txt,VERSION_NUMBER} \
./${{ matrix.result_dir }}/${{ matrix.artifact_name }}/
cp ./${{ matrix.result_dir }}/${{ matrix.release_config }}/"$TARGET_LIBRARY".{dll,lib} \
./${{ matrix.result_dir }}/${{ matrix.artifact_name }}/lib/
if [ -f ./${{ matrix.result_dir }}/${{ matrix.release_config }}/"$TARGET_LIBRARY"_providers_cuda.dll ]; then
cp ./${{ matrix.result_dir }}/${{ matrix.release_config }}/"$TARGET_LIBRARY"_providers_{cuda,shared}.{dll,lib} \
./${{ matrix.result_dir }}/${{ matrix.artifact_name }}/lib/
fi
else
./tools/ci_build/github/linux/copy_strip_binary.sh \
-r ${{ matrix.result_dir }} \
-a ${{ matrix.artifact_name }} \
-l "$onnxruntime_filename" \
-c ${{ matrix.release_config }} \
-s "$(pwd)" \
-t "$(git rev-parse HEAD)"
rm -r ${{ matrix.result_dir }}/${{ matrix.artifact_name }}/{Privacy.md,include}
fi
mv ${{ matrix.result_dir }}/${{ matrix.artifact_name }} "${{ matrix.artifact_name }}-$ONNXRUNTIME_VERSION"
tar cfz "${{ matrix.artifact_name }}-$ONNXRUNTIME_VERSION.tgz" "${{ matrix.artifact_name }}-$ONNXRUNTIME_VERSION/"
- name: Upload to Release
uses: svenstaro/upload-release-action@v2
with:
file: "*.tgz"
tag: ${{ env.ONNXRUNTIME_VERSION }}
overwrite: true
file_glob: true
build-aar:
strategy:
fail-fast: false
matrix:
include:
- artifact_name: onnxruntime-android-aar-minimal
os: ubuntu-22.04
build_settings: tools/ci_build/github/android/default_mobile_aar_build_settings.json
build_variant: mobile
release_config: Release
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
repository: ${{ env.REPOSITORY }}
ref: v${{ env.ONNXRUNTIME_VERSION }}
submodules: recursive
github-server-url: https://github.com
- name: Build ONNX Runtime
run: |
python tools/android_custom_build/build_custom_android_package.py --build_settings ${{ matrix.build_settings }} --config ${{ matrix.release_config }} --onnxruntime_branch_or_tag "v$ONNXRUNTIME_VERSION" ./build
mv "./build/output/aar_out/Release/com/microsoft/onnxruntime/onnxruntime-${{ matrix.build_variant }}/$ONNXRUNTIME_VERSION/" "${{ matrix.artifact_name }}-$ONNXRUNTIME_VERSION"
tar cfz "${{ matrix.artifact_name }}-$ONNXRUNTIME_VERSION.tgz" "${{ matrix.artifact_name }}-$ONNXRUNTIME_VERSION/"
- name: Upload to Release
uses: svenstaro/upload-release-action@v2
with:
file: "*.tgz"
tag: ${{ env.ONNXRUNTIME_VERSION }}
overwrite: true
file_glob: true
build-xcframework:
strategy:
fail-fast: false
matrix:
include:
- artifact_name: onnxruntime-ios-xcframework-minimal
os: macos-13
build_settings: tools/ci_build/github/apple/default_mobile_ios_framework_build_settings.json
release_config: MinSizeRel
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
repository: ${{ env.REPOSITORY }}
ref: v${{ env.ONNXRUNTIME_VERSION }}
submodules: recursive
github-server-url: https://github.com
- uses: actions/setup-python@v5
with:
python-version: ${{ env.ORT_PYTHON_VERSION }}
- name: Install build dependencies on macos
run: |
pip install --no-cache-dir flatbuffers
- name: Build ONNX Runtime
run: |
python tools/ci_build/github/apple/build_apple_framework.py ${{ matrix.build_settings }} --config ${{ matrix.release_config }}
mv build/apple_framework/framework_out/ "${{ matrix.artifact_name }}-$ONNXRUNTIME_VERSION"
7z a "${{ matrix.artifact_name }}-$ONNXRUNTIME_VERSION.zip" "${{ matrix.artifact_name }}-$ONNXRUNTIME_VERSION"
- name: Upload to Release
uses: svenstaro/upload-release-action@v2
with:
file: "*.zip"
tag: ${{ env.ONNXRUNTIME_VERSION }}
overwrite: true
file_glob: true