Skip to content

Commit

Permalink
[--overlay-ports] Show location of overriden ports during install plan (
Browse files Browse the repository at this point in the history
#7002)

* [--overlay-ports] Show source location of overlayed ports during install plan

* Code cleanup

* Code cleanup
  • Loading branch information
vicroms committed Jun 24, 2019
1 parent 4f675ea commit 9e565e9
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 9 deletions.
4 changes: 3 additions & 1 deletion toolsrc/include/vcpkg/dependencies.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,5 +199,7 @@ namespace vcpkg::Dependencies
const StatusParagraphs& status_db,
const CreateInstallPlanOptions& options = {});

void print_plan(const std::vector<AnyAction>& action_plan, const bool is_recursive = true);
void print_plan(const std::vector<AnyAction>& action_plan,
const bool is_recursive = true,
const fs::path& default_ports_dir = "");
}
2 changes: 1 addition & 1 deletion toolsrc/src/vcpkg/commands.ci.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ namespace vcpkg::Commands::CI

if (is_dry_run)
{
Dependencies::print_plan(action_plan);
Dependencies::print_plan(action_plan, true, paths.ports);
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion toolsrc/src/vcpkg/commands.upgrade.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ namespace vcpkg::Commands::Upgrade
}
}

Dependencies::print_plan(plan, true);
Dependencies::print_plan(plan, true, paths.ports);

if (!no_dry_run)
{
Expand Down
40 changes: 35 additions & 5 deletions toolsrc/src/vcpkg/dependencies.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,27 @@ namespace vcpkg::Dependencies
const PortFileProvider& m_provider;
};

std::string to_output_string(RequestType request_type,
const CStringView s,
const Build::BuildPackageOptions& options,
const fs::path& install_port_path,
const fs::path& default_port_path)
{
if (!default_port_path.empty()
&& !Strings::case_insensitive_ascii_starts_with(install_port_path.u8string(),
default_port_path.u8string()))
{
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", s, from_head, install_port_path.u8string());
case RequestType::USER_REQUESTED: return Strings::format(" %s%s -- %s", s, from_head, install_port_path.u8string());
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,
const Build::BuildPackageOptions& options)
Expand All @@ -131,7 +152,7 @@ namespace vcpkg::Dependencies

switch (request_type)
{
case RequestType::AUTO_SELECTED: return Strings::format(" * %s%s", s, from_head);
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);
}
Expand All @@ -141,7 +162,7 @@ namespace vcpkg::Dependencies
{
switch (request_type)
{
case RequestType::AUTO_SELECTED: return Strings::format(" * %s", s);
case RequestType::AUTO_SELECTED: return Strings::format(" * %s", s);
case RequestType::USER_REQUESTED: return Strings::format(" %s", s);
default: Checks::unreachable(VCPKG_LINE_INFO);
}
Expand Down Expand Up @@ -893,7 +914,7 @@ namespace vcpkg::Dependencies

PackageGraph::~PackageGraph() = default;

void print_plan(const std::vector<AnyAction>& action_plan, const bool is_recursive)
void print_plan(const std::vector<AnyAction>& action_plan, const bool is_recursive, const fs::path& default_ports_dir)
{
std::vector<const RemovePlanAction*> remove_plans;
std::vector<const InstallPlanAction*> rebuilt_plans;
Expand Down Expand Up @@ -948,8 +969,17 @@ namespace vcpkg::Dependencies
std::sort(already_installed_plans.begin(), already_installed_plans.end(), &InstallPlanAction::compare_by_name);
std::sort(excluded.begin(), excluded.end(), &InstallPlanAction::compare_by_name);

static auto actions_to_output_string = [](const std::vector<const InstallPlanAction*>& v) {
return Strings::join("\n", v, [](const InstallPlanAction* p) {
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,
default_ports_dir);
}

return to_output_string(p->request_type, p->displayname(), p->build_options);
});
};
Expand Down
2 changes: 1 addition & 1 deletion toolsrc/src/vcpkg/install.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ namespace vcpkg::Install

Metrics::g_metrics.lock()->track_property("installplan", specs_string);

Dependencies::print_plan(action_plan, is_recursive);
Dependencies::print_plan(action_plan, is_recursive, paths.ports);

if (dry_run)
{
Expand Down

0 comments on commit 9e565e9

Please sign in to comment.