Skip to content

Commit 5d697ef

Browse files
authored
iOSビルドの追加 (#13)
1 parent 7d1a14f commit 5d697ef

File tree

1 file changed

+51
-43
lines changed

1 file changed

+51
-43
lines changed

.github/workflows/build.yml

Lines changed: 51 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,32 @@ jobs:
2222
arch: arm-linux-gnueabihf
2323
symlink_workaround: true
2424
build_opts: --arm --cmake_extra_defines CMAKE_SYSTEM_NAME=Linux CMAKE_SYSTEM_PROCESSOR=armv7l --config Release --parallel --update --build --build_shared_lib
25-
result_dir: build/Linux/Release
25+
result_dir: build/Linux
26+
release_config: Release
2627
- artifact_name: onnxruntime-linux-arm64-cpu
2728
os: ubuntu-20.04
2829
cc_version: '8'
2930
cxx_version: '8'
3031
arch: aarch64-linux-gnu
3132
symlink_workaround: true
3233
build_opts: --arm64 --cmake_extra_defines CMAKE_SYSTEM_NAME=Linux CMAKE_SYSTEM_PROCESSOR=aarch64 --config Release --parallel --update --build --build_shared_lib
33-
result_dir: build/Linux/Release
34+
result_dir: build/Linux
35+
release_config: Release
36+
- artifact_name: onnxruntime-ios-arm64-cpu
37+
os: macos-12
38+
build_opts: --config Release --parallel --update --build --build_shared_lib --skip_tests --use_xcode --ios --ios_sysroot iphoneos --osx_arch arm64 --apple_deploy_target 16.0
39+
result_dir: build/iOS/Release
40+
release_config: Release-iphoneos
41+
- artifact_name: onnxruntime-ios-sim-arm64-cpu
42+
os: macos-12
43+
build_opts: --config Release --parallel --update --build --build_shared_lib --skip_tests --use_xcode --ios --ios_sysroot iphonesimulator --osx_arch arm64 --apple_deploy_target 16.0
44+
result_dir: build/iOS/Release
45+
release_config: Release-iphonesimulator
46+
- artifact_name: onnxruntime-ios-sim-x86_64-cpu
47+
os: macos-12
48+
build_opts: --config Release --parallel --update --build --build_shared_lib --skip_tests --use_xcode --ios --ios_sysroot iphonesimulator --osx_arch x86_64 --apple_deploy_target 16.0
49+
result_dir: build/iOS/Release
50+
release_config: Release-iphonesimulator
3451

3552
env:
3653
ONNXRUNTIME_VERSION: v1.14.1
@@ -62,7 +79,7 @@ jobs:
6279
key: ${{ matrix.artifact_name }}-${{ env.ONNXRUNTIME_VERSION }}-cache-v1-${{ hashFiles('matrix.json') }}
6380

6481
- name: Install build dependencies
65-
if: steps.cache-build-result.outputs.cache-hit != 'true'
82+
if: steps.cache-build-result.outputs.cache-hit != 'true' && startsWith(matrix.os, 'ubuntu')
6683
run: |
6784
sudo apt-get update
6885
sudo apt-get install -y \
@@ -76,15 +93,15 @@ jobs:
7693
7794
# ONNX Runtime v1.14.1 requires CMake 3.24 or higher.
7895
- name: Install CMake
79-
if: steps.cache-build-result.outputs.cache-hit != 'true'
96+
if: steps.cache-build-result.outputs.cache-hit != 'true' && startsWith(matrix.os, 'ubuntu')
8097
env:
8198
CMAKE_VERSION: 3.24.4
8299
run: |
83100
wget -O cmake.sh "https://github.com/Kitware/CMake/releases/download/v${{ env.CMAKE_VERSION }}/cmake-${{ env.CMAKE_VERSION }}-linux-x86_64.sh"
84101
sudo bash cmake.sh --skip-license --prefix=/usr/local
85102
86103
- name: Configure build environment
87-
if: steps.cache-build-result.outputs.cache-hit != 'true'
104+
if: steps.cache-build-result.outputs.cache-hit != 'true' && startsWith(matrix.os, 'ubuntu')
88105
run: |
89106
# Required for arm build
90107
# https://github.com/microsoft/onnxruntime/issues/4189#issuecomment-642528278
@@ -96,55 +113,46 @@ jobs:
96113
find /usr/${{ matrix.arch }}/lib -name '*.so*' -exec sudo ln -s {} /usr/lib/${{ matrix.arch }}/ ';'
97114
sudo ln -s /usr/${{ matrix.arch }}/lib/ld-linux-*.so* /usr/lib/
98115
fi
116+
117+
# Set environment variable CC / CXX
118+
echo "CC=${{ env.ARCH_PREFIX }}gcc-${{ matrix.cc_version }}" >> "$GITHUB_ENV"
119+
echo "CXX=${{ env.ARCH_PREFIX }}g++-${{ matrix.cxx_version }}" >> "$GITHUB_ENV"
99120
100121
- name: Build ONNX Runtime
101122
if: steps.cache-build-result.outputs.cache-hit != 'true'
102-
env:
103-
CC: ${{ env.ARCH_PREFIX }}gcc-${{ matrix.cc_version }}
104-
CXX: ${{ env.ARCH_PREFIX }}g++-${{ matrix.cxx_version }}
105123
run: |
106124
# add --arm for gcc-8: https://github.com/microsoft/onnxruntime/issues/4189
107125
# skip test: https://github.com/microsoft/onnxruntime/issues/2436
108126
# ONNX Runtime v1.9.0 requires CMAKE_SYSTEM_PROCESSOR, https://github.com/microsoft/onnxruntime/releases/tag/v1.9.0
109127
# Both CMAKE_SYSTEM_NAME and CMAKE_SYSTEM_PROCESSOR are required.
110128
bash ./build.sh ${{ matrix.build_opts }}
111-
129+
112130
- name: Organize artifact
131+
shell: bash
113132
run: |
114-
mkdir artifact
115-
116-
# copy shared lib
117-
mkdir artifact/lib
118-
119-
NAME=$(basename ${{ matrix.result_dir }}/libonnxruntime.so.*)
120-
cp "${{ matrix.result_dir }}/${NAME}" artifact/lib/
121-
ln -s "${NAME}" artifact/lib/libonnxruntime.so
122-
123-
# copy header files
124-
mkdir artifact/include
125-
126-
readarray -t HEADERS <<EOF
127-
onnxruntime/core/session/onnxruntime_c_api.h
128-
onnxruntime/core/session/onnxruntime_cxx_api.h
129-
onnxruntime/core/session/onnxruntime_cxx_inline.h
130-
onnxruntime/core/providers/cpu/cpu_provider_factory.h
131-
onnxruntime/core/session/onnxruntime_session_options_config_keys.h
132-
onnxruntime/core/session/onnxruntime_run_options_config_keys.h
133-
onnxruntime/core/framework/provider_options.h
134-
EOF
135-
136-
for path in "${HEADERS[@]}"; do
137-
cp "include/${path}" ./artifact/include/
138-
done
139-
140-
# copy docs & license
141-
cp VERSION_NUMBER ./artifact/
142-
cp LICENSE ./artifact/
143-
cp ThirdPartyNotices.txt ./artifact/
144-
cp docs/Privacy.md ./artifact/
145-
cp README.md ./artifact/
146-
147-
echo "$(git rev-parse HEAD)" >> ./artifact/GIT_COMMIT_ID
133+
# コピー先artifactを予め削除しておく
134+
rm -rf ${{ matrix.result_dir }}/${{ matrix.artifact_name }}
135+
rm -rf ./artifact
136+
# バージョンにはvが必要ないので取り除く
137+
ONNXRUNTIME_VERSION=${{ env.ONNXRUNTIME_VERSION }}
138+
ONNXRUNTIME_VERSION=${ONNXRUNTIME_VERSION:1}
139+
# Set library name
140+
if [[ ${{ matrix.artifact_name }} == onnxruntime-linux-* ]]; then
141+
ONNXRUNTIME_NAME=libonnxruntime.so.$ONNXRUNTIME_VERSION
142+
elif [[ ${{ matrix.artifact_name }} == onnxruntime-ios-* ]]; then
143+
ONNXRUNTIME_NAME=libonnxruntime.$ONNXRUNTIME_VERSION.dylib
144+
else
145+
echo "Unknown target found : ${{ matrix.artifact_name }}"
146+
return 1
147+
fi
148+
./tools/ci_build/github/linux/copy_strip_binary.sh \
149+
-r ${{ matrix.result_dir }} \
150+
-a ${{ matrix.artifact_name }} \
151+
-l $ONNXRUNTIME_NAME \
152+
-c ${{ matrix.release_config }} \
153+
-s "$(pwd)" \
154+
-t "$(git rev-parse HEAD)"
155+
mv ${{ matrix.result_dir }}/${{ matrix.artifact_name }} ./artifact/
148156
149157
- name: Upload artifact
150158
uses: actions/upload-artifact@v2

0 commit comments

Comments
 (0)