From 9fe196e458007004cece7818574c5759a3e7d82c Mon Sep 17 00:00:00 2001 From: Chester Liu <4710575+skyline75489@users.noreply.github.com> Date: Sat, 14 Sep 2024 12:03:13 +0800 Subject: [PATCH] apple framework packaging yaml --- .pipelines/nuget-publishing.yml | 7 +++++++ .pipelines/stages/capi-packaging-stage.yml | 7 +++++++ .pipelines/stages/jobs/capi-packaging-job.yml | 6 ++++++ .pipelines/stages/jobs/nuget-packaging-job.yml | 5 +++++ .../stages/jobs/steps/capi-appleframework-step.yml | 10 +++------- .pipelines/stages/jobs/steps/utils/download-ort.yml | 12 +++++++++++- .pipelines/stages/nuget-packaging-stage.yml | 6 ++++++ build.py | 2 +- 8 files changed, 46 insertions(+), 9 deletions(-) diff --git a/.pipelines/nuget-publishing.yml b/.pipelines/nuget-publishing.yml index 726493826..448652293 100644 --- a/.pipelines/nuget-publishing.yml +++ b/.pipelines/nuget-publishing.yml @@ -38,6 +38,11 @@ parameters: type: boolean default: true +- name: enable_apple_framework + displayName: 'Whether Apple framework for iOS & macOS is built.' + type: boolean + default: false + - name: ort_version displayName: 'OnnxRuntime version' type: string @@ -89,6 +94,7 @@ stages: enable_win_dml: ${{ parameters.enable_win_dml }} enable_win_arm64: ${{ parameters.enable_win_arm64 }} enable_macos_cpu: ${{ parameters.enable_macos_cpu }} + enable_apple_framework: ${{ parameters.enable_apple_framework }} ort_version: ${{ parameters.ort_version }} ort_cuda_version: ${{ parameters.ort_cuda_version }} ort_dml_version: ${{ parameters.ort_dml_version }} @@ -104,6 +110,7 @@ stages: enable_win_dml: ${{ parameters.enable_win_dml }} enable_win_arm64: ${{ parameters.enable_win_arm64 }} enable_macos_cpu: ${{ parameters.enable_macos_cpu }} + enable_apple_framework: ${{ parameters.enable_apple_framework }} ort_version: ${{ parameters.ort_version }} ort_cuda_version: ${{ parameters.ort_cuda_version }} ort_dml_version: ${{ parameters.ort_dml_version }} diff --git a/.pipelines/stages/capi-packaging-stage.yml b/.pipelines/stages/capi-packaging-stage.yml index 2da3971a8..5cdba65e4 100644 --- a/.pipelines/stages/capi-packaging-stage.yml +++ b/.pipelines/stages/capi-packaging-stage.yml @@ -111,3 +111,10 @@ stages: ort_version: ${{ parameters.ort_version }} os: 'osx' build_config: ${{ parameters.build_config }} + + - ${{ if eq(parameters.enable_macos_cpu, true) }}: + - template: jobs/capi-packaging-job.yml + parameters: + os: 'ios' + ort_version: ${{ parameters.ort_version }} + build_config: ${{ parameters.build_config }} diff --git a/.pipelines/stages/jobs/capi-packaging-job.yml b/.pipelines/stages/jobs/capi-packaging-job.yml index aa9e9efa4..cdeb14807 100644 --- a/.pipelines/stages/jobs/capi-packaging-job.yml +++ b/.pipelines/stages/jobs/capi-packaging-job.yml @@ -14,6 +14,7 @@ parameters: - 'linux' - 'win' - 'osx' + - 'ios' - name: build_config type: string default: 'release' @@ -143,4 +144,9 @@ jobs: ep: ${{ parameters.ep }} build_config: ${{ parameters.build_config }} + - ${{ if eq(parameters.os, 'ios') }}: + - template: steps/capi-appleframework-step.yml + parameters: + build_config: ${{ parameters.build_config }} + - template: steps/compliant-and-cleanup-step.yml diff --git a/.pipelines/stages/jobs/nuget-packaging-job.yml b/.pipelines/stages/jobs/nuget-packaging-job.yml index 8599ee207..89a0306e8 100644 --- a/.pipelines/stages/jobs/nuget-packaging-job.yml +++ b/.pipelines/stages/jobs/nuget-packaging-job.yml @@ -37,6 +37,11 @@ parameters: type: boolean default: false +- name: enable_apple_framework + displayName: 'Whether Apple framework for iOS & macOS is built.' + type: boolean + default: false + - name: ort_version type: string diff --git a/.pipelines/stages/jobs/steps/capi-appleframework-step.yml b/.pipelines/stages/jobs/steps/capi-appleframework-step.yml index 66f4c58b2..76741cc4b 100644 --- a/.pipelines/stages/jobs/steps/capi-appleframework-step.yml +++ b/.pipelines/stages/jobs/steps/capi-appleframework-step.yml @@ -12,13 +12,9 @@ steps: - template: utils/set-nightly-build-option-variable.yml -- powershell: | - New-Item -ItemType Directory -Path $(Build.Repository.LocalPath)\ort\lib -Force - $tmp = New-TemporaryFile - Invoke-WebRequest -Uri 'https://download.onnxruntime.ai/pod-archive-onnxruntime-c-1.19.2.zip' - $tmp | Expand-Archive -DestinationPath $(Build.Repository.LocalPath)\ort\lib - displayName: 'Download ORT xcframework' - workingDirectory: '$(Build.Repository.LocalPath)' +- template: utils/download-ort.yml + parameters: + archiveType: 'zip' - script: | python3 tools/ci_build/github/apple/build_apple_framework.py \ diff --git a/.pipelines/stages/jobs/steps/utils/download-ort.yml b/.pipelines/stages/jobs/steps/utils/download-ort.yml index 47717112c..eb94db51e 100644 --- a/.pipelines/stages/jobs/steps/utils/download-ort.yml +++ b/.pipelines/stages/jobs/steps/utils/download-ort.yml @@ -4,6 +4,16 @@ parameters: - name: ep type: string default: cpu + +variables: +- name: ort_native_package_name + ${{ if eq(parameters.os, 'ios') }}: + value: 'ios' + ${{ if eq(parameters.os, 'android') }}: + value: 'android' + ${{ else }}: + value: $(os)-$(arch) + steps: - task: DownloadPackage@1 @@ -25,7 +35,7 @@ steps: displayName: Unzip OnnxRuntime - task: CopyFiles@2 inputs: - SourceFolder: '$(Build.Repository.LocalPath)/ort/runtimes/$(os)-$(arch)/native' + SourceFolder: '$(Build.Repository.LocalPath)/ort/runtimes/$(ort_native_package_name)/native' TargetFolder: '$(Build.Repository.LocalPath)/ort/lib' - ${{ else }}: - script: | diff --git a/.pipelines/stages/nuget-packaging-stage.yml b/.pipelines/stages/nuget-packaging-stage.yml index 00ad62dd2..4b9182d23 100644 --- a/.pipelines/stages/nuget-packaging-stage.yml +++ b/.pipelines/stages/nuget-packaging-stage.yml @@ -34,6 +34,11 @@ parameters: type: boolean default: true +- name: enable_apple_framework + displayName: 'Whether Apple framework for iOS & macOS is built.' + type: boolean + default: false + - name: ort_version type: string - name: ort_cuda_version @@ -57,6 +62,7 @@ stages: enable_win_cpu: ${{ parameters.enable_win_cpu }} enable_win_arm64: ${{ parameters.enable_win_arm64 }} enable_macos_cpu: ${{ parameters.enable_macos_cpu }} + enable_apple_framework: ${{ parameters.enable_apple_framework }} - ${{ if or(eq(parameters.enable_linux_cuda, true), eq(parameters.enable_win_cuda, true)) }}: - template: jobs/nuget-packaging-job.yml parameters: diff --git a/build.py b/build.py index c5ef4ac7f..152607535 100644 --- a/build.py +++ b/build.py @@ -536,7 +536,7 @@ def _get_opencv_toolchain_file(): if args.macos == "Catalyst": macabi_target = f"{args.osx_arch}-apple-ios{args.apple_deploy_target}-macabi" - cmake_args += [ + command += [ "-DCMAKE_CXX_COMPILER_TARGET=" + macabi_target, "-DCMAKE_C_COMPILER_TARGET=" + macabi_target, "-DCMAKE_CC_COMPILER_TARGET=" + macabi_target,