forked from VOICEVOX/onnxruntime-builder
-
Notifications
You must be signed in to change notification settings - Fork 0
271 lines (240 loc) · 11.6 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
name: Build minimal ONNX Runtime
on:
release:
types:
- published
workflow_dispatch:
inputs:
version:
description: "Semantic version (e.g., 1.17.0)"
required: true
repository:
description: "Name of a target repository"
default: 'microsoft/onnxruntime'
required: false
env:
ORT_PYTHON_VERSION: '3.10'
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.17.0' }}
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 --cmake_extra_defines CMAKE_SYSTEM_NAME=Windows CMAKE_SYSTEM_PROCESSOR=x86_64
result_dir: build/Release
release_config: Release
- artifact_name: onnxruntime-linux-x64-minimal
os: ubuntu-22.04
build_opts: --minimal_build --disable_ml_ops --enable_reduced_operator_type_support --cmake_extra_defines CMAKE_SYSTEM_NAME=Linux CMAKE_SYSTEM_PROCESSOR=x86_64
result_dir: build
release_config: Release
- artifact_name: onnxruntime-linux-armhf-minimal
os: ubuntu-22.04
cc_version: "10"
cxx_version: "10"
linux_cross_arch: arm-linux-gnueabihf
symlink_workaround: true
build_opts: --minimal_build --disable_ml_ops --enable_reduced_operator_type_support --arm --cmake_extra_defines CMAKE_SYSTEM_NAME=Linux CMAKE_SYSTEM_PROCESSOR=armv7l
result_dir: build
release_config: Release
- artifact_name: onnxruntime-linux-arm64-minimal
os: ubuntu-22.04
cc_version: "10"
cxx_version: "10"
linux_cross_arch: aarch64-linux-gnu
symlink_workaround: true
build_opts: --minimal_build --disable_ml_ops --enable_reduced_operator_type_support --arm64 --cmake_extra_defines CMAKE_SYSTEM_NAME=Linux CMAKE_SYSTEM_PROCESSOR=aarch64
result_dir: build
release_config: Release
- artifact_name: onnxruntime-osx-arm64-minimal
os: macos-12
build_opts: --minimal_build --disable_ml_ops --enable_reduced_operator_type_support --cmake_extra_defines CMAKE_SYSTEM_NAME=Darwin CMAKE_OSX_ARCHITECTURES=arm64
result_dir: build
release_config: Release
- artifact_name: onnxruntime-osx-x86_64-minimal
os: macos-12
build_opts: --minimal_build --disable_ml_ops --enable_reduced_operator_type_support --cmake_extra_defines CMAKE_SYSTEM_NAME=Darwin CMAKE_OSX_ARCHITECTURES=x86_64
result_dir: build
release_config: Release
- artifact_name: onnxruntime-osx-universal2-minimal
os: macos-12
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
build_opts: --minimal_build=extended --use_nnapi --disable_ml_ops --disable_exceptions --disable_rtti --enable_reduced_operator_type_support --android_abi x86_64 --cmake_extra_defines CMAKE_SYSTEM_NAME=Android CMAKE_SYSTEM_PROCESSOR=x86_64 --android
result_dir: build
release_config: Release
- artifact_name: onnxruntime-android-arm64-minimal
os: ubuntu-22.04
build_opts: --minimal_build=extended --use_nnapi --disable_ml_ops --disable_exceptions --disable_rtti --enable_reduced_operator_type_support --android_abi arm64-v8a --cmake_extra_defines CMAKE_SYSTEM_NAME=Android CMAKE_SYSTEM_PROCESSOR=aarch64 --android
result_dir: build
release_config: Release
env:
# prefix usage: "", "arm-linux-gnueabihf-" => "gcc-8", "arm-linux-gnueabihf-gcc-8" (command name)
# suffix usage: "", "-arm-linux-gnueabihf" => "gcc-8", "gcc-8-arm-linux-gnueabihf" (package name)
ARCH_PREFIX: "${{ (matrix.linux_cross_arch != '' && matrix.linux_cross_arch) || '' }}${{ (matrix.linux_cross_arch != '' && '-') || '' }}"
ARCH_SUFFIX: "${{ (matrix.linux_cross_arch != '' && '-') || '' }}${{ (matrix.linux_cross_arch != '' && matrix.linux_cross_arch) || '' }}"
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
repository: ${{ env.REPOSITORY }}
ref: v${{ env.VERSION }}
submodules: recursive
github-server-url: https://github.com
- name: Checkout builder
uses: actions/checkout@v4
with:
path: builder
- name: Apply patch
run: |
git apply --ignore-whitespace --reject --whitespace=fix --verbose ./builder/1_17_patch.patch
- uses: actions/setup-python@v5
with:
python-version: ${{ env.ORT_PYTHON_VERSION }}
- name: Install build dependencies on ubuntu
if: startsWith(matrix.os, 'ubuntu') && matrix.linux_cross_arch
run: |
sudo apt-get update
sudo apt-get install -y \
build-essential \
git \
wget \
qemu-user-binfmt \
gcc-${{ matrix.cc_version }}${{ env.ARCH_SUFFIX }} \
g++-${{ matrix.cc_version }}${{ env.ARCH_SUFFIX }}
- name: Install build dependencies on macos
if: startsWith(matrix.os, 'macos')
run: |
pip install --no-cache-dir flatbuffers
- name: Configure build environment for non-x86_64 Linux
if: startsWith(matrix.os, 'ubuntu') && matrix.linux_cross_arch
run: |
# Required for arm build
# https://github.com/microsoft/onnxruntime/issues/4189#issuecomment-642528278
echo 'string(APPEND CMAKE_C_FLAGS " -latomic")' >> cmake/CMakeLists.txt
echo 'string(APPEND CMAKE_CXX_FLAGS " -latomic")' >> cmake/CMakeLists.txt
# Prevent Exec Format Error during cross-compiling
if ${{ matrix.symlink_workaround }}; then
find /usr/${{ matrix.linux_cross_arch }}/lib -name '*.so*' -exec sudo ln -s {} /usr/lib/${{ matrix.linux_cross_arch }}/ ';'
sudo ln -s /usr/${{ matrix.linux_cross_arch }}/lib/ld-linux-*.so* /usr/lib/
fi
# Set environment variable CC / CXX
echo "CC=${{ env.ARCH_PREFIX }}gcc-${{ matrix.cc_version }}" >> "$GITHUB_ENV"
echo "CXX=${{ env.ARCH_PREFIX }}g++-${{ matrix.cxx_version }}" >> "$GITHUB_ENV"
- 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: |
python ./tools/ci_build/build.py --build_dir ./build ${{ matrix.build_opts }} --config Release --parallel --compile_no_warning_as_error --update --build --build_shared_lib --skip_tests
- name: Organize artifact
run: |
# Set library name
if [[ ${{ matrix.artifact_name }} == onnxruntime-win-* ]]; then
ONNXRUNTIME_NAME=onnxruntime.dll
elif [[ ${{ matrix.artifact_name }} == onnxruntime-linux-* ]]; then
ONNXRUNTIME_NAME=libonnxruntime.so.${{ env.VERSION }}
elif [[ ${{ matrix.artifact_name }} == onnxruntime-android-* ]]; then
ONNXRUNTIME_NAME=libonnxruntime.so
elif [[ ${{ matrix.artifact_name }} == onnxruntime-osx-* ]]; then
ONNXRUNTIME_NAME=libonnxruntime.${{ env.VERSION }}.dylib
else
echo "Unknown target found : ${{ matrix.artifact_name }}"
return 1
fi
./tools/ci_build/github/linux/copy_strip_binary.sh \
-r ${{ matrix.result_dir }} \
-a ${{ matrix.artifact_name }} \
-l $ONNXRUNTIME_NAME \
-c ${{ matrix.release_config }} \
-s "$(pwd)" \
-t "$(git rev-parse HEAD)"
mv ${{ matrix.result_dir }}/${{ matrix.artifact_name }} "${{ matrix.artifact_name }}-${{ env.VERSION }}"
tar cfz "${{ matrix.artifact_name }}-${{ env.VERSION }}.tgz" "${{ matrix.artifact_name }}-${{ env.VERSION }}/"
- name: Upload to Release
uses: svenstaro/upload-release-action@v2
with:
file: "*.tgz"
tag: ${{ env.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.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${{ env.VERSION }} ./build
mv "./build/output/aar_out/Release/com/microsoft/onnxruntime/onnxruntime-${{ matrix.build_variant }}/${{ env.VERSION }}/" "${{ matrix.artifact_name }}-${{ env.VERSION }}"
tar cfz "${{ matrix.artifact_name }}-${{ env.VERSION }}.tgz" "${{ matrix.artifact_name }}-${{ env.VERSION }}/"
- name: Upload to Release
uses: svenstaro/upload-release-action@v2
with:
file: "*.tgz"
tag: ${{ env.VERSION }}
overwrite: true
file_glob: true
build-xcframework:
strategy:
fail-fast: false
matrix:
include:
- artifact_name: onnxruntime-ios-xcframework-minimal
os: macos-12
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.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 }}-${{ env.VERSION }}"
7z a "${{ matrix.artifact_name }}-${{ env.VERSION }}.zip" "${{ matrix.artifact_name }}-${{ env.VERSION }}"
- name: Upload to Release
uses: svenstaro/upload-release-action@v2
with:
file: "*.zip"
tag: ${{ env.VERSION }}
overwrite: true
file_glob: true