onnxruntime/tools/ci_build/github/azure-pipelines/templates/mac-ci.yml
Yi Zhang 7894d44d2d
Improve MacOS Cache Code (#13958)
### Description
Update cache key to make cache could be updated.
2022-12-14 20:47:09 +08:00

120 lines
3.7 KiB
YAML

parameters:
- name: AdditionalBuildFlags
displayName: Additional build flags for build.py
type: string
default: ''
# Must be 1 or 0
- name: AllowReleasedOpsetOnly
displayName: Whether unreleased onnx opsets are allowed
type: number
default: 1
values:
- 1
- 0
- name: BuildForAllArchs
displayName: Build for all CPU ARCHs
type: boolean
jobs:
- job: MacOS_C_API_Packaging_CPU_x64
workspace:
clean: all
variables:
MACOSX_DEPLOYMENT_TARGET: '10.14'
ALLOW_RELEASED_ONNX_OPSET_ONLY: ${{ parameters.AllowReleasedOpsetOnly }}
CCACHE_DIR: $(Pipeline.Workspace)/ccache
pool:
vmImage: 'macOS-11'
timeoutInMinutes: 300
steps:
- checkout: self
clean: true
submodules: none
- task: UsePythonVersion@0
# Use python 3.8 to avoid build some of the required packages
displayName: Use Python 3.8
inputs:
versionSpec: 3.8
- task: NodeTool@0
inputs:
versionSpec: '16.x'
- template: set-version-number-variables-step.yml
- script: |
brew install ccache
echo "##vso[task.prependpath]/usr/local/opt/ccache/libexec"
displayName: Install ccache and update PATH to use linked versions of gcc, cc, etc
- task: Cache@2
inputs:
key: 'ccache | "$(Agent.OS)" | protocol | "$(Build.SourceVersion)" '
path: $(CCACHE_DIR)
restoreKeys: |
ccache | "$(Agent.OS)" | protocol
displayName: ccache protocol
- script: |
set -e -x
pushd .
$(Build.SourcesDirectory)/tools/ci_build/github/linux/docker/inference/x64/python/cpu/scripts/install_protobuf.sh -d $(Build.SourcesDirectory)/cmake/deps.txt -p $(Build.BinariesDirectory)/installed
popd
export PATH=$(Build.BinariesDirectory)/installed/bin:$PATH
export ONNX_ML=1
export CMAKE_ARGS="-DONNX_GEN_PB_TYPE_STUBS=OFF -DONNX_WERROR=OFF"
python3 -m pip install -r '$(Build.SourcesDirectory)/tools/ci_build/github/linux/docker/scripts/requirements.txt'
sudo xcode-select --switch /Applications/Xcode_12.4.app/Contents/Developer
displayName: 'Install dependencies'
- script: |
ccache -s
ccache -z
displayName: Show Cache stats and Clear protolbuf stats.
- task: Cache@2
inputs:
key: 'ccache | "$(Agent.OS)" | onnxruntime | "$(Build.SourceVersion)" '
path: $(CCACHE_DIR)
restoreKeys: |
ccache | "$(Agent.OS)" | onnxruntime
displayName: ccache MacOS Build
- ${{ if eq(parameters.BuildForAllArchs, true) }}:
- template: mac-packaging.yml
parameters :
AdditionalBuildFlags : ${{ parameters.AdditionalBuildFlags }} --build_java --build_nodejs --use_coreml --cmake_extra_defines CMAKE_OSX_ARCHITECTURES=arm64
MacosArch: arm64
BuildJava: true
BuildNodejs: true
- ${{ if eq(parameters.BuildForAllArchs, true) }}:
- template: mac-packaging.yml
parameters :
AdditionalBuildFlags : ${{ parameters.AdditionalBuildFlags }} --use_coreml --cmake_extra_defines CMAKE_OSX_ARCHITECTURES="arm64;x86_64"
MacosArch: universal2
BuildJava: false
BuildNodejs: false
- template: mac-packaging.yml
parameters :
AdditionalBuildFlags : ${{ parameters.AdditionalBuildFlags }} --build_java --build_nodejs --use_coreml
MacosArch: x86_64
BuildJava: true
BuildNodejs: true
- script: |
ccache -s
ccache -z
displayName: Show Cache stats
- task: PublishPipelineArtifact@1
inputs:
targetPath: '$(Build.ArtifactStagingDirectory)'
artifactName: 'onnxruntime-osx'
- template: component-governance-component-detection-steps.yml
parameters :
condition : 'succeeded'