diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 406d8ef..aa18b56 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -22,7 +22,8 @@ jobs: arch: arm-linux-gnueabihf symlink_workaround: true build_opts: --arm --cmake_extra_defines CMAKE_SYSTEM_NAME=Linux CMAKE_SYSTEM_PROCESSOR=armv7l --config Release --parallel --update --build --build_shared_lib - result_dir: build/Linux/Release + result_dir: build/Linux + release_config: Release - artifact_name: onnxruntime-linux-arm64-cpu os: ubuntu-20.04 cc_version: '8' @@ -30,7 +31,23 @@ jobs: arch: aarch64-linux-gnu symlink_workaround: true build_opts: --arm64 --cmake_extra_defines CMAKE_SYSTEM_NAME=Linux CMAKE_SYSTEM_PROCESSOR=aarch64 --config Release --parallel --update --build --build_shared_lib - result_dir: build/Linux/Release + result_dir: build/Linux + release_config: Release + - artifact_name: onnxruntime-ios-arm64-cpu + os: macos-12 + 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 + result_dir: build/iOS/Release + release_config: Release-iphoneos + - artifact_name: onnxruntime-ios-sim-arm64-cpu + os: macos-12 + 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 + result_dir: build/iOS/Release + release_config: Release-iphonesimulator + - artifact_name: onnxruntime-ios-sim-x86_64-cpu + os: macos-12 + 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 + result_dir: build/iOS/Release + release_config: Release-iphonesimulator env: ONNXRUNTIME_VERSION: v1.14.1 @@ -62,7 +79,7 @@ jobs: key: ${{ matrix.artifact_name }}-${{ env.ONNXRUNTIME_VERSION }}-cache-v1-${{ hashFiles('matrix.json') }} - name: Install build dependencies - if: steps.cache-build-result.outputs.cache-hit != 'true' + if: steps.cache-build-result.outputs.cache-hit != 'true' && startsWith(matrix.os, 'ubuntu') run: | sudo apt-get update sudo apt-get install -y \ @@ -76,7 +93,7 @@ jobs: # ONNX Runtime v1.14.1 requires CMake 3.24 or higher. - name: Install CMake - if: steps.cache-build-result.outputs.cache-hit != 'true' + if: steps.cache-build-result.outputs.cache-hit != 'true' && startsWith(matrix.os, 'ubuntu') env: CMAKE_VERSION: 3.24.4 run: | @@ -84,7 +101,7 @@ jobs: sudo bash cmake.sh --skip-license --prefix=/usr/local - name: Configure build environment - if: steps.cache-build-result.outputs.cache-hit != 'true' + if: steps.cache-build-result.outputs.cache-hit != 'true' && startsWith(matrix.os, 'ubuntu') run: | # Required for arm build # https://github.com/microsoft/onnxruntime/issues/4189#issuecomment-642528278 @@ -96,55 +113,46 @@ jobs: find /usr/${{ matrix.arch }}/lib -name '*.so*' -exec sudo ln -s {} /usr/lib/${{ matrix.arch }}/ ';' sudo ln -s /usr/${{ matrix.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: Build ONNX Runtime if: steps.cache-build-result.outputs.cache-hit != 'true' - env: - CC: ${{ env.ARCH_PREFIX }}gcc-${{ matrix.cc_version }} - CXX: ${{ env.ARCH_PREFIX }}g++-${{ matrix.cxx_version }} run: | # add --arm for gcc-8: https://github.com/microsoft/onnxruntime/issues/4189 # skip test: https://github.com/microsoft/onnxruntime/issues/2436 # ONNX Runtime v1.9.0 requires CMAKE_SYSTEM_PROCESSOR, https://github.com/microsoft/onnxruntime/releases/tag/v1.9.0 # Both CMAKE_SYSTEM_NAME and CMAKE_SYSTEM_PROCESSOR are required. bash ./build.sh ${{ matrix.build_opts }} - + - name: Organize artifact + shell: bash run: | - mkdir artifact - - # copy shared lib - mkdir artifact/lib - - NAME=$(basename ${{ matrix.result_dir }}/libonnxruntime.so.*) - cp "${{ matrix.result_dir }}/${NAME}" artifact/lib/ - ln -s "${NAME}" artifact/lib/libonnxruntime.so - - # copy header files - mkdir artifact/include - - readarray -t HEADERS <> ./artifact/GIT_COMMIT_ID + # コピー先artifactを予め削除しておく + rm -rf ${{ matrix.result_dir }}/${{ matrix.artifact_name }} + rm -rf ./artifact + # バージョンにはvが必要ないので取り除く + ONNXRUNTIME_VERSION=${{ env.ONNXRUNTIME_VERSION }} + ONNXRUNTIME_VERSION=${ONNXRUNTIME_VERSION:1} + # Set library name + if [[ ${{ matrix.artifact_name }} == onnxruntime-linux-* ]]; then + ONNXRUNTIME_NAME=libonnxruntime.so.$ONNXRUNTIME_VERSION + elif [[ ${{ matrix.artifact_name }} == onnxruntime-ios-* ]]; then + ONNXRUNTIME_NAME=libonnxruntime.$ONNXRUNTIME_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 }} ./artifact/ - name: Upload artifact uses: actions/upload-artifact@v2