mirror of
https://github.com/microsoft/vcpkg.git
synced 2024-12-28 11:21:12 +08:00
[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>
This commit is contained in:
parent
f8baf48629
commit
f92bf6ee1e
@ -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;
|
||||
};
|
||||
|
@ -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)
|
||||
{
|
||||
const char* const from_head = options.use_head_version == Build::UseHeadVersion::YES ? " (from HEAD)" : "";
|
||||
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)
|
||||
{
|
||||
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);
|
||||
});
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user