Add Android executable drop in the Package pipeline (#9050)

* add copy executable for android job

* minor fix

* Variable fix

* Move to use tgz because zip is not part of the docker image

* update compression
This commit is contained in:
Guoyu Wang 2021-09-14 11:45:33 -07:00 committed by GitHub
parent be80698698
commit cf70635d2a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 31 additions and 3 deletions

View file

@ -34,3 +34,10 @@ cp ${BASE_PATH}/${PACKAGE_NAME}-${ORT_VERSION}-javadoc.jar /home/onnxruntimedev
cp ${BASE_PATH}/${PACKAGE_NAME}-${ORT_VERSION}-sources.jar /home/onnxruntimedev/.artifacts
cp ${BASE_PATH}/${PACKAGE_NAME}-${ORT_VERSION}.aar /home/onnxruntimedev/.artifacts
cp ${BASE_PATH}/${PACKAGE_NAME}-${ORT_VERSION}.pom /home/onnxruntimedev/.artifacts
# Copy executables if necessary
if [ "$PUBLISH_EXECUTABLES" == "1" ]; then
pushd /build/intermediates/executables/${BUILD_CONFIG}
tar -czvf /home/onnxruntimedev/.artifacts/${PACKAGE_NAME}-${ORT_VERSION}-executables.tgz *
popd
fi

View file

@ -3,9 +3,10 @@
# Licensed under the MIT License.
import argparse
import json
import os
import pathlib
import json
import shutil
import subprocess
import sys
@ -86,6 +87,7 @@ def _build_aar(args):
build_config = args.config
aar_dir = os.path.join(intermediates_dir, 'aar', build_config)
jnilibs_dir = os.path.join(intermediates_dir, 'jnilibs', build_config)
exe_dir = os.path.join(intermediates_dir, 'executables', build_config)
base_build_command = [
sys.executable, BUILD_PY, '--config=' + build_config
] + build_settings['build_params']
@ -117,6 +119,13 @@ def _build_aar(args):
os.remove(target_lib_name)
os.symlink(os.path.join(abi_build_dir, build_config, lib_name), target_lib_name)
# copy executables for each abi, in case we want to publish those as well
abi_exe_dir = os.path.join(exe_dir, abi)
for exe_name in ['libonnxruntime.so', 'onnxruntime_perf_test', 'onnx_test_runner']:
os.makedirs(abi_exe_dir, exist_ok=True)
target_exe_name = os.path.join(abi_exe_dir, exe_name)
shutil.copyfile(os.path.join(abi_build_dir, build_config, exe_name), target_exe_name)
# we only need to define the header files path once
if not header_files_path:
header_files_path = os.path.join(abi_build_dir, build_config, 'android', 'headers')

View file

@ -24,6 +24,11 @@ parameters:
type: string
default: ''
- name: publish_executables
displayName: Publish executables such as onnxruntime_perf_test, ...
type: string
default: '0'
jobs:
- job: Android_Java_API_AAR_Packaging_${{ parameters.job_name_suffix }}
timeoutInMinutes: 120
@ -76,6 +81,7 @@ jobs:
-e BUILD_BUILDNUMBER \
-e BUILD_CONFIG=${{parameters.buildConfig}} \
-e ORT_VERSION=$(OnnxRuntimeVersion) \
-e PUBLISH_EXECUTABLES=${{parameters.publish_executables}} \
onnxruntimecpubuild \
/bin/bash /onnxruntime_src/tools/ci_build/github/android/build_aar_and_copy_artifacts.sh
workingDirectory: $(Build.SourcesDirectory)

View file

@ -182,6 +182,7 @@ jobs:
buildSettings: '$(Build.SourcesDirectory)/tools/ci_build/github/android/default_full_aar_build_settings.json'
artifactName: 'onnxruntime-android-full-aar'
job_name_suffix: 'Full'
publish_executables: '1'
- job: iOS_Full_xcframework
workspace:
@ -190,14 +191,19 @@ jobs:
vmImage: 'macOS-10.15'
timeoutInMinutes: 180
steps:
- template: set-version-number-variables-step.yml
- script: |
set -e -x
python3 tools/ci_build/github/apple/build_ios_framework.py \
--build_dir "$(Build.BinariesDirectory)/ios_framework" \
tools/ci_build/github/apple/default_full_ios_framework_build_settings.json
mkdir $(Build.BinariesDirectory)/artifacts
pushd $(Build.BinariesDirectory)/ios_framework/framework_out/
zip -vr $(Build.BinariesDirectory)/artifacts/onnxruntime_xcframework.zip onnxruntime.xcframework
mkdir -p $(Build.BinariesDirectory)/artifacts_staging/onnxruntime-ios-xcframework-$(OnnxRuntimeVersion)
cp -R $(Build.BinariesDirectory)/ios_framework/framework_out/onnxruntime.xcframework \
$(Build.BinariesDirectory)/artifacts_staging/onnxruntime-ios-xcframework-$(OnnxRuntimeVersion)
pushd $(Build.BinariesDirectory)/artifacts_staging
zip -vr $(Build.BinariesDirectory)/artifacts/onnxruntime_xcframework.zip \
onnxruntime-ios-xcframework-$(OnnxRuntimeVersion)
popd
displayName: "Build iOS xcframework"