diff options
Diffstat (limited to 'scripts')
15 files changed, 122 insertions, 17 deletions
diff --git a/scripts/azure-pipelines/end-to-end-tests-dir/backcompat-helpers.ps1 b/scripts/azure-pipelines/end-to-end-tests-dir/backcompat-helpers.ps1 index 5b6b1c10f..704b52752 100644 --- a/scripts/azure-pipelines/end-to-end-tests-dir/backcompat-helpers.ps1 +++ b/scripts/azure-pipelines/end-to-end-tests-dir/backcompat-helpers.ps1 @@ -6,18 +6,16 @@ foreach ($backcompatFeaturePort in $backcompatFeaturePorts) { $succeedArgs = $commonArgs + @('install',$backcompatFeaturePort,'--no-binarycaching')
$failArgs = $succeedArgs + @('--x-prohibit-backcompat-features')
$CurrentTest = "Should fail: ./vcpkg $($failArgs -join ' ')"
- Write-Host $CurrentTest
- ./vcpkg @failArgs
+ Run-Vcpkg @failArgs
if ($LastExitCode -ne 0) {
- Write-Host "... failed (this is good!)"
+ Write-Host "... failed (this is good!)."
} else {
throw $CurrentTest
}
# Install failed when prohibiting backcompat features, so it should succeed if we allow them
$CurrentTest = "Should succeeed: ./vcpkg $($succeedArgs -join ' ')"
- Write-Host $CurrentTest
- ./vcpkg @succeedArgs
+ Run-Vcpkg @succeedArgs
if ($LastExitCode -ne 0) {
throw $CurrentTest
} else {
diff --git a/scripts/azure-pipelines/end-to-end-tests-dir/binarycaching.ps1 b/scripts/azure-pipelines/end-to-end-tests-dir/binarycaching.ps1 index 2b7e84fbd..e4ee6e698 100644 --- a/scripts/azure-pipelines/end-to-end-tests-dir/binarycaching.ps1 +++ b/scripts/azure-pipelines/end-to-end-tests-dir/binarycaching.ps1 @@ -1,3 +1,8 @@ +if ($IsLinux) {
+ # The tests below need a mono installation not currently available on the Linux agents.
+ return
+}
+
. $PSScriptRoot/../end-to-end-tests-prelude.ps1
# Test simple installation
diff --git a/scripts/azure-pipelines/end-to-end-tests-dir/vcpkg-minimum-required.ps1 b/scripts/azure-pipelines/end-to-end-tests-dir/vcpkg-minimum-required.ps1 new file mode 100644 index 000000000..8f512ae7a --- /dev/null +++ b/scripts/azure-pipelines/end-to-end-tests-dir/vcpkg-minimum-required.ps1 @@ -0,0 +1,22 @@ +. $PSScriptRoot/../end-to-end-tests-prelude.ps1 + +$successCases = @('vcpkg-requires-current-date', 'vcpkg-requires-old-date') +foreach ($successCase in $successCases) { + $CurrentTest = "Should succeeed: ./vcpkg install $successCase" + Write-Host $CurrentTest + Run-Vcpkg install $successCase @commonArgs + if ($LastExitCode -ne 0) { + throw $CurrentTest + } else { + Write-Host "... succeeded." + } +} + +$CurrentTest = "Should fail: ./vcpkg install vcpkg-requires-future-date" +Write-Host $CurrentTest +Run-Vcpkg install vcpkg-requires-future-date @commonArgs +if ($LastExitCode -ne 0) { + Write-Host "... failed (this is good!)." +} else { + throw $CurrentTest +} diff --git a/scripts/azure-pipelines/end-to-end-tests.ps1 b/scripts/azure-pipelines/end-to-end-tests.ps1 index 3c9dd067f..8858b362e 100644 --- a/scripts/azure-pipelines/end-to-end-tests.ps1 +++ b/scripts/azure-pipelines/end-to-end-tests.ps1 @@ -32,6 +32,10 @@ Param( $ErrorActionPreference = "Stop"
+if (-Not (Test-Path $WorkingRoot)) {
+ New-Item -Path $WorkingRoot -ItemType Directory
+}
+
$WorkingRoot = (Get-Item $WorkingRoot).FullName
$AllTests = Get-ChildItem $PSScriptRoot/end-to-end-tests-dir/*.ps1
@@ -47,4 +51,5 @@ $AllTests | % { $n += 1
}
+Write-Host "[end-to-end-tests.ps1] All tests passed."
$LASTEXITCODE = 0
diff --git a/scripts/azure-pipelines/linux/azure-pipelines.yml b/scripts/azure-pipelines/linux/azure-pipelines.yml index 018203a6a..40089bc24 100644 --- a/scripts/azure-pipelines/linux/azure-pipelines.yml +++ b/scripts/azure-pipelines/linux/azure-pipelines.yml @@ -37,11 +37,18 @@ jobs: - bash: toolsrc/build.rel/vcpkg-test
displayName: 'Run vcpkg tests'
- task: PowerShell@2
+ displayName: 'Run vcpkg end-to-end tests'
+ inputs:
+ filePath: 'scripts/azure-pipelines/end-to-end-tests.ps1'
+ arguments: '-Triplet x64-linux -WorkingRoot ${{ variables.WORKING_ROOT }}'
+ pwsh: true
+ - task: PowerShell@2
displayName: '*** Test Modified Ports and Prepare Test Logs ***'
inputs:
failOnStderr: true
filePath: 'scripts/azure-pipelines/test-modified-ports.ps1'
arguments: '-Triplet x64-linux -BuildReason $(Build.Reason) -UseEnvironmentSasToken -WorkingRoot ${{ variables.WORKING_ROOT }} -ArtifactStagingDirectory $(Build.ArtifactStagingDirectory)'
+ pwsh: true
- bash: |
df -h
displayName: 'Report on Disk Space After Build'
diff --git a/scripts/azure-pipelines/osx/azure-pipelines.yml b/scripts/azure-pipelines/osx/azure-pipelines.yml index c0e1c3a26..fa0d0e056 100644 --- a/scripts/azure-pipelines/osx/azure-pipelines.yml +++ b/scripts/azure-pipelines/osx/azure-pipelines.yml @@ -38,12 +38,14 @@ jobs: inputs:
filePath: 'scripts/azure-pipelines/end-to-end-tests.ps1'
arguments: '-Triplet x64-osx -WorkingRoot ${{ variables.WORKING_ROOT }}'
+ pwsh: true
- task: PowerShell@2
displayName: '*** Test Modified Ports and Prepare Test Logs ***'
inputs:
failOnStderr: true
filePath: 'scripts/azure-pipelines/test-modified-ports.ps1'
arguments: '-Triplet x64-osx -BuildReason $(Build.Reason) -BinarySourceStub "$(BINARY_SOURCE_STUB)" -WorkingRoot ${{ variables.WORKING_ROOT }} -ArtifactStagingDirectory $(Build.ArtifactStagingDirectory)'
+ pwsh: true
- bash: |
df -h
displayName: 'Report on Disk Space After Build'
diff --git a/scripts/bootstrap.ps1 b/scripts/bootstrap.ps1 index 018ba3f99..b4c6295c0 100644 --- a/scripts/bootstrap.ps1 +++ b/scripts/bootstrap.ps1 @@ -369,7 +369,8 @@ else } $arguments = ( -"`"/p:VCPKG_VERSION=-unknownhash`"", +"`"/p:VCPKG_VERSION=unknownhash`"", +"`"/p:VCPKG_BASE_VERSION=2021-01-13`"", # Note: This duplicate date version will be short lived. See https://github.com/microsoft/vcpkg/pull/15474 "/p:Configuration=Release", "/p:Platform=$platform", "/p:PlatformToolset=$platformToolset", diff --git a/scripts/cmake/vcpkg_minimum_required.cmake b/scripts/cmake/vcpkg_minimum_required.cmake new file mode 100644 index 000000000..202935b89 --- /dev/null +++ b/scripts/cmake/vcpkg_minimum_required.cmake @@ -0,0 +1,49 @@ +#[===[.md: +# vcpkg_minimum_required + +Asserts that the version of the vcpkg program being used to build a port is later than the supplied date, inclusive. + +## Usage +```cmake +vcpkg_minimum_required(VERSION 2021-01-13) +``` + +## Parameters +### VERSION +The date-version to check against. +#]===] + +function(vcpkg_minimum_required) + cmake_parse_arguments(PARSE_ARGV 0 _vcpkg "" "VERSION" "") + if (NOT DEFINED VCPKG_BASE_VERSION) + message(FATAL_ERROR + "Your vcpkg executable is outdated and is not compatible with the current CMake scripts. " + "Please re-acquire vcpkg by running bootstrap-vcpkg." + ) + endif() + + set(_vcpkg_date_regex "^[12][0-9][0-9][0-9]-[01][0-9]-[0-3][0-9]$") + if (NOT VCPKG_BASE_VERSION MATCHES "${_vcpkg_date_regex}") + message(FATAL_ERROR + "vcpkg internal failure; \${VCPKG_BASE_VERSION} (${VCPKG_BASE_VERSION}) was not a valid date." + ) + endif() + + if (NOT _vcpkg_VERSION MATCHES "${_vcpkg_date_regex}") + message(FATAL_ERROR + "VERSION parameter to vcpkg_minimum_required was not a valid date. " + "Comparing with vcpkg tool version ${_vcpkg_matched_base_version}" + ) + endif() + + string(REPLACE "-" "." _VCPKG_BASE_VERSION_as_dotted "${VCPKG_BASE_VERSION}") + string(REPLACE "-" "." _vcpkg_VERSION_as_dotted "${_vcpkg_VERSION}") + + if (_VCPKG_BASE_VERSION_as_dotted VERSION_LESS _vcpkg_VERSION_as_dotted) + message(FATAL_ERROR + "Your vcpkg executable is from ${VCPKG_BASE_VERSION} which is older than required by the caller " + "of vcpkg_minimum_required (${_vcpkg_VERSION}). " + "Please re-acquire vcpkg by running bootstrap-vcpkg." + ) + endif() +endfunction() diff --git a/scripts/e2e_ports/overlays/vcpkg-requires-current-date/portfile.cmake b/scripts/e2e_ports/overlays/vcpkg-requires-current-date/portfile.cmake new file mode 100644 index 000000000..68dc779a8 --- /dev/null +++ b/scripts/e2e_ports/overlays/vcpkg-requires-current-date/portfile.cmake @@ -0,0 +1,2 @@ +vcpkg_minimum_required(VERSION ${VCPKG_BASE_VERSION}) +set(VCPKG_POLICY_EMPTY_PACKAGE enabled) diff --git a/scripts/e2e_ports/overlays/vcpkg-requires-current-date/vcpkg.json b/scripts/e2e_ports/overlays/vcpkg-requires-current-date/vcpkg.json new file mode 100644 index 000000000..48debf1e7 --- /dev/null +++ b/scripts/e2e_ports/overlays/vcpkg-requires-current-date/vcpkg.json @@ -0,0 +1,6 @@ +{ + "name": "vcpkg-requires-current-date", + "version-string": "1.0.0", + "description": "A test port that verifies that vcpkg_minimum_required is inclusive by using the current base version value.", + "homepage": "" +} diff --git a/scripts/e2e_ports/overlays/vcpkg-requires-future-date/portfile.cmake b/scripts/e2e_ports/overlays/vcpkg-requires-future-date/portfile.cmake new file mode 100644 index 000000000..b68e53e95 --- /dev/null +++ b/scripts/e2e_ports/overlays/vcpkg-requires-future-date/portfile.cmake @@ -0,0 +1,2 @@ +vcpkg_minimum_required(VERSION 2999-12-31) +set(VCPKG_POLICY_EMPTY_PACKAGE enabled) diff --git a/scripts/e2e_ports/overlays/vcpkg-requires-future-date/vcpkg.json b/scripts/e2e_ports/overlays/vcpkg-requires-future-date/vcpkg.json new file mode 100644 index 000000000..f60901998 --- /dev/null +++ b/scripts/e2e_ports/overlays/vcpkg-requires-future-date/vcpkg.json @@ -0,0 +1,6 @@ +{ + "name": "vcpkg-requires-future-date", + "version-string": "1.0.0", + "description": "A test port that requires a vcpkg version from an impossibly far future.", + "homepage": "" +} diff --git a/scripts/e2e_ports/overlays/vcpkg-requires-old-date/portfile.cmake b/scripts/e2e_ports/overlays/vcpkg-requires-old-date/portfile.cmake new file mode 100644 index 000000000..5a4fbf421 --- /dev/null +++ b/scripts/e2e_ports/overlays/vcpkg-requires-old-date/portfile.cmake @@ -0,0 +1,2 @@ +vcpkg_minimum_required(VERSION 2020-01-12) +set(VCPKG_POLICY_EMPTY_PACKAGE enabled) diff --git a/scripts/e2e_ports/overlays/vcpkg-requires-old-date/vcpkg.json b/scripts/e2e_ports/overlays/vcpkg-requires-old-date/vcpkg.json new file mode 100644 index 000000000..31e6fb62f --- /dev/null +++ b/scripts/e2e_ports/overlays/vcpkg-requires-old-date/vcpkg.json @@ -0,0 +1,6 @@ +{ + "name": "vcpkg-requires-old-date", + "version-string": "1.0.0", + "description": "A test port that requires a vcpkg version from before vcpkg_minimum_required's introduction.", + "homepage": "" +} diff --git a/scripts/ports.cmake b/scripts/ports.cmake index 723d7e1df..9e1ba6b32 100644 --- a/scripts/ports.cmake +++ b/scripts/ports.cmake @@ -13,21 +13,13 @@ else() set(_VCPKG_BACKCOMPAT_MESSAGE_LEVEL "WARNING") endif() -if((NOT DEFINED VCPKG_ROOT_DIR) - OR (NOT DEFINED DOWNLOADS) - OR (NOT DEFINED _VCPKG_INSTALLED_DIR) - OR (NOT DEFINED PACKAGES_DIR) - OR (NOT DEFINED BUILDTREES_DIR)) - message(FATAL_ERROR [[ - Your vcpkg executable is outdated and is not compatible with the current CMake scripts. - Please re-build vcpkg by running bootstrap-vcpkg. - ]]) -endif() +list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake) +include(vcpkg_minimum_required) +vcpkg_minimum_required(VERSION 2021-01-13) file(TO_CMAKE_PATH ${BUILDTREES_DIR} BUILDTREES_DIR) file(TO_CMAKE_PATH ${PACKAGES_DIR} PACKAGES_DIR) -list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake) set(CURRENT_INSTALLED_DIR ${_VCPKG_INSTALLED_DIR}/${TARGET_TRIPLET} CACHE PATH "Location to install final packages") set(SCRIPTS ${CMAKE_CURRENT_LIST_DIR} CACHE PATH "Location to stored scripts") |
