# 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 # Do not output ##vso[] commands with `set -x` or they may be parsed again and include a trailing quote. set +x 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 }}