From 4f8fb510ba03f195a49f6353b97fabf5bb20d450 Mon Sep 17 00:00:00 2001 From: ras0219 <533828+ras0219@users.noreply.github.com> Date: Fri, 15 Jan 2021 12:35:48 -0800 Subject: [vcpkg] Add initial versioning documentation (#15565) * [vcpkg] Improve efficiency and tests of versioning * [vcpkg] Add initial versioning documentation and rename x-default-baseline to builtin-baseline * [vcpkg] Enable metrics for builtin-baseline & overrides * [vcpkg] Address PR comments * [vcpkg] Add support for syntax in version>= * [vcpkg] Remove port-version from dependency syntax * [vcpkg] Address CR comment * [vcpkg] Minor docs fixup --- toolsrc/include/vcpkg/base/expected.h | 9 ++++----- toolsrc/include/vcpkg/base/files.h | 33 +++++++++++---------------------- toolsrc/include/vcpkg/base/json.h | 4 +++- toolsrc/include/vcpkg/base/jsonreader.h | 2 +- toolsrc/include/vcpkg/sourceparagraph.h | 1 + toolsrc/include/vcpkg/vcpkgpaths.h | 15 ++++++--------- toolsrc/include/vcpkg/versions.h | 3 +-- 7 files changed, 27 insertions(+), 40 deletions(-) (limited to 'toolsrc/include') diff --git a/toolsrc/include/vcpkg/base/expected.h b/toolsrc/include/vcpkg/base/expected.h index 13e7b4bcb..20c23f077 100644 --- a/toolsrc/include/vcpkg/base/expected.h +++ b/toolsrc/include/vcpkg/base/expected.h @@ -226,11 +226,10 @@ namespace vcpkg 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. - Checks::check_exit(line_info, - !m_s.has_error(), - "Failed at [%s] with message:\n%s", - line_info.to_string(), - m_s.to_string()); + if (m_s.has_error()) + { + Checks::exit_with_message(line_info, "Failed at [%s] with message:\n%s", line_info, m_s.to_string()); + } } ErrorHolder m_s; diff --git a/toolsrc/include/vcpkg/base/files.h b/toolsrc/include/vcpkg/base/files.h index dd1b3a6c6..5f2e96e91 100644 --- a/toolsrc/include/vcpkg/base/files.h +++ b/toolsrc/include/vcpkg/base/files.h @@ -282,45 +282,34 @@ namespace vcpkg::Files }; ExclusiveFileLock() = default; - ExclusiveFileLock(ExclusiveFileLock&& other) - : fs_(other.fs_), handle_(std::exchange(handle_, fs::SystemHandle{})) - { - } - ExclusiveFileLock& operator=(ExclusiveFileLock&& other) - { - if (this == &other) return *this; - - clear(); - fs_ = other.fs_; - handle_ = std::exchange(other.handle_, fs::SystemHandle{}); - return *this; - } + ExclusiveFileLock(ExclusiveFileLock&&) = delete; + ExclusiveFileLock& operator=(ExclusiveFileLock&&) = delete; - ExclusiveFileLock(Wait wait, Filesystem& fs, const fs::path& path_, std::error_code& ec) : fs_(&fs) + ExclusiveFileLock(Wait wait, Filesystem& fs, const fs::path& path_, std::error_code& ec) : m_fs(&fs) { switch (wait) { - case Wait::Yes: handle_ = fs_->take_exclusive_file_lock(path_, ec); break; - case Wait::No: handle_ = fs_->try_take_exclusive_file_lock(path_, ec); break; + case Wait::Yes: m_handle = m_fs->take_exclusive_file_lock(path_, ec); break; + case Wait::No: m_handle = m_fs->try_take_exclusive_file_lock(path_, ec); break; } } ~ExclusiveFileLock() { clear(); } - explicit operator bool() const { return handle_.is_valid(); } - bool has_lock() const { return handle_.is_valid(); } + explicit operator bool() const { return m_handle.is_valid(); } + bool has_lock() const { return m_handle.is_valid(); } void clear() { - if (fs_ && handle_.is_valid()) + if (m_fs && m_handle.is_valid()) { std::error_code ignore; - fs_->unlock_file_lock(std::exchange(handle_, fs::SystemHandle{}), ignore); + m_fs->unlock_file_lock(std::exchange(m_handle, fs::SystemHandle{}), ignore); } } private: - fs::SystemHandle handle_; - Filesystem* fs_; + Filesystem* m_fs; + fs::SystemHandle m_handle; }; } diff --git a/toolsrc/include/vcpkg/base/json.h b/toolsrc/include/vcpkg/base/json.h index e7f3076f7..31696b757 100644 --- a/toolsrc/include/vcpkg/base/json.h +++ b/toolsrc/include/vcpkg/base/json.h @@ -291,7 +291,9 @@ namespace vcpkg::Json ExpectedT, std::unique_ptr> parse_file( const Files::Filesystem&, const fs::path&, std::error_code& ec) noexcept; ExpectedT, std::unique_ptr> parse( - StringView text, const fs::path& filepath = {}) noexcept; + StringView text, const fs::path& filepath) noexcept; + ExpectedT, std::unique_ptr> parse(StringView text, + StringView origin = {}) noexcept; std::pair parse_file(vcpkg::LineInfo linfo, const Files::Filesystem&, const fs::path&) noexcept; std::string stringify(const Value&, JsonStyle style); diff --git a/toolsrc/include/vcpkg/base/jsonreader.h b/toolsrc/include/vcpkg/base/jsonreader.h index da086fa02..4aca02998 100644 --- a/toolsrc/include/vcpkg/base/jsonreader.h +++ b/toolsrc/include/vcpkg/base/jsonreader.h @@ -278,7 +278,7 @@ namespace vcpkg::Json struct NaturalNumberDeserializer final : IDeserializer { - virtual StringView type_name() const override { return "a natural number"; } + virtual StringView type_name() const override { return "a nonnegative integer"; } virtual Optional visit_integer(Reader&, int64_t value) override { diff --git a/toolsrc/include/vcpkg/sourceparagraph.h b/toolsrc/include/vcpkg/sourceparagraph.h index f2dd0798b..52ce53980 100644 --- a/toolsrc/include/vcpkg/sourceparagraph.h +++ b/toolsrc/include/vcpkg/sourceparagraph.h @@ -69,6 +69,7 @@ namespace vcpkg std::vector overrides; std::vector default_features; std::string license; // SPDX license expression + Optional builtin_baseline; Type type; PlatformExpression::Expr supports_expression; diff --git a/toolsrc/include/vcpkg/vcpkgpaths.h b/toolsrc/include/vcpkg/vcpkgpaths.h index 36447b9f3..d36ebfb7c 100644 --- a/toolsrc/include/vcpkg/vcpkgpaths.h +++ b/toolsrc/include/vcpkg/vcpkgpaths.h @@ -118,8 +118,12 @@ namespace vcpkg const std::string& get_tool_version(const std::string& tool) const; // Git manipulation in the vcpkg directory - fs::path git_checkout_baseline(Files::Filesystem& filesystem, StringView commit_sha) const; - fs::path git_checkout_port(Files::Filesystem& filesystem, StringView port_name, StringView git_tree) const; + ExpectedS get_current_git_sha() const; + std::string get_current_git_sha_message() const; + ExpectedS git_checkout_baseline(StringView commit_sha) const; + ExpectedS git_checkout_port(StringView port_name, + StringView git_tree, + const fs::path& dot_git_dir) const; ExpectedS git_show(const std::string& treeish, const fs::path& dot_git_dir) const; ExpectedS>> git_get_local_port_treeish_map() const; @@ -168,12 +172,5 @@ namespace vcpkg const fs::path& destination, const fs::path& dot_git_dir, const fs::path& work_tree); - - static void git_checkout_object(const VcpkgPaths& paths, - StringView git_object, - const fs::path& local_repo, - const fs::path& destination, - const fs::path& dot_git_dir, - const fs::path& work_tree); }; } diff --git a/toolsrc/include/vcpkg/versions.h b/toolsrc/include/vcpkg/versions.h index 19b5546ea..b26c90dfb 100644 --- a/toolsrc/include/vcpkg/versions.h +++ b/toolsrc/include/vcpkg/versions.h @@ -81,8 +81,7 @@ namespace vcpkg::Versions enum class Type { None, - Minimum, - Exact + Minimum }; }; } -- cgit v1.2.3