mirror of
https://github.com/microsoft/vcpkg.git
synced 2024-11-27 19:09:00 +08:00
[vcpkg] Add vcpkg_minimum_required as a replacement for VERSION.txt. (#15638)
This commit is contained in:
parent
45fc55825d
commit
4d136ef25f
1
.gitignore
vendored
1
.gitignore
vendored
@ -327,3 +327,4 @@ prefab/
|
||||
###################
|
||||
pythonenv3.8/
|
||||
.venv/
|
||||
|
||||
|
@ -53,5 +53,6 @@
|
||||
- [vcpkg\_install\_nmake](vcpkg_install_nmake.md)
|
||||
- [vcpkg\_install\_qmake](vcpkg_install_qmake.md)
|
||||
- [vcpkg\_internal\_get\_cmake\_vars](vcpkg_internal_get_cmake_vars.md)
|
||||
- [vcpkg\_minimum\_required](vcpkg_minimum_required.md)
|
||||
- [vcpkg\_prettify\_command](vcpkg_prettify_command.md)
|
||||
- [vcpkg\_replace\_string](vcpkg_replace_string.md)
|
||||
|
15
docs/maintainers/vcpkg_minimum_required.md
Normal file
15
docs/maintainers/vcpkg_minimum_required.md
Normal file
@ -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)
|
@ -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 {
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
}
|
@ -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
|
||||
|
@ -36,12 +36,19 @@ jobs:
|
||||
arguments: '-buildTests'
|
||||
- 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'
|
||||
|
@ -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'
|
||||
|
@ -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",
|
||||
|
49
scripts/cmake/vcpkg_minimum_required.cmake
Normal file
49
scripts/cmake/vcpkg_minimum_required.cmake
Normal file
@ -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()
|
@ -0,0 +1,2 @@
|
||||
vcpkg_minimum_required(VERSION ${VCPKG_BASE_VERSION})
|
||||
set(VCPKG_POLICY_EMPTY_PACKAGE enabled)
|
@ -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": ""
|
||||
}
|
@ -0,0 +1,2 @@
|
||||
vcpkg_minimum_required(VERSION 2999-12-31)
|
||||
set(VCPKG_POLICY_EMPTY_PACKAGE enabled)
|
@ -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": ""
|
||||
}
|
@ -0,0 +1,2 @@
|
||||
vcpkg_minimum_required(VERSION 2020-01-12)
|
||||
set(VCPKG_POLICY_EMPTY_PACKAGE enabled)
|
@ -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": ""
|
||||
}
|
@ -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")
|
||||
|
||||
|
@ -77,10 +77,12 @@ if (VCPKG_EMBED_GIT_SHA)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (VCPKG_VERSION STREQUAL "")
|
||||
set(VCPKG_VERSION "nohash")
|
||||
if (NOT DEFINED VCPKG_VERSION OR VCPKG_VERSION STREQUAL "")
|
||||
set(VCPKG_VERSION "unknownhash")
|
||||
endif()
|
||||
|
||||
set(VCPKG_BASE_VERSION "2021-01-13")
|
||||
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
@ -115,7 +117,9 @@ target_include_directories(vcpkglib PUBLIC include)
|
||||
vcpkg_target_add_warning_options(vcpkglib)
|
||||
target_compile_definitions(vcpkglib PUBLIC
|
||||
VCPKG_USE_STD_FILESYSTEM=$<BOOL:${VCPKG_USE_STD_FILESYSTEM}>
|
||||
VCPKG_VERSION=${VCPKG_VERSION})
|
||||
VCPKG_VERSION=${VCPKG_VERSION}
|
||||
VCPKG_BASE_VERSION=${VCPKG_BASE_VERSION}
|
||||
)
|
||||
|
||||
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
||||
find_package(Threads REQUIRED)
|
||||
|
@ -1 +0,0 @@
|
||||
"2020.11.12"
|
@ -29,6 +29,7 @@
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
#include <iterator>
|
||||
#include <limits>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
|
41
toolsrc/include/vcpkg/base/basic_checks.h
Normal file
41
toolsrc/include/vcpkg/base/basic_checks.h
Normal file
@ -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);
|
||||
}
|
@ -1,29 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include <vcpkg/base/cstringview.h>
|
||||
#include <vcpkg/base/basic_checks.h>
|
||||
#include <vcpkg/base/strings.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]] inline void exit_fail(const LineInfo& line_info) { exit_with_code(line_info, EXIT_FAILURE); }
|
||||
|
||||
// Exit the tool successfully.
|
||||
[[noreturn]] inline void exit_success(const LineInfo& line_info) { exit_with_code(line_info, EXIT_SUCCESS); }
|
||||
|
||||
// Display an error message to the user and exit the tool.
|
||||
[[noreturn]] void exit_with_message(const LineInfo& line_info, StringView error_message);
|
||||
// Additional convenience overloads on top of basic_checks.h that do formatting.
|
||||
|
||||
template<class Arg1, class... Args>
|
||||
// Display an error message to the user and exit the tool.
|
||||
@ -36,10 +18,6 @@ namespace vcpkg::Checks
|
||||
Strings::format(error_message_template, error_message_arg1, error_message_args...));
|
||||
}
|
||||
|
||||
void check_exit(const LineInfo& line_info, bool expression);
|
||||
|
||||
void check_exit(const LineInfo& line_info, bool expression, StringView error_message);
|
||||
|
||||
template<class Conditional, class Arg1, class... Args>
|
||||
void check_exit(const LineInfo& line_info,
|
||||
Conditional&& expression,
|
||||
@ -54,4 +32,29 @@ namespace vcpkg::Checks
|
||||
Strings::format(error_message_template, error_message_arg1, error_message_args...));
|
||||
}
|
||||
}
|
||||
|
||||
template<class Arg1, class... Args>
|
||||
[[noreturn]] void exit_maybe_upgrade(const LineInfo& line_info,
|
||||
const char* error_message_template,
|
||||
const Arg1& error_message_arg1,
|
||||
const Args&... error_message_args)
|
||||
{
|
||||
exit_maybe_upgrade(line_info,
|
||||
Strings::format(error_message_template, error_message_arg1, error_message_args...));
|
||||
}
|
||||
|
||||
template<class Conditional, class Arg1, class... Args>
|
||||
void check_maybe_upgrade(const LineInfo& line_info,
|
||||
Conditional&& expression,
|
||||
const char* error_message_template,
|
||||
const Arg1& error_message_arg1,
|
||||
const Args&... error_message_args)
|
||||
{
|
||||
if (!expression)
|
||||
{
|
||||
// Only create the string if the expression is false
|
||||
exit_maybe_upgrade(line_info,
|
||||
Strings::format(error_message_template, error_message_arg1, error_message_args...));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -22,17 +22,17 @@ namespace vcpkg
|
||||
|
||||
namespace details
|
||||
{
|
||||
inline bool vcpkg_strcmp(const char* l, const char* r) { return strcmp(l, r) == 0; }
|
||||
inline bool strequal(const char* l, const char* r) { return strcmp(l, r) == 0; }
|
||||
}
|
||||
|
||||
inline bool operator==(const CStringView& l, const CStringView& r)
|
||||
{
|
||||
return details::vcpkg_strcmp(l.c_str(), r.c_str());
|
||||
return details::strequal(l.c_str(), r.c_str());
|
||||
}
|
||||
|
||||
inline bool operator==(const char* l, const CStringView& r) { return details::vcpkg_strcmp(l, r.c_str()); }
|
||||
inline bool operator==(const char* l, const CStringView& r) { return details::strequal(l, r.c_str()); }
|
||||
|
||||
inline bool operator==(const CStringView& r, const char* l) { return details::vcpkg_strcmp(l, r.c_str()); }
|
||||
inline bool operator==(const CStringView& r, const char* l) { return details::strequal(l, r.c_str()); }
|
||||
|
||||
inline bool operator==(const std::string& l, const CStringView& r) { return l == r.c_str(); }
|
||||
|
||||
@ -41,12 +41,12 @@ namespace vcpkg
|
||||
// notequals
|
||||
inline bool operator!=(const CStringView& l, const CStringView& r)
|
||||
{
|
||||
return !details::vcpkg_strcmp(l.c_str(), r.c_str());
|
||||
return !details::strequal(l.c_str(), r.c_str());
|
||||
}
|
||||
|
||||
inline bool operator!=(const char* l, const CStringView& r) { return !details::vcpkg_strcmp(l, r.c_str()); }
|
||||
inline bool operator!=(const char* l, const CStringView& r) { return !details::strequal(l, r.c_str()); }
|
||||
|
||||
inline bool operator!=(const CStringView& r, const char* l) { return !details::vcpkg_strcmp(l, r.c_str()); }
|
||||
inline bool operator!=(const CStringView& r, const char* l) { return !details::strequal(l, r.c_str()); }
|
||||
|
||||
inline bool operator!=(const CStringView& r, const std::string& l) { return l != r.c_str(); }
|
||||
|
||||
|
@ -1,8 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <vcpkg/base/fwd/lineinfo.h>
|
||||
|
||||
#include <vcpkg/base/cstringview.h>
|
||||
#include <vcpkg/base/lineinfo.h>
|
||||
|
||||
namespace vcpkg::Enums
|
||||
{
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include <vcpkg/base/checks.h>
|
||||
#include <vcpkg/base/lineinfo.h>
|
||||
#include <vcpkg/base/stringliteral.h>
|
||||
#include <vcpkg/base/system.print.h>
|
||||
|
||||
#include <system_error>
|
||||
#include <type_traits>
|
||||
@ -225,10 +226,10 @@ namespace vcpkg
|
||||
private:
|
||||
void exit_if_error(const LineInfo& line_info) const
|
||||
{
|
||||
// This is used for quick value_or_exit() calls, so always put line_info in the error message.
|
||||
if (m_s.has_error())
|
||||
{
|
||||
Checks::exit_with_message(line_info, "Failed at [%s] with message:\n%s", line_info, m_s.to_string());
|
||||
System::print2(System::Color::error, m_s.to_string(), "\n");
|
||||
Checks::unreachable(line_info);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
namespace vcpkg
|
||||
{
|
||||
struct LineInfo;
|
||||
}
|
@ -56,7 +56,7 @@ namespace vcpkg::Json
|
||||
{
|
||||
case Newline::Lf: return "\n";
|
||||
case Newline::CrLf: return "\r\n";
|
||||
default: Checks::exit_fail(VCPKG_LINE_INFO);
|
||||
default: Checks::unreachable(VCPKG_LINE_INFO);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,21 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace vcpkg
|
||||
{
|
||||
struct LineInfo
|
||||
{
|
||||
constexpr LineInfo() noexcept : m_line_number(0), m_file_name("") { }
|
||||
constexpr LineInfo(const int lineno, const char* filename) : m_line_number(lineno), m_file_name(filename) { }
|
||||
|
||||
std::string to_string() const;
|
||||
void to_string(std::string& out) const;
|
||||
|
||||
private:
|
||||
int m_line_number;
|
||||
const char* m_file_name;
|
||||
int line_number;
|
||||
const char* file_name;
|
||||
};
|
||||
}
|
||||
|
||||
#define VCPKG_LINE_INFO vcpkg::LineInfo(__LINE__, __FILE__)
|
||||
#define VCPKG_LINE_INFO \
|
||||
vcpkg::LineInfo { __LINE__, __FILE__ }
|
||||
|
@ -1,8 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include <vcpkg/base/fwd/lineinfo.h>
|
||||
#include <vcpkg/base/fwd/optional.h>
|
||||
|
||||
#include <vcpkg/base/basic_checks.h>
|
||||
#include <vcpkg/base/lineinfo.h>
|
||||
#include <vcpkg/base/pragmas.h>
|
||||
|
||||
#include <type_traits>
|
||||
@ -217,9 +218,6 @@ namespace vcpkg
|
||||
private:
|
||||
const T* m_t;
|
||||
};
|
||||
|
||||
// Note: implemented in checks.cpp to cut the header dependency
|
||||
void exit_if_null(bool b, const LineInfo& line_info);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
@ -237,19 +235,19 @@ namespace vcpkg
|
||||
|
||||
T&& value_or_exit(const LineInfo& line_info) &&
|
||||
{
|
||||
details::exit_if_null(this->m_base.has_value(), line_info);
|
||||
Checks::check_exit(line_info, this->m_base.has_value(), "Value was null");
|
||||
return std::move(this->m_base.value());
|
||||
}
|
||||
|
||||
T& value_or_exit(const LineInfo& line_info) &
|
||||
{
|
||||
details::exit_if_null(this->m_base.has_value(), line_info);
|
||||
Checks::check_exit(line_info, this->m_base.has_value(), "Value was null");
|
||||
return this->m_base.value();
|
||||
}
|
||||
|
||||
const T& value_or_exit(const LineInfo& line_info) const&
|
||||
{
|
||||
details::exit_if_null(this->m_base.has_value(), line_info);
|
||||
Checks::check_exit(line_info, this->m_base.has_value(), "Value was null");
|
||||
return this->m_base.value();
|
||||
}
|
||||
|
||||
|
@ -2,28 +2,16 @@
|
||||
|
||||
#include <vcpkg/base/fwd/stringview.h>
|
||||
|
||||
#include <vcpkg/base/optional.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include <iterator>
|
||||
#include <limits>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace vcpkg
|
||||
{
|
||||
struct StringView
|
||||
{
|
||||
static std::vector<StringView> find_all_enclosed(const StringView& input,
|
||||
const std::string& left_delim,
|
||||
const std::string& right_delim) noexcept;
|
||||
|
||||
static StringView find_exactly_one_enclosed(const StringView& input,
|
||||
const std::string& left_tag,
|
||||
const std::string& right_tag) noexcept;
|
||||
|
||||
static Optional<StringView> find_at_most_one_enclosed(const StringView& input,
|
||||
const std::string& left_tag,
|
||||
const std::string& right_tag) noexcept;
|
||||
|
||||
constexpr StringView() = default;
|
||||
StringView(const std::string& s) noexcept; // Implicit by design
|
||||
|
||||
|
@ -10,12 +10,6 @@ namespace vcpkg::Debug
|
||||
{
|
||||
extern std::atomic<bool> g_debugging;
|
||||
|
||||
template<class... Args>
|
||||
void print(System::Color c, const Args&... args)
|
||||
{
|
||||
if (g_debugging) System::print2(c, "[DEBUG] ", args...);
|
||||
}
|
||||
|
||||
template<class... Args>
|
||||
void print(const Args&... args)
|
||||
{
|
||||
|
@ -4,9 +4,8 @@
|
||||
|
||||
namespace vcpkg::Commands::Version
|
||||
{
|
||||
const char* base_version();
|
||||
const char* version();
|
||||
void warn_if_vcpkg_version_mismatch(const VcpkgPaths& paths);
|
||||
const char* base_version() noexcept;
|
||||
const char* version() noexcept;
|
||||
void perform_and_exit(const VcpkgCmdArguments& args, Files::Filesystem& fs);
|
||||
|
||||
struct VersionCommand : BasicCommand
|
||||
|
@ -189,6 +189,6 @@ int main(int argc, char** argv)
|
||||
case FuzzKind::JsonParser: fuzz_json_and_exit(text);
|
||||
case FuzzKind::Utf8Decoder: fuzz_utf8_and_exit(text);
|
||||
case FuzzKind::PlatformExpr: fuzz_platform_expr_and_exit(text);
|
||||
default: Checks::exit_fail(VCPKG_LINE_INFO);
|
||||
default: Checks::unreachable(VCPKG_LINE_INFO);
|
||||
}
|
||||
}
|
||||
|
@ -79,12 +79,6 @@ static void inner(vcpkg::Files::Filesystem& fs, const VcpkgCmdArguments& args)
|
||||
paths.track_feature_flag_metrics();
|
||||
|
||||
fs.current_path(paths.root, VCPKG_LINE_INFO);
|
||||
if ((args.command == "install" || args.command == "remove" || args.command == "export" ||
|
||||
args.command == "update") &&
|
||||
!args.output_json())
|
||||
{
|
||||
Commands::Version::warn_if_vcpkg_version_mismatch(paths);
|
||||
}
|
||||
|
||||
if (const auto command_function = find_command(Commands::get_available_paths_commands()))
|
||||
{
|
||||
|
@ -101,7 +101,7 @@ namespace vcpkg::Archives
|
||||
}
|
||||
else
|
||||
{
|
||||
Checks::exit_with_message(VCPKG_LINE_INFO, "Unexpected archive extension: %s", fs::u8string(ext));
|
||||
Checks::exit_maybe_upgrade(VCPKG_LINE_INFO, "Unexpected archive extension: %s", fs::u8string(ext));
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -2,9 +2,12 @@
|
||||
#include <vcpkg/base/stringview.h>
|
||||
#include <vcpkg/base/system.debug.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
namespace vcpkg
|
||||
{
|
||||
static void (*g_shutdown_handler)() = nullptr;
|
||||
|
||||
void Checks::register_global_shutdown_handler(void (*func)())
|
||||
{
|
||||
if (g_shutdown_handler)
|
||||
@ -21,7 +24,7 @@ namespace vcpkg
|
||||
#if defined(_WIN32)
|
||||
::TerminateProcess(::GetCurrentProcess(), exit_code);
|
||||
#else
|
||||
std::terminate();
|
||||
std::abort();
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -37,8 +40,10 @@ namespace vcpkg
|
||||
|
||||
[[noreturn]] void Checks::unreachable(const LineInfo& line_info)
|
||||
{
|
||||
System::print2(System::Color::error, "Error: Unreachable code was reached\n");
|
||||
System::print2(System::Color::error, line_info, '\n'); // Always print line_info here
|
||||
System::printf(System::Color::error,
|
||||
"Error: Unreachable code was reached\n%s(%d)\n",
|
||||
line_info.file_name,
|
||||
line_info.line_number);
|
||||
#ifndef NDEBUG
|
||||
std::abort();
|
||||
#else
|
||||
@ -48,10 +53,14 @@ namespace vcpkg
|
||||
|
||||
[[noreturn]] void Checks::exit_with_code(const LineInfo& line_info, const int exit_code)
|
||||
{
|
||||
Debug::print(System::Color::error, line_info, '\n');
|
||||
Debug::print(Strings::format("%s(%d)\n", line_info.file_name, line_info.line_number));
|
||||
final_cleanup_and_exit(exit_code);
|
||||
}
|
||||
|
||||
[[noreturn]] void Checks::exit_fail(const LineInfo& line_info) { exit_with_code(line_info, EXIT_FAILURE); }
|
||||
|
||||
[[noreturn]] void Checks::exit_success(const LineInfo& line_info) { exit_with_code(line_info, EXIT_SUCCESS); }
|
||||
|
||||
[[noreturn]] void Checks::exit_with_message(const LineInfo& line_info, StringView error_message)
|
||||
{
|
||||
System::print2(System::Color::error, error_message, '\n');
|
||||
@ -74,19 +83,38 @@ namespace vcpkg
|
||||
}
|
||||
}
|
||||
|
||||
std::string LineInfo::to_string() const
|
||||
static void display_upgrade_message()
|
||||
{
|
||||
std::string ret;
|
||||
this->to_string(ret);
|
||||
return ret;
|
||||
System::print2(System::Color::error,
|
||||
"Note: Updating vcpkg by rerunning bootstrap-vcpkg may resolve this failure.\n");
|
||||
}
|
||||
void LineInfo::to_string(std::string& out) const
|
||||
|
||||
[[noreturn]] void Checks::exit_maybe_upgrade(const LineInfo& line_info)
|
||||
{
|
||||
out += m_file_name;
|
||||
Strings::append(out, '(', m_line_number, ')');
|
||||
display_upgrade_message();
|
||||
exit_fail(line_info);
|
||||
}
|
||||
namespace details
|
||||
|
||||
[[noreturn]] void Checks::exit_maybe_upgrade(const LineInfo& line_info, StringView error_message)
|
||||
{
|
||||
void exit_if_null(bool b, const LineInfo& line_info) { Checks::check_exit(line_info, b, "Value was null"); }
|
||||
System::print2(System::Color::error, error_message, '\n');
|
||||
display_upgrade_message();
|
||||
exit_fail(line_info);
|
||||
}
|
||||
|
||||
void Checks::check_maybe_upgrade(const LineInfo& line_info, bool expression)
|
||||
{
|
||||
if (!expression)
|
||||
{
|
||||
exit_maybe_upgrade(line_info);
|
||||
}
|
||||
}
|
||||
|
||||
void Checks::check_maybe_upgrade(const LineInfo& line_info, bool expression, StringView error_message)
|
||||
{
|
||||
if (!expression)
|
||||
{
|
||||
exit_maybe_upgrade(line_info, error_message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -462,6 +462,6 @@ namespace vcpkg::Downloads
|
||||
fs.rename(download_path_part_path, download_path, VCPKG_LINE_INFO);
|
||||
return url;
|
||||
}
|
||||
Checks::exit_with_message(VCPKG_LINE_INFO, "Failed to download from mirror set:\n%s", errors);
|
||||
Checks::exit_with_message(VCPKG_LINE_INFO, Strings::concat("Failed to download from mirror set:\n", errors));
|
||||
}
|
||||
}
|
||||
|
@ -459,39 +459,52 @@ namespace vcpkg::Files
|
||||
{
|
||||
auto maybe_contents = this->read_contents(path);
|
||||
if (auto p = maybe_contents.get())
|
||||
{
|
||||
return std::move(*p);
|
||||
else
|
||||
Checks::exit_with_message(
|
||||
linfo, "error reading file: %s: %s", fs::u8string(path), maybe_contents.error().message());
|
||||
}
|
||||
|
||||
Checks::exit_with_message(
|
||||
linfo, "error reading file: %s: %s", fs::u8string(path), maybe_contents.error().message());
|
||||
}
|
||||
void Filesystem::write_contents(const fs::path& path, const std::string& data, LineInfo linfo)
|
||||
{
|
||||
std::error_code ec;
|
||||
this->write_contents(path, data, ec);
|
||||
if (ec) Checks::exit_with_message(linfo, "error writing file: %s: %s", fs::u8string(path), ec.message());
|
||||
if (ec)
|
||||
{
|
||||
Checks::exit_with_message(linfo, "error writing file: %s: %s", fs::u8string(path), ec.message());
|
||||
}
|
||||
}
|
||||
void Filesystem::write_contents_and_dirs(const fs::path& path, const std::string& data, LineInfo linfo)
|
||||
{
|
||||
std::error_code ec;
|
||||
this->write_contents_and_dirs(path, data, ec);
|
||||
if (ec)
|
||||
{
|
||||
Checks::exit_with_message(
|
||||
linfo, "error writing file and creating directories: %s: %s", fs::u8string(path), ec.message());
|
||||
}
|
||||
}
|
||||
void Filesystem::rename(const fs::path& oldpath, const fs::path& newpath, LineInfo linfo)
|
||||
{
|
||||
std::error_code ec;
|
||||
this->rename(oldpath, newpath, ec);
|
||||
if (ec)
|
||||
{
|
||||
Checks::exit_with_message(
|
||||
linfo, "error renaming file: %s: %s: %s", fs::u8string(oldpath), fs::u8string(newpath), ec.message());
|
||||
}
|
||||
}
|
||||
|
||||
bool Filesystem::remove(const fs::path& path, LineInfo linfo)
|
||||
{
|
||||
std::error_code ec;
|
||||
auto r = this->remove(path, ec);
|
||||
if (ec) Checks::exit_with_message(linfo, "error removing file: %s: %s", fs::u8string(path), ec.message());
|
||||
if (ec)
|
||||
{
|
||||
Checks::exit_with_message(linfo, "error removing file: %s: %s", fs::u8string(path), ec.message());
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
@ -562,15 +575,20 @@ namespace vcpkg::Files
|
||||
std::error_code ec;
|
||||
this->copy_file(oldpath, newpath, opts, ec);
|
||||
if (ec)
|
||||
{
|
||||
vcpkg::Checks::exit_with_message(
|
||||
li, "error copying file from %s to %s: %s", fs::u8string(oldpath), fs::u8string(newpath), ec.message());
|
||||
}
|
||||
}
|
||||
|
||||
fs::file_status Filesystem::status(vcpkg::LineInfo li, const fs::path& p) const noexcept
|
||||
{
|
||||
std::error_code ec;
|
||||
auto result = this->status(p, ec);
|
||||
if (ec) vcpkg::Checks::exit_with_message(li, "error getting status of path %s: %s", p.string(), ec.message());
|
||||
if (ec)
|
||||
{
|
||||
vcpkg::Checks::exit_with_message(li, "error getting status of path %s: %s", p.string(), ec.message());
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -585,7 +603,10 @@ namespace vcpkg::Files
|
||||
{
|
||||
std::error_code ec;
|
||||
auto result = this->symlink_status(p, ec);
|
||||
if (ec) vcpkg::Checks::exit_with_message(li, "error getting status of path %s: %s", p.string(), ec.message());
|
||||
if (ec)
|
||||
{
|
||||
vcpkg::Checks::exit_with_message(li, "error getting status of path %s: %s", p.string(), ec.message());
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -600,7 +621,10 @@ namespace vcpkg::Files
|
||||
{
|
||||
std::error_code ec;
|
||||
this->write_lines(path, lines, ec);
|
||||
if (ec) Checks::exit_with_message(linfo, "error writing lines: %s: %s", fs::u8string(path), ec.message());
|
||||
if (ec)
|
||||
{
|
||||
Checks::exit_with_message(linfo, "error writing lines: %s: %s", fs::u8string(path), ec.message());
|
||||
}
|
||||
}
|
||||
|
||||
void Filesystem::remove_all(const fs::path& path, LineInfo li)
|
||||
@ -657,17 +681,23 @@ namespace vcpkg::Files
|
||||
{
|
||||
std::error_code ec;
|
||||
const auto result = this->absolute(path, ec);
|
||||
if (ec) Checks::exit_with_message(li, "Error getting absolute path of %s: %s", path.string(), ec.message());
|
||||
if (ec)
|
||||
{
|
||||
Checks::exit_with_message(li, "Error getting absolute path of %s: %s", path.string(), ec.message());
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
fs::path Filesystem::canonical(LineInfo li, const fs::path& path) const
|
||||
{
|
||||
std::error_code ec;
|
||||
|
||||
const auto result = this->canonical(path, ec);
|
||||
if (ec)
|
||||
{
|
||||
Checks::exit_with_message(li, "Error getting canonicalization of %s: %s", path.string(), ec.message());
|
||||
}
|
||||
|
||||
if (ec) Checks::exit_with_message(li, "Error getting canonicalization of %s: %s", path.string(), ec.message());
|
||||
return result;
|
||||
}
|
||||
fs::path Filesystem::canonical(const fs::path& path, ignore_errors_t) const
|
||||
@ -679,15 +709,21 @@ namespace vcpkg::Files
|
||||
{
|
||||
std::error_code ec;
|
||||
const auto result = this->current_path(ec);
|
||||
if (ec)
|
||||
{
|
||||
Checks::exit_with_message(li, "Error getting current path: %s", ec.message());
|
||||
}
|
||||
|
||||
if (ec) Checks::exit_with_message(li, "Error getting current path: %s", ec.message());
|
||||
return result;
|
||||
}
|
||||
void Filesystem::current_path(const fs::path& path, LineInfo li)
|
||||
{
|
||||
std::error_code ec;
|
||||
this->current_path(path, ec);
|
||||
if (ec) Checks::exit_with_message(li, "Error setting current path: %s", ec.message());
|
||||
if (ec)
|
||||
{
|
||||
Checks::exit_with_message(li, "Error setting current path: %s", ec.message());
|
||||
}
|
||||
}
|
||||
|
||||
struct RealFilesystem final : Filesystem
|
||||
@ -712,7 +748,6 @@ namespace vcpkg::Files
|
||||
std::string output;
|
||||
output.resize(static_cast<size_t>(length));
|
||||
file_stream.read(&output[0], length);
|
||||
file_stream.close();
|
||||
|
||||
return output;
|
||||
}
|
||||
@ -734,7 +769,6 @@ namespace vcpkg::Files
|
||||
|
||||
output.push_back(line);
|
||||
}
|
||||
file_stream.close();
|
||||
|
||||
return output;
|
||||
}
|
||||
@ -813,22 +847,24 @@ namespace vcpkg::Files
|
||||
std::error_code& ec) override
|
||||
{
|
||||
std::fstream output(file_path, std::ios_base::out | std::ios_base::binary | std::ios_base::trunc);
|
||||
if (!output)
|
||||
auto first = lines.begin();
|
||||
const auto last = lines.end();
|
||||
for (;;)
|
||||
{
|
||||
ec.assign(errno, std::generic_category());
|
||||
return;
|
||||
}
|
||||
for (const std::string& line : lines)
|
||||
{
|
||||
output << line << "\n";
|
||||
if (!output)
|
||||
{
|
||||
output.close();
|
||||
ec.assign(errno, std::generic_category());
|
||||
ec.assign(static_cast<int>(std::errc::io_error), std::generic_category());
|
||||
return;
|
||||
}
|
||||
|
||||
if (first == last)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
output << *first << "\n";
|
||||
++first;
|
||||
}
|
||||
output.close();
|
||||
}
|
||||
virtual void rename(const fs::path& oldpath, const fs::path& newpath, std::error_code& ec) override
|
||||
{
|
||||
|
@ -122,7 +122,7 @@ namespace vcpkg::Hash
|
||||
case Algorithm::Sha1: alg_handle = sha1_alg_handle; break;
|
||||
case Algorithm::Sha256: alg_handle = sha256_alg_handle; break;
|
||||
case Algorithm::Sha512: alg_handle = sha512_alg_handle; break;
|
||||
default: Checks::exit_with_message(VCPKG_LINE_INFO, "Unknown algorithm");
|
||||
default: Checks::unreachable(VCPKG_LINE_INFO);
|
||||
}
|
||||
|
||||
clear();
|
||||
|
@ -33,7 +33,7 @@ namespace vcpkg
|
||||
case MachineType::SH5:
|
||||
case MachineType::THUMB:
|
||||
case MachineType::WCEMIPSV2: return t;
|
||||
default: Checks::exit_with_message(VCPKG_LINE_INFO, "Unknown machine type code 0x%hx", value);
|
||||
default: Checks::exit_maybe_upgrade(VCPKG_LINE_INFO, "Unknown machine type code 0x%hx", value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,15 @@
|
||||
#include <vcpkg/base/strings.h>
|
||||
#include <vcpkg/base/util.h>
|
||||
|
||||
#include <locale.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <locale>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace vcpkg::Strings::details
|
||||
{
|
||||
// To disambiguate between two overloads
|
||||
@ -237,26 +246,26 @@ std::vector<StringView> Strings::find_all_enclosed(StringView input, StringView
|
||||
StringView Strings::find_exactly_one_enclosed(StringView input, StringView left_tag, StringView right_tag)
|
||||
{
|
||||
std::vector<StringView> result = find_all_enclosed(input, left_tag, right_tag);
|
||||
Checks::check_exit(VCPKG_LINE_INFO,
|
||||
result.size() == 1,
|
||||
"Found %d sets of %s.*%s but expected exactly 1, in block:\n%s",
|
||||
result.size(),
|
||||
left_tag,
|
||||
right_tag,
|
||||
input);
|
||||
Checks::check_maybe_upgrade(VCPKG_LINE_INFO,
|
||||
result.size() == 1,
|
||||
"Found %d sets of %s.*%s but expected exactly 1, in block:\n%s",
|
||||
result.size(),
|
||||
left_tag,
|
||||
right_tag,
|
||||
input);
|
||||
return result.front();
|
||||
}
|
||||
|
||||
Optional<StringView> Strings::find_at_most_one_enclosed(StringView input, StringView left_tag, StringView right_tag)
|
||||
{
|
||||
std::vector<StringView> result = find_all_enclosed(input, left_tag, right_tag);
|
||||
Checks::check_exit(VCPKG_LINE_INFO,
|
||||
result.size() <= 1,
|
||||
"Found %d sets of %s.*%s but expected at most 1, in block:\n%s",
|
||||
result.size(),
|
||||
left_tag,
|
||||
right_tag,
|
||||
input);
|
||||
Checks::check_maybe_upgrade(VCPKG_LINE_INFO,
|
||||
result.size() <= 1,
|
||||
"Found %d sets of %s.*%s but expected at most 1, in block:\n%s",
|
||||
result.size(),
|
||||
left_tag,
|
||||
right_tag,
|
||||
input);
|
||||
|
||||
if (result.empty())
|
||||
{
|
||||
|
@ -2,73 +2,11 @@
|
||||
#include <vcpkg/base/lineinfo.h>
|
||||
#include <vcpkg/base/stringview.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
|
||||
namespace vcpkg
|
||||
{
|
||||
std::vector<StringView> StringView::find_all_enclosed(const StringView& input,
|
||||
const std::string& left_delim,
|
||||
const std::string& right_delim) noexcept
|
||||
{
|
||||
auto it_left = input.begin();
|
||||
auto it_right = input.begin();
|
||||
|
||||
std::vector<StringView> output;
|
||||
|
||||
while (true)
|
||||
{
|
||||
it_left = std::search(it_right, input.end(), left_delim.cbegin(), left_delim.cend());
|
||||
if (it_left == input.end()) break;
|
||||
|
||||
it_left += left_delim.length();
|
||||
|
||||
it_right = std::search(it_left, input.end(), right_delim.cbegin(), right_delim.cend());
|
||||
if (it_right == input.end()) break;
|
||||
|
||||
output.emplace_back(it_left, it_right);
|
||||
|
||||
++it_right;
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
StringView StringView::find_exactly_one_enclosed(const StringView& input,
|
||||
const std::string& left_tag,
|
||||
const std::string& right_tag) noexcept
|
||||
{
|
||||
std::vector<StringView> result = find_all_enclosed(input, left_tag, right_tag);
|
||||
Checks::check_exit(VCPKG_LINE_INFO,
|
||||
result.size() == 1,
|
||||
"Found %d sets of %s.*%s but expected exactly 1, in block:\n%s",
|
||||
result.size(),
|
||||
left_tag,
|
||||
right_tag,
|
||||
input);
|
||||
return result.front();
|
||||
}
|
||||
|
||||
Optional<StringView> StringView::find_at_most_one_enclosed(const StringView& input,
|
||||
const std::string& left_tag,
|
||||
const std::string& right_tag) noexcept
|
||||
{
|
||||
std::vector<StringView> result = find_all_enclosed(input, left_tag, right_tag);
|
||||
Checks::check_exit(VCPKG_LINE_INFO,
|
||||
result.size() <= 1,
|
||||
"Found %d sets of %s.*%s but expected at most 1, in block:\n%s",
|
||||
result.size(),
|
||||
left_tag,
|
||||
right_tag,
|
||||
input);
|
||||
|
||||
if (result.empty())
|
||||
{
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
return result.front();
|
||||
}
|
||||
|
||||
StringView::StringView(const std::string& s) noexcept : m_ptr(s.data()), m_size(s.size()) { }
|
||||
|
||||
std::string StringView::to_string() const { return std::string(m_ptr, m_size); }
|
||||
|
@ -39,7 +39,7 @@ namespace vcpkg
|
||||
case CPUArchitecture::ARM: return "arm";
|
||||
case CPUArchitecture::ARM64: return "arm64";
|
||||
case CPUArchitecture::S390X: return "s390x";
|
||||
default: Checks::exit_with_message(VCPKG_LINE_INFO, "unexpected vcpkg::System::CPUArchitecture");
|
||||
default: Checks::unreachable(VCPKG_LINE_INFO);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -242,23 +242,23 @@ namespace vcpkg
|
||||
out_str.substr(initial_end), "vcpkg::serialize(const BinaryParagraph&, std::string&)");
|
||||
if (!parsed_paragraph.has_value())
|
||||
{
|
||||
Checks::exit_with_message(VCPKG_LINE_INFO,
|
||||
R"([sanity check] Failed to parse a serialized binary paragraph.
|
||||
Checks::exit_maybe_upgrade(VCPKG_LINE_INFO,
|
||||
R"([sanity check] Failed to parse a serialized binary paragraph.
|
||||
Please open an issue at https://github.com/microsoft/vcpkg, with the following output:
|
||||
Error: %s
|
||||
|
||||
=== Serialized BinaryParagraph ===
|
||||
%s
|
||||
)",
|
||||
parsed_paragraph.error(),
|
||||
my_paragraph);
|
||||
parsed_paragraph.error(),
|
||||
my_paragraph);
|
||||
}
|
||||
|
||||
auto binary_paragraph = BinaryParagraph(*parsed_paragraph.get());
|
||||
if (binary_paragraph != pgh)
|
||||
{
|
||||
const auto& join_str = R"(", ")";
|
||||
Checks::exit_with_message(
|
||||
Checks::exit_maybe_upgrade(
|
||||
VCPKG_LINE_INFO,
|
||||
R"([sanity check] The serialized binary paragraph was different from the original binary paragraph.
|
||||
Please open an issue at https://github.com/microsoft/vcpkg, with the following output:
|
||||
|
@ -104,11 +104,12 @@ namespace vcpkg::Build
|
||||
const PackageSpec& spec = full_spec.package_spec;
|
||||
const SourceControlFile& scf = *scfl.source_control_file;
|
||||
|
||||
Checks::check_exit(VCPKG_LINE_INFO,
|
||||
spec.name() == scf.core_paragraph->name,
|
||||
"The Source field inside the CONTROL file does not match the port directory: '%s' != '%s'",
|
||||
scf.core_paragraph->name,
|
||||
spec.name());
|
||||
Checks::check_maybe_upgrade(
|
||||
VCPKG_LINE_INFO,
|
||||
spec.name() == scf.core_paragraph->name,
|
||||
Strings::format("The Source field inside the CONTROL file does not match the port directory: '%s' != '%s'",
|
||||
scf.core_paragraph->name,
|
||||
spec.name()));
|
||||
|
||||
compute_all_abis(paths, action_plan, var_provider, status_db);
|
||||
|
||||
@ -181,7 +182,7 @@ namespace vcpkg::Build
|
||||
const auto port_name = spec.package_spec.name();
|
||||
const auto* scfl = provider.get_control_file(port_name).get();
|
||||
|
||||
Checks::check_exit(VCPKG_LINE_INFO, scfl != nullptr, "Error: Couldn't find port '%s'", port_name);
|
||||
Checks::check_maybe_upgrade(VCPKG_LINE_INFO, scfl != nullptr, "Error: Couldn't find port '%s'", port_name);
|
||||
ASSUME(scfl != nullptr);
|
||||
|
||||
return perform_ex(args,
|
||||
@ -298,13 +299,13 @@ namespace vcpkg::Build
|
||||
if (cmake_system_name == "Windows") return "";
|
||||
if (cmake_system_name == "WindowsStore") return "store";
|
||||
|
||||
Checks::exit_with_message(VCPKG_LINE_INFO, "Unsupported vcvarsall target %s", cmake_system_name);
|
||||
Checks::exit_maybe_upgrade(VCPKG_LINE_INFO, "Unsupported vcvarsall target %s", cmake_system_name);
|
||||
}
|
||||
|
||||
static CStringView to_vcvarsall_toolchain(const std::string& target_architecture, const Toolset& toolset)
|
||||
{
|
||||
auto maybe_target_arch = System::to_cpu_architecture(target_architecture);
|
||||
Checks::check_exit(
|
||||
Checks::check_maybe_upgrade(
|
||||
VCPKG_LINE_INFO, maybe_target_arch.has_value(), "Invalid architecture string: %s", target_architecture);
|
||||
auto target_arch = maybe_target_arch.value_or_exit(VCPKG_LINE_INFO);
|
||||
auto host_architectures = System::get_supported_host_architectures();
|
||||
@ -317,12 +318,12 @@ namespace vcpkg::Build
|
||||
if (it != toolset.supported_architectures.end()) return it->name;
|
||||
}
|
||||
|
||||
Checks::exit_with_message(VCPKG_LINE_INFO,
|
||||
"Unsupported toolchain combination. Target was: %s but supported ones were:\n%s",
|
||||
target_architecture,
|
||||
Strings::join(",", toolset.supported_architectures, [](const ToolsetArchOption& t) {
|
||||
return t.name.c_str();
|
||||
}));
|
||||
Checks::exit_maybe_upgrade(VCPKG_LINE_INFO,
|
||||
"Unsupported toolchain combination. Target was: %s but supported ones were:\n%s",
|
||||
target_architecture,
|
||||
Strings::join(",", toolset.supported_architectures, [](const ToolsetArchOption& t) {
|
||||
return t.name.c_str();
|
||||
}));
|
||||
}
|
||||
|
||||
#if defined(_WIN32)
|
||||
@ -515,11 +516,12 @@ namespace vcpkg::Build
|
||||
Util::Vectors::append(&out_vars,
|
||||
std::initializer_list<System::CMakeVariable>{
|
||||
{"CMD", "BUILD"},
|
||||
{"DOWNLOADS", paths.downloads},
|
||||
{"TARGET_TRIPLET", triplet.canonical_name()},
|
||||
{"TARGET_TRIPLET_FILE", fs::u8string(paths.get_triplet_file_path(triplet))},
|
||||
{"VCPKG_PLATFORM_TOOLSET", toolset.version.c_str()},
|
||||
{"DOWNLOADS", paths.downloads},
|
||||
{"VCPKG_BASE_VERSION", Commands::Version::base_version()},
|
||||
{"VCPKG_CONCURRENCY", std::to_string(get_concurrency())},
|
||||
{"VCPKG_PLATFORM_TOOLSET", toolset.version.c_str()},
|
||||
});
|
||||
if (!System::get_environment_variable("VCPKG_FORCE_SYSTEM_BINARIES").has_value())
|
||||
{
|
||||
@ -626,14 +628,14 @@ namespace vcpkg::Build
|
||||
}
|
||||
|
||||
std::vector<System::CMakeVariable> variables{
|
||||
{"PORT", scf.core_paragraph->name},
|
||||
{"ALL_FEATURES", all_features},
|
||||
{"CURRENT_PORT_DIR", scfl.source_location},
|
||||
{"FEATURES", Strings::join(";", action.feature_list)},
|
||||
{"PORT", scf.core_paragraph->name},
|
||||
{"VCPKG_USE_HEAD_VERSION", Util::Enum::to_bool(action.build_options.use_head_version) ? "1" : "0"},
|
||||
{"_VCPKG_NO_DOWNLOADS", !Util::Enum::to_bool(action.build_options.allow_downloads) ? "1" : "0"},
|
||||
{"_VCPKG_DOWNLOAD_TOOL", to_string(action.build_options.download_tool)},
|
||||
{"_VCPKG_EDITABLE", Util::Enum::to_bool(action.build_options.editable) ? "1" : "0"},
|
||||
{"FEATURES", Strings::join(";", action.feature_list)},
|
||||
{"ALL_FEATURES", all_features},
|
||||
{"_VCPKG_NO_DOWNLOADS", !Util::Enum::to_bool(action.build_options.allow_downloads) ? "1" : "0"},
|
||||
};
|
||||
|
||||
for (auto cmake_arg : args.cmake_args)
|
||||
@ -726,10 +728,11 @@ namespace vcpkg::Build
|
||||
}
|
||||
else
|
||||
{
|
||||
Checks::exit_with_message(VCPKG_LINE_INFO,
|
||||
"Unable to determine toolchain to use for triplet %s with CMAKE_SYSTEM_NAME %s",
|
||||
triplet,
|
||||
cmake_system_name);
|
||||
Checks::exit_maybe_upgrade(VCPKG_LINE_INFO,
|
||||
"Unable to determine toolchain to use for triplet %s with CMAKE_SYSTEM_NAME %s; "
|
||||
"maybe you meant to use VCPKG_CHAINLOAD_TOOLCHAIN_FILE?",
|
||||
triplet,
|
||||
cmake_system_name);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1061,13 +1064,11 @@ namespace vcpkg::Build
|
||||
auto status_it = status_db.find(pspec);
|
||||
if (status_it == status_db.end())
|
||||
{
|
||||
Checks::exit_with_message(
|
||||
Checks::exit_maybe_upgrade(
|
||||
VCPKG_LINE_INFO, "Failed to find dependency abi for %s -> %s", action.spec, pspec);
|
||||
}
|
||||
else
|
||||
{
|
||||
dependency_abis.emplace_back(AbiEntry{pspec.name(), status_it->get()->package.abi});
|
||||
}
|
||||
|
||||
dependency_abis.emplace_back(AbiEntry{pspec.name(), status_it->get()->package.abi});
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1248,9 +1249,13 @@ namespace vcpkg::Build
|
||||
|
||||
auto crtlinkage = to_linkage_type(crt_linkage_as_string);
|
||||
if (const auto p = crtlinkage.get())
|
||||
{
|
||||
build_info.crt_linkage = *p;
|
||||
}
|
||||
else
|
||||
{
|
||||
Checks::exit_with_message(VCPKG_LINE_INFO, "Invalid crt linkage type: [%s]", crt_linkage_as_string);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
@ -1258,11 +1263,16 @@ namespace vcpkg::Build
|
||||
parser.required_field(BuildInfoRequiredField::LIBRARY_LINKAGE, library_linkage_as_string);
|
||||
auto liblinkage = to_linkage_type(library_linkage_as_string);
|
||||
if (const auto p = liblinkage.get())
|
||||
{
|
||||
build_info.library_linkage = *p;
|
||||
}
|
||||
else
|
||||
{
|
||||
Checks::exit_with_message(
|
||||
VCPKG_LINE_INFO, "Invalid library linkage type: [%s]", library_linkage_as_string);
|
||||
}
|
||||
}
|
||||
|
||||
std::string version = parser.optional_field("Version");
|
||||
if (!version.empty()) build_info.version = std::move(version);
|
||||
|
||||
@ -1276,7 +1286,7 @@ namespace vcpkg::Build
|
||||
else if (setting == "disabled")
|
||||
policies.emplace(policy, false);
|
||||
else
|
||||
Checks::exit_with_message(
|
||||
Checks::exit_maybe_upgrade(
|
||||
VCPKG_LINE_INFO, "Unknown setting for policy '%s': %s", to_string(policy), setting);
|
||||
}
|
||||
|
||||
@ -1294,7 +1304,7 @@ namespace vcpkg::Build
|
||||
BuildInfo read_build_info(const Files::Filesystem& fs, const fs::path& filepath)
|
||||
{
|
||||
const ExpectedS<Parse::Paragraph> pghs = Paragraphs::get_single_paragraph(fs, filepath);
|
||||
Checks::check_exit(
|
||||
Checks::check_maybe_upgrade(
|
||||
VCPKG_LINE_INFO, pghs.get() != nullptr, "Invalid BUILD_INFO file for package: %s", pghs.error());
|
||||
return inner_create_buildinfo(*pghs.get());
|
||||
}
|
||||
@ -1394,16 +1404,22 @@ namespace vcpkg::Build
|
||||
else if (Strings::case_insensitive_ascii_equals(variable_value, "1") ||
|
||||
Strings::case_insensitive_ascii_equals(variable_value, "on") ||
|
||||
Strings::case_insensitive_ascii_equals(variable_value, "true"))
|
||||
{
|
||||
load_vcvars_env = true;
|
||||
}
|
||||
else if (Strings::case_insensitive_ascii_equals(variable_value, "0") ||
|
||||
Strings::case_insensitive_ascii_equals(variable_value, "off") ||
|
||||
Strings::case_insensitive_ascii_equals(variable_value, "false"))
|
||||
{
|
||||
load_vcvars_env = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
Checks::exit_with_message(VCPKG_LINE_INFO,
|
||||
"Unknown boolean setting for VCPKG_LOAD_VCVARS_ENV: %s. Valid "
|
||||
"settings are '', '1', '0', 'ON', 'OFF', 'TRUE', and 'FALSE'.",
|
||||
variable_value);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ namespace vcpkg::Commands::BuildExternal
|
||||
PortFileProvider::PathsPortFileProvider provider(paths, overlays);
|
||||
auto maybe_scfl = provider.get_control_file(spec.package_spec.name());
|
||||
|
||||
Checks::check_exit(
|
||||
Checks::check_maybe_upgrade(
|
||||
VCPKG_LINE_INFO, maybe_scfl.has_value(), "could not load control file for %s", spec.package_spec.name());
|
||||
|
||||
Build::Command::perform_and_exit_ex(args,
|
||||
|
@ -220,7 +220,7 @@ namespace vcpkg::Commands::CI
|
||||
message_block = Strings::format("<reason><![CDATA[%s]]></reason>", to_string(test.result));
|
||||
break;
|
||||
case BuildResult::SUCCEEDED: result_string = "Pass"; break;
|
||||
default: Checks::exit_fail(VCPKG_LINE_INFO); break;
|
||||
default: Checks::unreachable(VCPKG_LINE_INFO);
|
||||
}
|
||||
|
||||
std::string traits_block;
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
#include <vcpkg/buildenvironment.h>
|
||||
#include <vcpkg/commands.create.h>
|
||||
#include <vcpkg/commands.version.h>
|
||||
#include <vcpkg/help.h>
|
||||
#include <vcpkg/vcpkgcmdarguments.h>
|
||||
#include <vcpkg/vcpkgpaths.h>
|
||||
@ -37,8 +38,10 @@ namespace vcpkg::Commands::Create
|
||||
std::vector<System::CMakeVariable> cmake_args{
|
||||
{"CMD", "CREATE"},
|
||||
{"PORT", port_name},
|
||||
{"PORT_PATH", fs::generic_u8string(paths.builtin_ports_directory() / fs::u8path(port_name))},
|
||||
{"URL", url},
|
||||
{"PORT_PATH", fs::generic_u8string(paths.builtin_ports_directory() / fs::u8path(port_name))}};
|
||||
{"VCPKG_BASE_VERSION", Commands::Version::base_version()},
|
||||
};
|
||||
|
||||
if (args.command_arguments.size() >= 3)
|
||||
{
|
||||
|
@ -161,7 +161,7 @@ namespace vcpkg::Commands::Edit
|
||||
for (auto&& port_name : ports)
|
||||
{
|
||||
const fs::path portpath = paths.builtin_ports_directory() / port_name;
|
||||
Checks::check_exit(
|
||||
Checks::check_maybe_upgrade(
|
||||
VCPKG_LINE_INFO, fs.is_directory(portpath), R"(Could not find port named "%s")", port_name);
|
||||
}
|
||||
|
||||
|
@ -120,18 +120,18 @@ Please open an issue at https://github.com/microsoft/vcpkg, with the following o
|
||||
Error:)",
|
||||
data.scf.core_paragraph->name);
|
||||
print_error_message(check.error());
|
||||
Checks::exit_with_message(VCPKG_LINE_INFO,
|
||||
R"(
|
||||
Checks::exit_maybe_upgrade(VCPKG_LINE_INFO,
|
||||
R"(
|
||||
=== Serialized manifest file ===
|
||||
%s
|
||||
)",
|
||||
Json::stringify(res, {}));
|
||||
Json::stringify(res, {}));
|
||||
}
|
||||
|
||||
auto check_scf = std::move(check).value_or_exit(VCPKG_LINE_INFO);
|
||||
if (*check_scf != data.scf)
|
||||
{
|
||||
Checks::exit_with_message(
|
||||
Checks::exit_maybe_upgrade(
|
||||
VCPKG_LINE_INFO,
|
||||
R"([correctness check] The serialized manifest SCF was different from the original SCF.
|
||||
Please open an issue at https://github.com/microsoft/vcpkg, with the following output:
|
||||
|
@ -37,7 +37,7 @@ namespace vcpkg::Commands::Info
|
||||
const ParsedArguments options = args.parse_arguments(COMMAND_STRUCTURE);
|
||||
if (!args.output_json())
|
||||
{
|
||||
Checks::exit_with_message(
|
||||
Checks::exit_maybe_upgrade(
|
||||
VCPKG_LINE_INFO, "This command currently requires --%s", VcpkgCmdArguments::JSON_SWITCH);
|
||||
}
|
||||
|
||||
|
@ -597,7 +597,7 @@ With a project open, go to Tools->NuGet Package Manager->Package Manager Console
|
||||
}
|
||||
#endif
|
||||
|
||||
Checks::exit_with_message(VCPKG_LINE_INFO, "Unknown parameter %s for integrate", args.command_arguments[0]);
|
||||
Checks::exit_maybe_upgrade(VCPKG_LINE_INFO, "Unknown parameter %s for integrate", args.command_arguments[0]);
|
||||
}
|
||||
|
||||
void IntegrateCommand::perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths) const
|
||||
|
@ -15,69 +15,25 @@
|
||||
|
||||
#define VCPKG_VERSION_AS_STRING MACRO_TO_STRING(VCPKG_VERSION)
|
||||
|
||||
#if !defined(VCPKG_BASE_VERSION)
|
||||
#error VCPKG_BASE_VERSION must be defined
|
||||
#endif
|
||||
|
||||
#define VCPKG_BASE_VERSION_AS_STRING MACRO_TO_STRING(VCPKG_BASE_VERSION)
|
||||
|
||||
namespace vcpkg::Commands::Version
|
||||
{
|
||||
const char* base_version()
|
||||
{
|
||||
return
|
||||
#include "../VERSION.txt"
|
||||
;
|
||||
}
|
||||
const char* base_version() noexcept { return VCPKG_BASE_VERSION_AS_STRING; }
|
||||
|
||||
const char* version()
|
||||
const char* version() noexcept
|
||||
{
|
||||
return
|
||||
#include "../VERSION.txt"
|
||||
"-" VCPKG_VERSION_AS_STRING
|
||||
return VCPKG_BASE_VERSION_AS_STRING "-" VCPKG_VERSION_AS_STRING
|
||||
#ifndef NDEBUG
|
||||
"-debug"
|
||||
"-debug"
|
||||
#endif
|
||||
;
|
||||
}
|
||||
|
||||
static int scan3(const char* input, const char* pattern, int* a, int* b, int* c)
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
return sscanf_s(input, pattern, a, b, c);
|
||||
#else
|
||||
return sscanf(input, pattern, a, b, c);
|
||||
#endif
|
||||
}
|
||||
|
||||
void warn_if_vcpkg_version_mismatch(const VcpkgPaths& paths)
|
||||
{
|
||||
auto version_file = paths.get_filesystem().read_contents(paths.root / "toolsrc" / "VERSION.txt");
|
||||
if (const auto version_contents = version_file.get())
|
||||
{
|
||||
int maj1, min1, rev1;
|
||||
const auto num1 = scan3(version_contents->c_str(), "\"%d.%d.%d\"", &maj1, &min1, &rev1);
|
||||
|
||||
int maj2, min2, rev2;
|
||||
const auto num2 = scan3(Version::version(), "%d.%d.%d-", &maj2, &min2, &rev2);
|
||||
|
||||
if (num1 == 3 && num2 == 3)
|
||||
{
|
||||
if (maj1 != maj2 || min1 != min2 || rev1 != rev2)
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
auto bootstrap = ".\\bootstrap-vcpkg.bat";
|
||||
#else
|
||||
auto bootstrap = "./bootstrap-vcpkg.sh";
|
||||
#endif
|
||||
System::printf(System::Color::warning,
|
||||
"Warning: Different source is available for vcpkg (%d.%d.%d -> %d.%d.%d). Use "
|
||||
"%s to update.\n",
|
||||
maj2,
|
||||
min2,
|
||||
rev2,
|
||||
maj1,
|
||||
min1,
|
||||
rev1,
|
||||
bootstrap);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
const CommandStructure COMMAND_STRUCTURE = {
|
||||
create_example_string("version"),
|
||||
0,
|
||||
|
@ -197,13 +197,16 @@ namespace vcpkg::Dependencies
|
||||
static auto vcpkg_remove_cmd = "./vcpkg";
|
||||
#endif
|
||||
if (!m_scfl)
|
||||
Checks::exit_with_message(
|
||||
{
|
||||
Checks::exit_maybe_upgrade(
|
||||
VCPKG_LINE_INFO,
|
||||
"Error: while loading control file for %s: %s.\nPlease run \"%s remove %s\" and re-attempt.",
|
||||
m_spec,
|
||||
m_scfl.error(),
|
||||
vcpkg_remove_cmd,
|
||||
m_spec);
|
||||
}
|
||||
|
||||
return *m_scfl.get();
|
||||
}
|
||||
|
||||
@ -258,7 +261,7 @@ namespace vcpkg::Dependencies
|
||||
{
|
||||
const SourceControlFileLocation* scfl = m_port_provider.get_control_file(spec.name()).get();
|
||||
|
||||
Checks::check_exit(
|
||||
Checks::check_maybe_upgrade(
|
||||
VCPKG_LINE_INFO, scfl, "Error: Cannot find definition for package `%s`.", spec.name());
|
||||
|
||||
return m_graph
|
||||
@ -296,7 +299,7 @@ namespace vcpkg::Dependencies
|
||||
const Cluster& find_or_exit(const PackageSpec& spec, LineInfo linfo) const
|
||||
{
|
||||
auto it = m_graph.find(spec);
|
||||
Checks::check_exit(linfo, it != m_graph.end(), "Failed to locate spec in graph");
|
||||
Checks::check_maybe_upgrade(linfo, it != m_graph.end(), "Failed to locate spec in graph");
|
||||
return it->second;
|
||||
}
|
||||
|
||||
@ -697,11 +700,11 @@ namespace vcpkg::Dependencies
|
||||
{
|
||||
auto maybe_scfl = port_provider.get_control_file(spec.package_spec.name());
|
||||
|
||||
Checks::check_exit(VCPKG_LINE_INFO,
|
||||
maybe_scfl.has_value(),
|
||||
"Error: while loading port `%s`: %s",
|
||||
spec.package_spec.name(),
|
||||
maybe_scfl.error());
|
||||
Checks::check_maybe_upgrade(VCPKG_LINE_INFO,
|
||||
maybe_scfl.has_value(),
|
||||
"Error: while loading port `%s`: %s",
|
||||
spec.package_spec.name(),
|
||||
maybe_scfl.error());
|
||||
|
||||
const SourceControlFileLocation* scfl = maybe_scfl.get();
|
||||
|
||||
@ -790,11 +793,11 @@ namespace vcpkg::Dependencies
|
||||
{
|
||||
auto maybe_paragraph =
|
||||
clust.get_scfl_or_exit().source_control_file->find_feature(spec.feature());
|
||||
Checks::check_exit(VCPKG_LINE_INFO,
|
||||
maybe_paragraph.has_value(),
|
||||
"Package %s does not have a %s feature",
|
||||
spec.name(),
|
||||
spec.feature());
|
||||
Checks::check_maybe_upgrade(VCPKG_LINE_INFO,
|
||||
maybe_paragraph.has_value(),
|
||||
"Package %s does not have a %s feature",
|
||||
spec.name(),
|
||||
spec.feature());
|
||||
paragraph_depends = &maybe_paragraph.value_or_exit(VCPKG_LINE_INFO).dependencies;
|
||||
}
|
||||
|
||||
@ -1024,11 +1027,12 @@ namespace vcpkg::Dependencies
|
||||
for (auto&& dep : deps)
|
||||
{
|
||||
auto p_installed = graph->get(dep).m_installed.get();
|
||||
Checks::check_exit(VCPKG_LINE_INFO,
|
||||
p_installed,
|
||||
"Error: database corrupted. Package %s is installed but dependency %s is not.",
|
||||
ipv.spec(),
|
||||
dep);
|
||||
Checks::check_maybe_upgrade(
|
||||
VCPKG_LINE_INFO,
|
||||
p_installed,
|
||||
"Error: database corrupted. Package %s is installed but dependency %s is not.",
|
||||
ipv.spec(),
|
||||
dep);
|
||||
p_installed->remove_edges.emplace(ipv.spec());
|
||||
}
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ namespace vcpkg::Export::Chocolatey
|
||||
{
|
||||
Checks::exit_with_message(VCPKG_LINE_INFO, "Cannot find desired dependency version.");
|
||||
}
|
||||
|
||||
std::string nuspec_dependency = Strings::replace_all(CONTENT_TEMPLATE, "@PACKAGE_ID@", depend);
|
||||
Strings::inplace_replace_all(nuspec_dependency, "@PACKAGE_VERSION@", found->second);
|
||||
nuspec_dependencies += nuspec_dependency;
|
||||
@ -62,6 +63,7 @@ namespace vcpkg::Export::Chocolatey
|
||||
{
|
||||
Checks::exit_with_message(VCPKG_LINE_INFO, "Cannot find desired package version.");
|
||||
}
|
||||
|
||||
std::string nuspec_file_content =
|
||||
Strings::replace_all(CONTENT_TEMPLATE, "@PACKAGE_ID@", binary_paragraph.spec.name());
|
||||
Strings::inplace_replace_all(nuspec_file_content, "@PACKAGE_VERSION@", package_version->second);
|
||||
|
@ -616,7 +616,7 @@ With a project open, go to Tools->NuGet Package Manager->Package Manager Console
|
||||
{
|
||||
if (paths.manifest_mode_enabled())
|
||||
{
|
||||
Checks::exit_with_message(
|
||||
Checks::exit_maybe_upgrade(
|
||||
VCPKG_LINE_INFO,
|
||||
"vcpkg export does not support manifest mode, in order to allow for future design considerations. You "
|
||||
"may use export in classic mode by running vcpkg outside of a manifest-based project.");
|
||||
|
@ -257,7 +257,8 @@ namespace vcpkg::Export::Prefab
|
||||
|
||||
{
|
||||
auto build_info = build_info_from_triplet(paths, provider, default_triplet);
|
||||
Checks::check_exit(VCPKG_LINE_INFO, is_supported(*build_info), "Currenty supported on android triplets");
|
||||
Checks::check_maybe_upgrade(
|
||||
VCPKG_LINE_INFO, is_supported(*build_info), "Currenty supported on android triplets");
|
||||
}
|
||||
|
||||
std::vector<VcpkgPaths::TripletFile> available_triplets = paths.get_available_triplets();
|
||||
@ -312,25 +313,25 @@ namespace vcpkg::Export::Prefab
|
||||
|
||||
const fs::path ndk_location = android_ndk_home.value_or_exit(VCPKG_LINE_INFO);
|
||||
|
||||
Checks::check_exit(VCPKG_LINE_INFO,
|
||||
utils.exists(ndk_location),
|
||||
"Error: ANDROID_NDK_HOME Directory does not exists %s",
|
||||
fs::generic_u8string(ndk_location));
|
||||
Checks::check_maybe_upgrade(VCPKG_LINE_INFO,
|
||||
utils.exists(ndk_location),
|
||||
"Error: ANDROID_NDK_HOME Directory does not exists %s",
|
||||
fs::generic_u8string(ndk_location));
|
||||
const fs::path source_properties_location = ndk_location / "source.properties";
|
||||
|
||||
Checks::check_exit(VCPKG_LINE_INFO,
|
||||
utils.exists(ndk_location),
|
||||
"Error: source.properties missing in ANDROID_NDK_HOME directory %s",
|
||||
fs::generic_u8string(source_properties_location));
|
||||
Checks::check_maybe_upgrade(VCPKG_LINE_INFO,
|
||||
utils.exists(ndk_location),
|
||||
"Error: source.properties missing in ANDROID_NDK_HOME directory %s",
|
||||
fs::generic_u8string(source_properties_location));
|
||||
|
||||
std::string content = utils.read_contents(source_properties_location, VCPKG_LINE_INFO);
|
||||
|
||||
Optional<std::string> version_opt = find_ndk_version(content);
|
||||
|
||||
Checks::check_exit(VCPKG_LINE_INFO,
|
||||
version_opt.has_value(),
|
||||
"Error: NDK version missing %s",
|
||||
fs::generic_u8string(source_properties_location));
|
||||
Checks::check_maybe_upgrade(VCPKG_LINE_INFO,
|
||||
version_opt.has_value(),
|
||||
"Error: NDK version missing %s",
|
||||
fs::generic_u8string(source_properties_location));
|
||||
|
||||
NdkVersion version = to_version(version_opt.value_or_exit(VCPKG_LINE_INFO)).value_or_exit(VCPKG_LINE_INFO);
|
||||
|
||||
|
@ -51,8 +51,9 @@ namespace vcpkg::Install
|
||||
{
|
||||
auto& fs = paths.get_filesystem();
|
||||
auto source_dir = paths.package_dir(spec);
|
||||
Checks::check_exit(
|
||||
VCPKG_LINE_INFO, fs.exists(source_dir), "Source directory %s does not exist", fs::u8string(source_dir));
|
||||
Checks::check_exit(VCPKG_LINE_INFO,
|
||||
fs.exists(source_dir),
|
||||
Strings::concat("Source directory ", fs::u8string(source_dir), "does not exist"));
|
||||
auto files = fs.get_files_recursive(source_dir);
|
||||
install_files_and_write_listfile(fs, source_dir, files, destination_dir);
|
||||
}
|
||||
@ -857,12 +858,13 @@ namespace vcpkg::Install
|
||||
return (ch >= 'a' || ch <= 'f') || Parse::ParserBase::is_ascii_digit(ch);
|
||||
}))
|
||||
{
|
||||
Checks::exit_with_message(VCPKG_LINE_INFO,
|
||||
"Error: the top-level builtin-baseline (%s) was not a valid commit sha: "
|
||||
"expected 40 lowercase hexadecimal characters.\n%s\n",
|
||||
*p_baseline,
|
||||
paths.get_current_git_sha_message());
|
||||
Checks::exit_maybe_upgrade(VCPKG_LINE_INFO,
|
||||
"Error: the top-level builtin-baseline (%s) was not a valid commit sha: "
|
||||
"expected 40 lowercase hexadecimal characters.\n%s\n",
|
||||
*p_baseline,
|
||||
paths.get_current_git_sha_message());
|
||||
}
|
||||
|
||||
paths.get_configuration().registry_set.experimental_set_builtin_registry_baseline(*p_baseline);
|
||||
}
|
||||
auto verprovider = PortFileProvider::make_versioned_portfile_provider(paths);
|
||||
@ -1079,7 +1081,7 @@ namespace vcpkg::Install
|
||||
message_block = Strings::format("<reason><![CDATA[%s]]></reason>", to_string(code));
|
||||
break;
|
||||
case BuildResult::SUCCEEDED: result_string = "Pass"; break;
|
||||
default: Checks::exit_fail(VCPKG_LINE_INFO);
|
||||
default: Checks::unreachable(VCPKG_LINE_INFO);
|
||||
}
|
||||
|
||||
return Strings::format(R"(<test name="%s" method="%s" time="%lld" result="%s">%s</test>)"
|
||||
|
@ -398,11 +398,7 @@ namespace vcpkg::PlatformExpression
|
||||
case Identifier::wasm32: return true_if_exists_and_equal("VCPKG_TARGET_ARCHITECTURE", "wasm32");
|
||||
case Identifier::static_link:
|
||||
return true_if_exists_and_equal("VCPKG_LIBRARY_LINKAGE", "static");
|
||||
default:
|
||||
Checks::exit_with_message(
|
||||
VCPKG_LINE_INFO,
|
||||
"vcpkg bug: string2identifier returned a value that we don't recognize: %d\n",
|
||||
static_cast<int>(id));
|
||||
default: Checks::unreachable(VCPKG_LINE_INFO);
|
||||
}
|
||||
}
|
||||
else if (expr.kind == ExprKind::op_not)
|
||||
|
@ -112,7 +112,7 @@ namespace vcpkg::PortFileProvider
|
||||
else
|
||||
{
|
||||
print_error_message(maybe_scf.error());
|
||||
Checks::exit_with_message(
|
||||
Checks::exit_maybe_upgrade(
|
||||
VCPKG_LINE_INFO, "Error: Failed to load port %s from %s", spec, fs::u8string(ports_dir));
|
||||
}
|
||||
|
||||
@ -130,16 +130,16 @@ namespace vcpkg::PortFileProvider
|
||||
{
|
||||
return std::make_unique<OverlayRegistryEntry>(std::move(ports_spec), scf->to_versiont());
|
||||
}
|
||||
Checks::exit_with_message(VCPKG_LINE_INFO,
|
||||
"Error: Failed to load port from %s: names did not match: '%s' != '%s'",
|
||||
fs::u8string(ports_spec),
|
||||
spec,
|
||||
scf->core_paragraph->name);
|
||||
Checks::exit_maybe_upgrade(VCPKG_LINE_INFO,
|
||||
"Error: Failed to load port from %s: names did not match: '%s' != '%s'",
|
||||
fs::u8string(ports_spec),
|
||||
spec,
|
||||
scf->core_paragraph->name);
|
||||
}
|
||||
else
|
||||
{
|
||||
print_error_message(found_scf.error());
|
||||
Checks::exit_with_message(
|
||||
Checks::exit_maybe_upgrade(
|
||||
VCPKG_LINE_INFO, "Error: Failed to load port %s from %s", spec, fs::u8string(ports_dir));
|
||||
}
|
||||
}
|
||||
@ -271,7 +271,7 @@ namespace vcpkg::PortFileProvider
|
||||
else
|
||||
{
|
||||
print_error_message(maybe_scf.error());
|
||||
Checks::exit_with_message(
|
||||
Checks::exit_maybe_upgrade(
|
||||
VCPKG_LINE_INFO, "Error: Failed to load port from %s", fs::u8string(ports_dir));
|
||||
}
|
||||
continue;
|
||||
@ -345,7 +345,7 @@ namespace vcpkg::PortFileProvider
|
||||
auto entry = try_load_registry_port_and_baseline(paths, port_name.to_string());
|
||||
if (!entry.first)
|
||||
{
|
||||
Checks::exit_with_message(
|
||||
Checks::exit_maybe_upgrade(
|
||||
VCPKG_LINE_INFO, "Error: Could not find a definition for port %s", port_name);
|
||||
}
|
||||
auto it = m_entry_cache.emplace(port_name.to_string(), std::move(entry.first));
|
||||
@ -436,10 +436,10 @@ namespace vcpkg::PortFileProvider
|
||||
else
|
||||
{
|
||||
print_error_message(maybe_scf.error());
|
||||
Checks::exit_with_message(VCPKG_LINE_INFO,
|
||||
"Error: Failed to load port %s from %s",
|
||||
port_name,
|
||||
fs::u8string(maybe_overlay->path));
|
||||
Checks::exit_maybe_upgrade(VCPKG_LINE_INFO,
|
||||
"Error: Failed to load port %s from %s",
|
||||
port_name,
|
||||
fs::u8string(maybe_overlay->path));
|
||||
}
|
||||
}
|
||||
it = m_overlay_cache.emplace(std::move(s_port_name), std::move(v)).first;
|
||||
|
@ -234,7 +234,7 @@ namespace
|
||||
auto port_name = filename.substr(0, filename.size() - 5);
|
||||
if (!Json::PackageNameDeserializer::is_package_name(port_name))
|
||||
{
|
||||
Checks::exit_with_message(
|
||||
Checks::exit_maybe_upgrade(
|
||||
VCPKG_LINE_INFO, "Error: found invalid port version file name: `%s`.", fs::u8string(file));
|
||||
}
|
||||
out.push_back(std::move(port_name));
|
||||
@ -252,8 +252,8 @@ namespace
|
||||
{
|
||||
auto maybe_version_entries =
|
||||
load_versions_file(paths.get_filesystem(), VersionDbType::Git, paths.builtin_port_versions, port_name);
|
||||
Checks::check_exit(
|
||||
VCPKG_LINE_INFO, maybe_version_entries.has_value(), "Error: %s", maybe_version_entries.error());
|
||||
Checks::check_maybe_upgrade(
|
||||
VCPKG_LINE_INFO, maybe_version_entries.has_value(), "Error: " + maybe_version_entries.error());
|
||||
auto version_entries = std::move(maybe_version_entries).value_or_exit(VCPKG_LINE_INFO);
|
||||
|
||||
auto res =
|
||||
@ -278,7 +278,7 @@ namespace
|
||||
auto maybe_error = scf->check_against_feature_flags(port_directory, paths.get_feature_flags());
|
||||
if (maybe_error)
|
||||
{
|
||||
Checks::exit_with_message(VCPKG_LINE_INFO, "Parsing manifest failed: %s", *maybe_error.get());
|
||||
Checks::exit_maybe_upgrade(VCPKG_LINE_INFO, "Parsing manifest failed: %s", *maybe_error.get());
|
||||
}
|
||||
|
||||
if (scf->core_paragraph->name == port_name)
|
||||
@ -286,11 +286,11 @@ namespace
|
||||
return std::make_unique<BuiltinRegistryEntry>(
|
||||
std::make_unique<SourceControlFileLocation>(std::move(scf), std::move(port_directory)));
|
||||
}
|
||||
Checks::exit_with_message(VCPKG_LINE_INFO,
|
||||
"Error: Failed to load port from %s: names did not match: '%s' != '%s'",
|
||||
fs::u8string(port_directory),
|
||||
port_name,
|
||||
scf->core_paragraph->name);
|
||||
Checks::exit_maybe_upgrade(VCPKG_LINE_INFO,
|
||||
"Error: Failed to load port from %s: names did not match: '%s' != '%s'",
|
||||
fs::u8string(port_directory),
|
||||
port_name,
|
||||
scf->core_paragraph->name);
|
||||
}
|
||||
}
|
||||
|
||||
@ -416,14 +416,14 @@ namespace
|
||||
return {};
|
||||
}
|
||||
|
||||
Checks::exit_with_message(
|
||||
Checks::exit_maybe_upgrade(
|
||||
VCPKG_LINE_INFO,
|
||||
"Error: could not find explicitly specified baseline `\"%s\"` in baseline file `%s`.",
|
||||
baseline_identifier,
|
||||
fs::u8string(path_to_baseline));
|
||||
}
|
||||
|
||||
Checks::exit_with_message(VCPKG_LINE_INFO, res_baseline.error());
|
||||
Checks::exit_maybe_upgrade(VCPKG_LINE_INFO, res_baseline.error());
|
||||
}
|
||||
Optional<VersionT> FilesystemRegistry::get_baseline_version(const VcpkgPaths& paths, StringView port_name) const
|
||||
{
|
||||
@ -446,8 +446,8 @@ namespace
|
||||
{
|
||||
auto maybe_version_entries = load_versions_file(
|
||||
paths.get_filesystem(), VersionDbType::Filesystem, m_path / port_versions_dir, port_name, m_path);
|
||||
Checks::check_exit(
|
||||
VCPKG_LINE_INFO, maybe_version_entries.has_value(), "Error: %s", maybe_version_entries.error());
|
||||
Checks::check_maybe_upgrade(
|
||||
VCPKG_LINE_INFO, maybe_version_entries.has_value(), "Error: " + maybe_version_entries.error());
|
||||
auto version_entries = std::move(maybe_version_entries).value_or_exit(VCPKG_LINE_INFO);
|
||||
|
||||
auto res = std::make_unique<FilesystemRegistryEntry>(port_name.to_string());
|
||||
@ -471,8 +471,8 @@ namespace
|
||||
auto port_versions = get_versions_tree_path(paths);
|
||||
auto maybe_version_entries =
|
||||
load_versions_file(paths.get_filesystem(), VersionDbType::Git, port_versions, port_name);
|
||||
Checks::check_exit(
|
||||
VCPKG_LINE_INFO, maybe_version_entries.has_value(), "Error: %s", maybe_version_entries.error());
|
||||
Checks::check_maybe_upgrade(
|
||||
VCPKG_LINE_INFO, maybe_version_entries.has_value(), "Error: " + maybe_version_entries.error());
|
||||
auto version_entries = std::move(maybe_version_entries).value_or_exit(VCPKG_LINE_INFO);
|
||||
|
||||
auto res = std::make_unique<GitRegistryEntry>(port_name.to_string());
|
||||
@ -493,7 +493,7 @@ namespace
|
||||
|
||||
if (!res_baseline.has_value())
|
||||
{
|
||||
Checks::exit_with_message(VCPKG_LINE_INFO, res_baseline.error());
|
||||
Checks::exit_maybe_upgrade(VCPKG_LINE_INFO, res_baseline.error());
|
||||
}
|
||||
auto opt_baseline = res_baseline.get();
|
||||
if (auto p = opt_baseline->get())
|
||||
@ -552,7 +552,7 @@ namespace
|
||||
}
|
||||
else
|
||||
{
|
||||
Checks::exit_with_message(
|
||||
Checks::exit_maybe_upgrade(
|
||||
VCPKG_LINE_INFO,
|
||||
"Couldn't find explicitly specified baseline `\"%s\"` in the baseline file for repo %s, "
|
||||
"and the `\"default\"` baseline does not exist at that commit.",
|
||||
@ -893,7 +893,7 @@ namespace
|
||||
fs::path path;
|
||||
r.required_object_field("a filesystem registry", obj, PATH, path, Json::PathDeserializer::instance);
|
||||
|
||||
res = std::make_unique<FilesystemRegistry>(config_directory / path, std::move(baseline));
|
||||
res = std::make_unique<FilesystemRegistry>(Files::combine(config_directory, path), std::move(baseline));
|
||||
}
|
||||
else if (kind == KIND_GIT)
|
||||
{
|
||||
|
@ -218,9 +218,9 @@ namespace vcpkg::Remove
|
||||
{
|
||||
if (paths.manifest_mode_enabled())
|
||||
{
|
||||
Checks::exit_with_message(VCPKG_LINE_INFO,
|
||||
"vcpkg remove does not support manifest mode. In order to remove dependencies, "
|
||||
"you will need to edit your manifest (vcpkg.json).");
|
||||
Checks::exit_maybe_upgrade(VCPKG_LINE_INFO,
|
||||
"vcpkg remove does not support manifest mode. In order to remove dependencies, "
|
||||
"you will need to edit your manifest (vcpkg.json).");
|
||||
}
|
||||
const ParsedArguments options = args.parse_arguments(COMMAND_STRUCTURE);
|
||||
|
||||
|
@ -27,7 +27,8 @@ namespace vcpkg
|
||||
: want(Want::ERROR_STATE), state(InstallState::ERROR_STATE)
|
||||
{
|
||||
auto status_it = fields.find(BinaryParagraphRequiredField::STATUS);
|
||||
Checks::check_exit(VCPKG_LINE_INFO, status_it != fields.end(), "Expected 'Status' field in status paragraph");
|
||||
Checks::check_maybe_upgrade(
|
||||
VCPKG_LINE_INFO, status_it != fields.end(), "Expected 'Status' field in status paragraph");
|
||||
std::string status_field = std::move(status_it->second.first);
|
||||
fields.erase(status_it);
|
||||
|
||||
|
@ -103,15 +103,14 @@ namespace vcpkg
|
||||
}
|
||||
|
||||
const std::string tool_data =
|
||||
StringView::find_exactly_one_enclosed(XML, match_tool_entry[0], "</tool>").to_string();
|
||||
Strings::find_exactly_one_enclosed(XML, match_tool_entry[0].str(), "</tool>").to_string();
|
||||
const std::string version_as_string =
|
||||
StringView::find_exactly_one_enclosed(tool_data, "<version>", "</version>").to_string();
|
||||
Strings::find_exactly_one_enclosed(tool_data, "<version>", "</version>").to_string();
|
||||
const std::string exe_relative_path =
|
||||
StringView::find_exactly_one_enclosed(tool_data, "<exeRelativePath>", "</exeRelativePath>").to_string();
|
||||
const std::string url = StringView::find_exactly_one_enclosed(tool_data, "<url>", "</url>").to_string();
|
||||
const std::string sha512 =
|
||||
StringView::find_exactly_one_enclosed(tool_data, "<sha512>", "</sha512>").to_string();
|
||||
auto archive_name = StringView::find_at_most_one_enclosed(tool_data, "<archiveName>", "</archiveName>");
|
||||
Strings::find_exactly_one_enclosed(tool_data, "<exeRelativePath>", "</exeRelativePath>").to_string();
|
||||
const std::string url = Strings::find_exactly_one_enclosed(tool_data, "<url>", "</url>").to_string();
|
||||
const std::string sha512 = Strings::find_exactly_one_enclosed(tool_data, "<sha512>", "</sha512>").to_string();
|
||||
auto archive_name = Strings::find_at_most_one_enclosed(tool_data, "<archiveName>", "</archiveName>");
|
||||
|
||||
const Optional<std::array<int, 3>> version = parse_version_string(version_as_string);
|
||||
Checks::check_exit(VCPKG_LINE_INFO,
|
||||
@ -185,13 +184,13 @@ namespace vcpkg
|
||||
{
|
||||
const std::array<int, 3>& version = tool_data.version;
|
||||
const std::string version_as_string = Strings::format("%d.%d.%d", version[0], version[1], version[2]);
|
||||
Checks::check_exit(VCPKG_LINE_INFO,
|
||||
!tool_data.url.empty(),
|
||||
"A suitable version of %s was not found (required v%s) and unable to automatically "
|
||||
"download a portable one. Please install a newer version of %s.",
|
||||
tool_name,
|
||||
version_as_string,
|
||||
tool_name);
|
||||
Checks::check_maybe_upgrade(VCPKG_LINE_INFO,
|
||||
!tool_data.url.empty(),
|
||||
"A suitable version of %s was not found (required v%s) and unable to automatically "
|
||||
"download a portable one. Please install a newer version of %s.",
|
||||
tool_name,
|
||||
version_as_string,
|
||||
tool_name);
|
||||
System::printf("A suitable version of %s was not found (required v%s). Downloading portable %s v%s...\n",
|
||||
tool_name,
|
||||
version_as_string,
|
||||
@ -271,7 +270,7 @@ namespace vcpkg
|
||||
return fetch_tool(paths, tool, *tool_data);
|
||||
}
|
||||
|
||||
Checks::exit_with_message(VCPKG_LINE_INFO, maybe_tool_data.error());
|
||||
Checks::exit_maybe_upgrade(VCPKG_LINE_INFO, maybe_tool_data.error());
|
||||
}
|
||||
|
||||
struct CMakeProvider : ToolProvider
|
||||
@ -311,7 +310,7 @@ cmake version 3.10.2
|
||||
|
||||
CMake suite maintained and supported by Kitware (kitware.com/cmake).
|
||||
*/
|
||||
return {StringView::find_exactly_one_enclosed(rc.output, "cmake version ", "\n").to_string(),
|
||||
return {Strings::find_exactly_one_enclosed(rc.output, "cmake version ", "\n").to_string(),
|
||||
expected_left_tag};
|
||||
}
|
||||
};
|
||||
@ -385,7 +384,7 @@ Type 'NuGet help <command>' for help on a specific command.
|
||||
|
||||
[[[List of available commands follows]]]
|
||||
*/
|
||||
return {StringView::find_exactly_one_enclosed(rc.output, "NuGet Version: ", "\n").to_string(),
|
||||
return {Strings::find_exactly_one_enclosed(rc.output, "NuGet Version: ", "\n").to_string(),
|
||||
expected_left_tag};
|
||||
}
|
||||
};
|
||||
@ -602,7 +601,7 @@ Mono JIT compiler version 6.8.0.105 (Debian 6.8.0.105+dfsg-2 Wed Feb 26 23:23:50
|
||||
return {fetch_tool(paths, tool, *p_tool_data), p_tool_data->sha512};
|
||||
}
|
||||
|
||||
Checks::exit_with_message(VCPKG_LINE_INFO, "Unknown or unavailable tool: %s", tool);
|
||||
Checks::exit_maybe_upgrade(VCPKG_LINE_INFO, "Unknown or unavailable tool: %s", tool);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -188,10 +188,12 @@ namespace vcpkg
|
||||
}
|
||||
|
||||
for (auto&& ipv : ipv_map)
|
||||
Checks::check_exit(VCPKG_LINE_INFO,
|
||||
ipv.second.core != nullptr,
|
||||
"Database is corrupted: package %s has features but no core paragraph.",
|
||||
ipv.first);
|
||||
{
|
||||
Checks::check_maybe_upgrade(VCPKG_LINE_INFO,
|
||||
ipv.second.core != nullptr,
|
||||
"Database is corrupted: package %s has features but no core paragraph.",
|
||||
ipv.first);
|
||||
}
|
||||
|
||||
return Util::fmap(ipv_map, [](auto&& p) -> InstalledPackageView { return std::move(p.second); });
|
||||
}
|
||||
|
@ -119,18 +119,18 @@ namespace vcpkg
|
||||
auto manifest_opt = Json::parse_file(fs, manifest_path, ec);
|
||||
if (ec)
|
||||
{
|
||||
Checks::exit_with_message(VCPKG_LINE_INFO,
|
||||
"Failed to load manifest from directory %s: %s",
|
||||
fs::u8string(manifest_dir),
|
||||
ec.message());
|
||||
Checks::exit_maybe_upgrade(VCPKG_LINE_INFO,
|
||||
"Failed to load manifest from directory %s: %s",
|
||||
fs::u8string(manifest_dir),
|
||||
ec.message());
|
||||
}
|
||||
|
||||
if (!manifest_opt.has_value())
|
||||
{
|
||||
Checks::exit_with_message(VCPKG_LINE_INFO,
|
||||
"Failed to parse manifest at %s:\n%s",
|
||||
fs::u8string(manifest_path),
|
||||
manifest_opt.error()->format());
|
||||
Checks::exit_maybe_upgrade(VCPKG_LINE_INFO,
|
||||
"Failed to parse manifest at %s:\n%s",
|
||||
fs::u8string(manifest_path),
|
||||
manifest_opt.error()->format());
|
||||
}
|
||||
auto manifest_value = std::move(manifest_opt).value_or_exit(VCPKG_LINE_INFO);
|
||||
|
||||
@ -158,17 +158,16 @@ namespace vcpkg
|
||||
const fs::path& manifest_dir)
|
||||
{
|
||||
fs::path config_dir;
|
||||
|
||||
if (!manifest_dir.empty())
|
||||
{
|
||||
// manifest mode
|
||||
config_dir = manifest_dir;
|
||||
}
|
||||
else
|
||||
if (manifest_dir.empty())
|
||||
{
|
||||
// classic mode
|
||||
config_dir = vcpkg_root;
|
||||
}
|
||||
else
|
||||
{
|
||||
// manifest mode
|
||||
config_dir = manifest_dir;
|
||||
}
|
||||
|
||||
auto path_to_config = config_dir / fs::u8path("vcpkg-configuration.json");
|
||||
if (!fs.exists(path_to_config))
|
||||
@ -979,7 +978,7 @@ If you wish to silence this error and use classic mode, you can:
|
||||
}
|
||||
|
||||
#if !defined(_WIN32)
|
||||
Checks::exit_with_message(VCPKG_LINE_INFO, "Cannot build windows triplets from non-windows.");
|
||||
Checks::exit_maybe_upgrade(VCPKG_LINE_INFO, "Cannot build windows triplets from non-windows.");
|
||||
#else
|
||||
const std::vector<Toolset>& vs_toolsets = m_pimpl->toolsets.get_lazy(
|
||||
[this]() { return VisualStudio::find_toolset_instances_preferred_first(*this); });
|
||||
|
@ -1,6 +1,7 @@
|
||||
#if defined(_WIN32)
|
||||
|
||||
#include <vcpkg/base/sortedvector.h>
|
||||
#include <vcpkg/base/strings.h>
|
||||
#include <vcpkg/base/stringview.h>
|
||||
#include <vcpkg/base/system.print.h>
|
||||
#include <vcpkg/base/system.process.h>
|
||||
@ -98,11 +99,11 @@ namespace vcpkg::VisualStudio
|
||||
code_and_output.output);
|
||||
|
||||
const auto instance_entries =
|
||||
StringView::find_all_enclosed(code_and_output.output, "<instance>", "</instance>");
|
||||
Strings::find_all_enclosed(code_and_output.output, "<instance>", "</instance>");
|
||||
for (const StringView& instance : instance_entries)
|
||||
{
|
||||
auto maybe_is_prerelease =
|
||||
StringView::find_at_most_one_enclosed(instance, "<isPrerelease>", "</isPrerelease>");
|
||||
Strings::find_at_most_one_enclosed(instance, "<isPrerelease>", "</isPrerelease>");
|
||||
|
||||
VisualStudioInstance::ReleaseType release_type = VisualStudioInstance::ReleaseType::LEGACY;
|
||||
if (const auto p = maybe_is_prerelease.get())
|
||||
@ -117,9 +118,9 @@ namespace vcpkg::VisualStudio
|
||||
}
|
||||
|
||||
instances.emplace_back(
|
||||
StringView::find_exactly_one_enclosed(instance, "<installationPath>", "</installationPath>")
|
||||
Strings::find_exactly_one_enclosed(instance, "<installationPath>", "</installationPath>")
|
||||
.to_string(),
|
||||
StringView::find_exactly_one_enclosed(instance, "<installationVersion>", "</installationVersion>")
|
||||
Strings::find_exactly_one_enclosed(instance, "<installationVersion>", "</installationVersion>")
|
||||
.to_string(),
|
||||
release_type);
|
||||
}
|
||||
|
@ -96,7 +96,7 @@
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>..\include</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>VCPKG_VERSION=$(VCPKG_VERSION);_MBCS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>VCPKG_VERSION=$(VCPKG_VERSION);VCPKG_BASE_VERSION=$(VCPKG_BASE_VERSION);_MBCS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalOptions>/std:c++latest %(AdditionalOptions)</AdditionalOptions>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<MinimalRebuild>false</MinimalRebuild>
|
||||
@ -114,7 +114,7 @@
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>..\include</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>VCPKG_VERSION=$(VCPKG_VERSION);_MBCS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>VCPKG_VERSION=$(VCPKG_VERSION);VCPKG_BASE_VERSION=$(VCPKG_BASE_VERSION);_MBCS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalOptions>/std:c++latest %(AdditionalOptions)</AdditionalOptions>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<MinimalRebuild>false</MinimalRebuild>
|
||||
@ -134,7 +134,7 @@
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>..\include</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>VCPKG_VERSION=$(VCPKG_VERSION);_MBCS;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>VCPKG_VERSION=$(VCPKG_VERSION);VCPKG_BASE_VERSION=$(VCPKG_BASE_VERSION);_MBCS;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>_MBCS;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalOptions>/std:c++latest %(AdditionalOptions)</AdditionalOptions>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
@ -156,7 +156,7 @@
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>..\include</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>VCPKG_VERSION=$(VCPKG_VERSION);_MBCS;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>VCPKG_VERSION=$(VCPKG_VERSION);VCPKG_BASE_VERSION=$(VCPKG_BASE_VERSION);_MBCS;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>_MBCS;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalOptions>/std:c++latest %(AdditionalOptions)</AdditionalOptions>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
@ -368,9 +368,6 @@
|
||||
<ClCompile Include="..\src\vcpkg\visualstudio.cpp" />
|
||||
<ClCompile Include="..\src\vcpkg.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Text Include="..\VERSION.txt" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
|
Loading…
Reference in New Issue
Block a user