diff --git a/tools/ci_build/github/android/build_aar_and_copy_artifacts.sh b/tools/ci_build/github/android/build_aar_and_copy_artifacts.sh index e1efd1471a..83a4813e84 100755 --- a/tools/ci_build/github/android/build_aar_and_copy_artifacts.sh +++ b/tools/ci_build/github/android/build_aar_and_copy_artifacts.sh @@ -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 diff --git a/tools/ci_build/github/android/build_aar_package.py b/tools/ci_build/github/android/build_aar_package.py index af43689c07..948942a914 100644 --- a/tools/ci_build/github/android/build_aar_package.py +++ b/tools/ci_build/github/android/build_aar_package.py @@ -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') diff --git a/tools/ci_build/github/azure-pipelines/templates/android-java-api-aar.yml b/tools/ci_build/github/azure-pipelines/templates/android-java-api-aar.yml index e245ae278d..c4385ae98b 100644 --- a/tools/ci_build/github/azure-pipelines/templates/android-java-api-aar.yml +++ b/tools/ci_build/github/azure-pipelines/templates/android-java-api-aar.yml @@ -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) diff --git a/tools/ci_build/github/azure-pipelines/templates/c-api-cpu.yml b/tools/ci_build/github/azure-pipelines/templates/c-api-cpu.yml index b13f59a357..0784003699 100644 --- a/tools/ci_build/github/azure-pipelines/templates/c-api-cpu.yml +++ b/tools/ci_build/github/azure-pipelines/templates/c-api-cpu.yml @@ -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"