onnxruntime/tools/ci_build/github/azure-pipelines/templates/mac-build-step-with-cache.yml
Yi Zhang feafbc4263
Refactor all Mac build steps (#15440)
### Description


### Motivation and Context
Make the compilation cache steps easy to use and maintain
Reduce cache storage.
2023-04-11 12:12:46 +08:00

60 lines
1.7 KiB
YAML

# It's used for compilation with cache in Mac Host.
parameters:
- name: WithCache
displayName: Build with Cache
type: boolean
default: false
- name: BuildStep
type: stepList
# if WithCahe is false, the following parameters are not used.
- name: Today
type: string
default: ""
- name: AdditionalKey
type: string
default: ""
- name: CacheDir
type: string
default: ""
- name: ChangeEveryCommit
type: boolean
default: true
steps:
- script: |
which ccache || brew install ccache
echo "##vso[task.prependpath]/usr/local/opt/ccache/libexec"
mkdir -p "${{ parameters.CacheDir }}"
displayName: Install ccache and update PATH to use linked versions of gcc, cc, etc
condition: eq(${{ parameters.WithCache }}, true)
- task: Cache@2
inputs:
${{ if eq(parameters.ChangeEveryCommit, true) }}:
# If it's a merge build, the run will read the cache generated by main build.
${{if eq(variables['Build.SourceBranchName'], 'merge')}}:
key: ' "$(TODAY)" | ccache | merge '
${{else}}:
key: ' "${{parameters.Today}}" | ${{parameters.AdditionalKey}} | "$(Build.SourceVersion)" '
restoreKeys: |
"${{parameters.Today}}" | ${{parameters.AdditionalKey}}
${{ else }}:
key: ' ${{parameters.AdditionalKey}} '
restoreKeys: |
${{parameters.AdditionalKey}}
path: ${{ parameters.CacheDir }}
displayName: ccache task
condition: eq(${{ parameters.WithCache }}, true)
- ${{ parameters.BuildStep }}
- ${{ if eq(parameters.WithCache, true) }}:
- template: check-cache-stats.yml
parameters:
CacheDir: ${{ parameters.CacheDir }}