Use vcpkg caching (#361)
* Use vcpkg caching * fetch tags * Supply OSVmImage to doc generation so vcpkg.yml can include/exclude the correct set of steps
This commit is contained in:
parent
b9212922e7
commit
c7d994f08f
@ -81,8 +81,9 @@ jobs:
|
||||
- ${{ if ne(parameters.ServiceDirectory, 'not-specified' )}}:
|
||||
- job: GenerateReleaseArtifacts
|
||||
pool:
|
||||
vmImage: windows-2019
|
||||
vmImage: $(OSVmImage)
|
||||
variables:
|
||||
OSVmImage: windows-2019
|
||||
VcpkgDependencies: curl[winssl] libxml2
|
||||
VCPKG_DEFAULT_TRIPLET: 'x64-windows-static'
|
||||
steps:
|
||||
|
||||
@ -6,8 +6,28 @@ parameters:
|
||||
# invocations
|
||||
DependenciesVariableName: vcpkg.deps
|
||||
|
||||
# Ref at which to check out (can be commit SHA or tag in the form of
|
||||
# `tags/<tag>`)
|
||||
VcpkgVersion: tags/2020.06
|
||||
|
||||
steps:
|
||||
# Mac OS specific requirements
|
||||
# Set VCPKG_INSTALLATION_ROOT location for cache on Mac OS hosts
|
||||
- task: Bash@3
|
||||
inputs:
|
||||
targetType: inline
|
||||
workingDirectory: $(Agent.TempDirectory)
|
||||
script: |
|
||||
echo "##vso[task.prependpath]$(Agent.TempDirectory)/vcpkg"
|
||||
echo "##vso[task.setvariable variable=VCPKG_INSTALLATION_ROOT;]$(Agent.TempDirectory)/vcpkg"
|
||||
displayName: MacOS - Set VCPKG_INSTALLATION_ROOT
|
||||
condition: >-
|
||||
and(
|
||||
succeeded(),
|
||||
not(eq(variables['${{ parameters.DependenciesVariableName }}'], '')),
|
||||
contains(variables['OSVmImage'], 'macOS')
|
||||
)
|
||||
|
||||
# Set MacOS specific build environment features for vcpkg
|
||||
- task: Bash@3
|
||||
inputs:
|
||||
targetType: inline
|
||||
@ -19,10 +39,56 @@ steps:
|
||||
# Install gcc 9
|
||||
brew install gcc@9
|
||||
gcc --version
|
||||
displayName: MacOS - Set tools versions
|
||||
condition: >-
|
||||
and(
|
||||
succeeded(),
|
||||
not(eq(variables['${{ parameters.DependenciesVariableName }}'], '')),
|
||||
contains(variables['OSVmImage'], 'macOS')
|
||||
)
|
||||
|
||||
# Clear the vcpkg folder so the cache can successfully deploy to that location
|
||||
- bash: |
|
||||
id
|
||||
sudo rm -rf $(VCPKG_INSTALLATION_ROOT)
|
||||
sudo mkdir -p $(VCPKG_INSTALLATION_ROOT)
|
||||
sudo chown `id --name -u`.`id --name -g` $(VCPKG_INSTALLATION_ROOT)
|
||||
displayName: Linux - Clear vcpkg folder
|
||||
condition: >-
|
||||
and(
|
||||
succeeded(),
|
||||
not(eq(variables['${{ parameters.DependenciesVariableName }}'], '')),
|
||||
contains(variables['OSVmImage'], 'ubuntu')
|
||||
)
|
||||
|
||||
# Attempt to restore vcpkg from the cache
|
||||
- task: Cache@2
|
||||
inputs:
|
||||
key: >-
|
||||
$(Agent.JobName)
|
||||
| "${{ parameters.VcpkgVersion }}"
|
||||
| $(Agent.Os)
|
||||
| $(${{ parameters.DependenciesVariableName }})
|
||||
path: $(VCPKG_INSTALLATION_ROOT)
|
||||
cacheHitVar: VcpkgRestoredFromCache
|
||||
displayName: Vcpkg Cache
|
||||
condition: >-
|
||||
and(
|
||||
succeeded(),
|
||||
not(eq(variables['${{ parameters.DependenciesVariableName }}'], '')),
|
||||
not(eq(variables['Skip.VcpkgCache'], 'true'))
|
||||
)
|
||||
|
||||
# Install vcpkg on MacOS
|
||||
- task: Bash@3
|
||||
inputs:
|
||||
targetType: inline
|
||||
workingDirectory: $(Agent.TempDirectory)
|
||||
script: |
|
||||
git clone https://github.com/Microsoft/vcpkg.git
|
||||
cd vcpkg
|
||||
git rev-parse --verify HEAD
|
||||
git checkout ${{ parameters.VcpkgVersion }}
|
||||
git status
|
||||
|
||||
./bootstrap-vcpkg.sh
|
||||
@ -37,12 +103,55 @@ steps:
|
||||
|
||||
echo "##vso[task.prependpath]$(pwd)"
|
||||
echo "##vso[task.setvariable variable=VCPKG_INSTALLATION_ROOT;]$(pwd)"
|
||||
# Execute only for Mac and if there is at least one dependency to be installed
|
||||
condition: and(succeeded(), contains(variables['OSVmImage'], 'macOS'), not(eq(variables['${{ parameters.DependenciesVariableName }}'], '')))
|
||||
displayName: vcpkg bootstrap
|
||||
condition: >-
|
||||
and(
|
||||
succeeded(),
|
||||
ne(variables['VcpkgRestoredFromCache'], 'true'),
|
||||
not(contains(variables['OSVmImage'], 'windows')),
|
||||
not(eq(variables['${{ parameters.DependenciesVariableName }}'], ''))
|
||||
)
|
||||
displayName: MacOS & Linux - vcpkg bootstrap
|
||||
|
||||
# Update vcpkg and re-bootstrap on non-Mac OS'. Vcpkg is installed on the
|
||||
# image at a given time stamp and not moved forward until some update
|
||||
# procedure is run.
|
||||
- task: Bash@3
|
||||
inputs:
|
||||
targetType: inline
|
||||
script: |
|
||||
cd $VCPKG_INSTALLATION_ROOT
|
||||
|
||||
# Sometimes the image has changes in the git tree. Reset to HEAD and
|
||||
# then pull
|
||||
git reset --hard HEAD
|
||||
git fetch --tags
|
||||
git pull origin master
|
||||
git checkout ${{ parameters.VcpkgVersion }}
|
||||
|
||||
./bootstrap-vcpkg.sh
|
||||
condition: >-
|
||||
and(
|
||||
succeeded(),
|
||||
ne(variables['VcpkgRestoredFromCache'], 'true'),
|
||||
not(contains(variables['OSVmImage'], 'macOS')),
|
||||
not(eq(variables['${{ parameters.DependenciesVariableName }}'], ''))
|
||||
)
|
||||
displayName: Non-MacOS - vcpkg bootstrap
|
||||
|
||||
- script: vcpkg version
|
||||
displayName: vcpkg version
|
||||
condition: >-
|
||||
and(
|
||||
succeeded(),
|
||||
not(eq(variables['${{ parameters.DependenciesVariableName }}'], ''))
|
||||
)
|
||||
|
||||
- script: |
|
||||
vcpkg install $(${{ parameters.DependenciesVariableName }})
|
||||
displayName: vcpkg install dependencies
|
||||
displayName: Install Dependencies (vcpkg)
|
||||
# Execute only if there is at least one dependency to be installed
|
||||
condition: and(succeeded(), not(eq(variables['${{ parameters.DependenciesVariableName }}'], '')))
|
||||
condition: >-
|
||||
and(
|
||||
succeeded(),
|
||||
not(eq(variables['${{ parameters.DependenciesVariableName }}'], ''))
|
||||
)
|
||||
Loading…
Reference in New Issue
Block a user