diff options
| author | ras0219 <533828+ras0219@users.noreply.github.com> | 2020-12-01 13:18:42 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-12-01 13:18:42 -0800 |
| commit | f92bf6ee1ec327799c0b1b5efac2365fb7004237 (patch) | |
| tree | 421f34e7f0f23e8638eaaa0d1f7c6cf1796df233 | |
| parent | f8baf4862946195b6efa7fc9959cd4b7fe026f8e (diff) | |
| download | vcpkg-f92bf6ee1ec327799c0b1b5efac2365fb7004237.tar.gz vcpkg-f92bf6ee1ec327799c0b1b5efac2365fb7004237.zip | |
[vcpkg] Output versions during install plans (#14882)
* [vcpkg] Output versions during install plans
* [vcpkg] Display versions for already-installed packages
Co-authored-by: Robert Schumacher <roschuma@microsoft.com>
| -rw-r--r-- | toolsrc/include/vcpkg/sourceparagraph.h | 6 | ||||
| -rw-r--r-- | toolsrc/src/vcpkg/dependencies.cpp | 68 |
2 files changed, 42 insertions, 32 deletions
diff --git a/toolsrc/include/vcpkg/sourceparagraph.h b/toolsrc/include/vcpkg/sourceparagraph.h index 2152e0237..ee07826bb 100644 --- a/toolsrc/include/vcpkg/sourceparagraph.h +++ b/toolsrc/include/vcpkg/sourceparagraph.h @@ -74,6 +74,8 @@ namespace vcpkg Json::Object extra_info; + VersionT to_versiont() const { return VersionT{version, port_version}; } + friend bool operator==(const SourceParagraph& lhs, const SourceParagraph& rhs); friend bool operator!=(const SourceParagraph& lhs, const SourceParagraph& rhs) { return !(lhs == rhs); } }; @@ -104,6 +106,8 @@ namespace vcpkg Optional<std::string> check_against_feature_flags(const fs::path& origin, const FeatureFlagSettings& flags) const; + VersionT to_versiont() const { return core_paragraph->to_versiont(); } + friend bool operator==(const SourceControlFile& lhs, const SourceControlFile& rhs); friend bool operator!=(const SourceControlFile& lhs, const SourceControlFile& rhs) { return !(lhs == rhs); } }; @@ -132,6 +136,8 @@ namespace vcpkg return {std::make_unique<SourceControlFile>(source_control_file->clone()), source_location}; } + VersionT to_versiont() const { return source_control_file->to_versiont(); } + std::unique_ptr<SourceControlFile> source_control_file; fs::path source_location; }; diff --git a/toolsrc/src/vcpkg/dependencies.cpp b/toolsrc/src/vcpkg/dependencies.cpp index 117a05209..7d69becdf 100644 --- a/toolsrc/src/vcpkg/dependencies.cpp +++ b/toolsrc/src/vcpkg/dependencies.cpp @@ -311,47 +311,52 @@ namespace vcpkg::Dependencies static std::string to_output_string(RequestType request_type, const CStringView s, const Build::BuildPackageOptions& options, - const fs::path& install_port_path, + const SourceControlFileLocation* scfl, + const InstalledPackageView* ipv, const fs::path& builtin_ports_dir) { - if (!builtin_ports_dir.empty() && !Strings::case_insensitive_ascii_starts_with(fs::u8string(install_port_path), - fs::u8string(builtin_ports_dir))) + std::string ret; + switch (request_type) + { + case RequestType::AUTO_SELECTED: Strings::append(ret, " * "); break; + case RequestType::USER_REQUESTED: Strings::append(ret, " "); break; + default: Checks::unreachable(VCPKG_LINE_INFO); + } + Strings::append(ret, s); + if (scfl) + { + Strings::append(ret, " -> ", scfl->to_versiont()); + } + else if (ipv) { - const char* const from_head = options.use_head_version == Build::UseHeadVersion::YES ? " (from HEAD)" : ""; - switch (request_type) + Strings::append(ret, " -> ", VersionT{ipv->core->package.version, ipv->core->package.port_version}); + } + if (options.use_head_version == Build::UseHeadVersion::YES) + { + Strings::append(ret, " (+HEAD)"); + } + if (scfl) + { + const auto s_install_port_path = fs::u8string(scfl->source_location); + if (!builtin_ports_dir.empty() && + !Strings::case_insensitive_ascii_starts_with(s_install_port_path, fs::u8string(builtin_ports_dir))) { - case RequestType::AUTO_SELECTED: - return Strings::format(" * %s%s -- %s", s, from_head, fs::u8string(install_port_path)); - case RequestType::USER_REQUESTED: - return Strings::format(" %s%s -- %s", s, from_head, fs::u8string(install_port_path)); - default: Checks::unreachable(VCPKG_LINE_INFO); + Strings::append(ret, " -- ", s_install_port_path); } } - return to_output_string(request_type, s, options); + return ret; } std::string to_output_string(RequestType request_type, const CStringView s, const Build::BuildPackageOptions& options) { - const char* const from_head = options.use_head_version == Build::UseHeadVersion::YES ? " (from HEAD)" : ""; - - switch (request_type) - { - case RequestType::AUTO_SELECTED: return Strings::format(" * %s%s", s, from_head); - case RequestType::USER_REQUESTED: return Strings::format(" %s%s", s, from_head); - default: Checks::unreachable(VCPKG_LINE_INFO); - } + return to_output_string(request_type, s, options, {}, {}, {}); } std::string to_output_string(RequestType request_type, const CStringView s) { - switch (request_type) - { - case RequestType::AUTO_SELECTED: return Strings::format(" * %s", s); - case RequestType::USER_REQUESTED: return Strings::format(" %s", s); - default: Checks::unreachable(VCPKG_LINE_INFO); - } + return to_output_string(request_type, s, {Build::UseHeadVersion::NO}, {}, {}, {}); } InstallPlanAction::InstallPlanAction() noexcept @@ -1096,13 +1101,12 @@ namespace vcpkg::Dependencies static auto actions_to_output_string = [&](const std::vector<const InstallPlanAction*>& v) { return Strings::join("\n", v, [&](const InstallPlanAction* p) { - if (auto* pscfl = p->source_control_file_location.get()) - { - return to_output_string( - p->request_type, p->displayname(), p->build_options, pscfl->source_location, builtin_ports_dir); - } - - return to_output_string(p->request_type, p->displayname(), p->build_options); + return to_output_string(p->request_type, + p->displayname(), + p->build_options, + p->source_control_file_location.get(), + p->installed_package.get(), + builtin_ports_dir); }); }; |
