Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[vcpkg] Add vcpkg_minimum_required as a replacement for VERSION.txt. #15638

Merged
merged 25 commits into from Jan 20, 2021

Conversation

BillyONeal
Copy link
Member

No description provided.

@BillyONeal BillyONeal added category:vcpkg-feature The issue is a new capability of the tool that doesn’t already exist and we haven’t committed info:internal This PR or Issue was filed by the vcpkg team. labels Jan 14, 2021

string(REGEX MATCH "[12][0-9][0-9][0-9]-[01][0-9]-[0-2][0-9]" _vcpkg_matched_test_version "${_vcpkg_VERSION}")
if (NOT _vcpkg_matched_test_version STREQUAL _vcpkg_VERSION)
message(FATAL_ERROR "VERSION parameter to vcpkg_minimum_required was not a valid date.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be good to print the current vcpkg tool's _vcpkg_matched_base_version in this error case as well.

endif()

set(VCPKG_BASE_VERSION "2020-01-13")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
set(VCPKG_BASE_VERSION "2020-01-13")
set(VCPKG_BASE_VERSION "2021-01-13")

😄

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At least I was consistent about it I guess 😂

endif()
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake)
include(vcpkg_minimum_required)
vcpkg_minimum_required(VERSION 2020-01-13)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
vcpkg_minimum_required(VERSION 2020-01-13)
vcpkg_minimum_required(VERSION 2021-01-13)

@@ -0,0 +1,2 @@
vcpkg_minimum_required(VERSION 2020-01-12)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
vcpkg_minimum_required(VERSION 2020-01-12)
vcpkg_minimum_required(VERSION 2021-01-12)

## Usage
```cmake
vcpkg_check_linkage(
VERSION 2020-01-13
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
VERSION 2020-01-13
VERSION 2021-01-13

@@ -369,7 +369,8 @@ else
}

$arguments = (
"`"/p:VCPKG_VERSION=-unknownhash`"",
"`"/p:VCPKG_VERSION=unknownhash`"",
"`"/p:VCPKG_BASE_VERSION=2020-01-13`"", # Note: This duplicate date version will be short lived. See https://github.com/microsoft/vcpkg/pull/15474
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"`"/p:VCPKG_BASE_VERSION=2020-01-13`"", # Note: This duplicate date version will be short lived. See https://github.com/microsoft/vcpkg/pull/15474
"`"/p:VCPKG_BASE_VERSION=2021-01-13`"", # Note: This duplicate date version will be short lived. See https://github.com/microsoft/vcpkg/pull/15474


## Usage
```cmake
vcpkg_check_linkage(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
vcpkg_check_linkage(
vcpkg_minimum_required(

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Copy link
Contributor

@strega-nil strega-nil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor changes requested, then I'm an approve.

)
endif()

string(REGEX MATCH "[12][0-9][0-9][0-9]-[01][0-9]-[0-2][0-9]" _vcpkg_matched_base_version "${VCPKG_BASE_VERSION}")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
string(REGEX MATCH "[12][0-9][0-9][0-9]-[01][0-9]-[0-2][0-9]" _vcpkg_matched_base_version "${VCPKG_BASE_VERSION}")
string(REGEX MATCH "^[12][0-9][0-9][0-9]-(0[0-9]|1[0-2])-([0-2][0-9]|3[01])$" _vcpkg_matched_base_version "${VCPKG_BASE_VERSION}")

this doesn't match "2020-01-31" as it is right now, and it also matches "foobar2423-13-12"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively,

Suggested change
string(REGEX MATCH "[12][0-9][0-9][0-9]-[01][0-9]-[0-2][0-9]" _vcpkg_matched_base_version "${VCPKG_BASE_VERSION}")
string(REGEX MATCH "^\d{4}-\d{2}-\d{2}$" _vcpkg_matched_base_version "${VCPKG_BASE_VERSION}")


string(REPLACE "-" "." _VCPKG_BASE_VERSION_as_dotted "${_vcpkg_matched_base_version}")

string(REGEX MATCH "[12][0-9][0-9][0-9]-[01][0-9]-[0-2][0-9]" _vcpkg_matched_test_version "${_vcpkg_VERSION}")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should either split out the matcher, or use a simpler matcher.

Comment on lines 42 to 43
{"PORT_PATH", fs::generic_u8string(paths.builtin_ports_directory() / fs::u8path(port_name))},
{"VCPKG_BASE_VERSION", Commands::Version::base_version()},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a minor nit, but

Suggested change
{"PORT_PATH", fs::generic_u8string(paths.builtin_ports_directory() / fs::u8path(port_name))},
{"VCPKG_BASE_VERSION", Commands::Version::base_version()},
{"VCPKG_BASE_VERSION", Commands::Version::base_version()},
{"PORT_PATH", fs::generic_u8string(paths.builtin_ports_directory() / fs::u8path(port_name))},

New-Item -Path $WorkingRoot -ItemType Directory
}

$WorkingRoot = (Get-Item $WorkingRoot).FullName
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate of below

docs/maintainers/vcpkg_minimum_required.md Outdated Show resolved Hide resolved
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."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This message might need to additionally suggest git pull.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that would be harmful given the status quo that the only way the user can have this happen if they've already changed branches. I agree it makes sense when most of our users are using externally acquired vcpkg / registries, but when that happens the right fix won't be bootstrap-vcpkg either.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(That is, that message might change the versions of bits users are using)

Copy link
Contributor

@strega-nil strega-nil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor comments and questions but approved :)

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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

were these just never defined?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ctors are defined inline there, to_string was defined in checks.cpp.

@@ -49,7 +34,7 @@ namespace vcpkg
std::string to_string() const;
void to_string(std::string& out) const;

StringView substr(size_t pos, size_t count = std::numeric_limits<size_t>::max()) const noexcept;
StringView substr(size_t pos, size_t count = static_cast<size_t>(-1)) const noexcept;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like this change.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without this change we need to add #include <limits> and we were trying to make this header very small?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that we're using PCHs, I don't have a huge issue with using standard headers, even if they're pretty large. However, I won't block this change if you feel strongly about it.


file_stream.close();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why aren't we just letting the RAII do its thing? (not a change from your PR, but while you're editing anyways)

@@ -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::exit_maybe_upgrade(VCPKG_LINE_INFO, "unexpected vcpkg::System::CPUArchitecture");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
default: Checks::exit_maybe_upgrade(VCPKG_LINE_INFO, "unexpected vcpkg::System::CPUArchitecture");
default: Checks::unexpected(VCPKG_LINE_INFO);

This is an enumeration, if a value is not in the list then that's a coding error.

@BillyONeal BillyONeal merged commit 4d136ef into microsoft:master Jan 20, 2021
@BillyONeal BillyONeal deleted the vcpkg_version branch January 20, 2021 20:11
BillyONeal added a commit to BillyONeal/vcpkg that referenced this pull request Feb 3, 2021
utilities.cmake: Disable warnings that are firing on Azure Pipelines CI machines due to different Clang version.

expected.h: Fix a bug I introduced in microsoft#15638 because I was under the impression expected worked like optional (in that value_or_exit for it should be treated as a program bug)

build.cpp: Add (void)s to silence warnings.

binarycaching.cpp: Repair assumption that the current directory is C: which isn't true on the Hosted Azure Pipelines agents.

others: Make unit tests respect %VCPKG_ROOT%, as necessary in the vcpkg_tool repo. Note that this required splitting vcpkgcmdarguments::ImbueFromEnvironment into the once-only process modifying part and the just imbue from environment part.
BillyONeal added a commit to microsoft/vcpkg-tool that referenced this pull request Feb 3, 2021
utilities.cmake: Disable warnings that are firing on Azure Pipelines CI machines due to different Clang version.

expected.h: Fix a bug I introduced in microsoft/vcpkg#15638 because I was under the impression expected worked like optional (in that value_or_exit for it should be treated as a program bug)

build.cpp: Add (void)s to silence warnings.

binarycaching.cpp: Repair assumption that the current directory is C: which isn't true on the Hosted Azure Pipelines agents.

others: Make unit tests respect %VCPKG_ROOT%, as necessary in the vcpkg_tool repo. Note that this required splitting vcpkgcmdarguments::ImbueFromEnvironment into the once-only process modifying part and the just imbue from environment part.
BillyONeal added a commit that referenced this pull request Feb 3, 2021
utilities.cmake: Disable warnings that are firing on Azure Pipelines CI machines due to different Clang version.

expected.h: Fix a bug I introduced in #15638 because I was under the impression expected worked like optional (in that value_or_exit for it should be treated as a program bug)

build.cpp: Add (void)s to silence warnings.

binarycaching.cpp: Repair assumption that the current directory is C: which isn't true on the Hosted Azure Pipelines agents.

others: Make unit tests respect %VCPKG_ROOT%, as necessary in the vcpkg_tool repo. Note that this required splitting vcpkgcmdarguments::ImbueFromEnvironment into the once-only process modifying part and the just imbue from environment part.
BillyONeal added a commit to microsoft/vcpkg-tool that referenced this pull request Feb 3, 2021
utilities.cmake: Disable warnings that are firing on Azure Pipelines CI machines due to different Clang version.

expected.h: Fix a bug I introduced in microsoft/vcpkg#15638 because I was under the impression expected worked like optional (in that value_or_exit for it should be treated as a program bug)

build.cpp: Add (void)s to silence warnings.

binarycaching.cpp: Repair assumption that the current directory is C: which isn't true on the Hosted Azure Pipelines agents.

others: Make unit tests respect %VCPKG_ROOT%, as necessary in the vcpkg_tool repo. Note that this required splitting vcpkgcmdarguments::ImbueFromEnvironment into the once-only process modifying part and the just imbue from environment part.
Sungeun0318 pushed a commit to Sungeun0318/-vcpkg that referenced this pull request May 15, 2024
utilities.cmake: Disable warnings that are firing on Azure Pipelines CI machines due to different Clang version.

expected.h: Fix a bug I introduced in microsoft/vcpkg#15638 because I was under the impression expected worked like optional (in that value_or_exit for it should be treated as a program bug)

build.cpp: Add (void)s to silence warnings.

binarycaching.cpp: Repair assumption that the current directory is C: which isn't true on the Hosted Azure Pipelines agents.

others: Make unit tests respect %VCPKG_ROOT%, as necessary in the vcpkg_tool repo. Note that this required splitting vcpkgcmdarguments::ImbueFromEnvironment into the once-only process modifying part and the just imbue from environment part.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:vcpkg-feature The issue is a new capability of the tool that doesn’t already exist and we haven’t committed info:internal This PR or Issue was filed by the vcpkg team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants