forked from microsoft/vcpkg
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[vcpkg] Add vcpkg_minimum_required as a replacement for VERSION.txt. (m…
- Loading branch information
1 parent
45fc558
commit 4d136ef
Showing
69 changed files
with
579 additions
and
460 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -327,3 +327,4 @@ prefab/ | |
################### | ||
pythonenv3.8/ | ||
.venv/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# 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. | ||
|
||
## Source | ||
[scripts/cmake/vcpkg_minimum_required.cmake](https://github.com/Microsoft/vcpkg/blob/master/scripts/cmake/vcpkg_minimum_required.cmake) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
scripts/azure-pipelines/end-to-end-tests-dir/binarycaching.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
scripts/azure-pipelines/end-to-end-tests-dir/vcpkg-minimum-required.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() |
2 changes: 2 additions & 0 deletions
2
scripts/e2e_ports/overlays/vcpkg-requires-current-date/portfile.cmake
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
vcpkg_minimum_required(VERSION ${VCPKG_BASE_VERSION}) | ||
set(VCPKG_POLICY_EMPTY_PACKAGE enabled) |
6 changes: 6 additions & 0 deletions
6
scripts/e2e_ports/overlays/vcpkg-requires-current-date/vcpkg.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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": "" | ||
} |
2 changes: 2 additions & 0 deletions
2
scripts/e2e_ports/overlays/vcpkg-requires-future-date/portfile.cmake
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
vcpkg_minimum_required(VERSION 2999-12-31) | ||
set(VCPKG_POLICY_EMPTY_PACKAGE enabled) |
6 changes: 6 additions & 0 deletions
6
scripts/e2e_ports/overlays/vcpkg-requires-future-date/vcpkg.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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": "" | ||
} |
2 changes: 2 additions & 0 deletions
2
scripts/e2e_ports/overlays/vcpkg-requires-old-date/portfile.cmake
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
vcpkg_minimum_required(VERSION 2020-01-12) | ||
set(VCPKG_POLICY_EMPTY_PACKAGE enabled) |
6 changes: 6 additions & 0 deletions
6
scripts/e2e_ports/overlays/vcpkg-requires-old-date/vcpkg.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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": "" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#pragma once | ||
|
||
#include <vcpkg/base/lineinfo.h> | ||
#include <vcpkg/base/stringview.h> | ||
|
||
namespace vcpkg::Checks | ||
{ | ||
void register_global_shutdown_handler(void (*func)()); | ||
|
||
// Note: for internal use | ||
[[noreturn]] void final_cleanup_and_exit(const int exit_code); | ||
|
||
// Indicate that an internal error has occurred and exit the tool. This should be used when invariants have been | ||
// broken. | ||
[[noreturn]] void unreachable(const LineInfo& line_info); | ||
|
||
[[noreturn]] void exit_with_code(const LineInfo& line_info, const int exit_code); | ||
|
||
// Exit the tool without an error message. | ||
[[noreturn]] void exit_fail(const LineInfo& line_info); | ||
|
||
// Exit the tool successfully. | ||
[[noreturn]] void exit_success(const LineInfo& line_info); | ||
|
||
// Display an error message to the user and exit the tool. | ||
[[noreturn]] void exit_with_message(const LineInfo& line_info, StringView error_message); | ||
|
||
// If expression is false, call exit_fail. | ||
void check_exit(const LineInfo& line_info, bool expression); | ||
|
||
// if expression is false, call exit_with_message. | ||
void check_exit(const LineInfo& line_info, bool expression, StringView error_message); | ||
|
||
// Display a message indicating that vcpkg should be upgraded and exit. | ||
[[noreturn]] void exit_maybe_upgrade(const LineInfo& line_info); | ||
[[noreturn]] void exit_maybe_upgrade(const LineInfo& line_info, StringView error_message); | ||
|
||
// Check the indicated condition and call exit_maybe_upgrade if it is false. | ||
void check_maybe_upgrade(const LineInfo& line_info, bool condition); | ||
void check_maybe_upgrade(const LineInfo& line_info, bool condition, StringView error_message); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.