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

Colorize multi-triplet dot graphs #1371

Merged
merged 3 commits into from
Apr 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions src/vcpkg/commands.depend-info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,18 @@ namespace

namespace vcpkg
{
namespace
{
const char* get_dot_element_style(const std::string& label)
{
if (!Strings::contains(label, ':')) return "";

if (Strings::ends_with(label, ":host")) return " [color=gray51 fontcolor=gray51]";

return " [color=blue fontcolor=blue]";
}
}

std::string create_dot_as_string(const std::vector<PackageDependInfo>& depend_info)
{
int empty_node_count = 0;
Expand All @@ -173,7 +185,8 @@ namespace vcpkg

for (const auto& package : depend_info)
{
fmt::format_to(std::back_inserter(s), "\"{}\";\n", package.package);
fmt::format_to(
std::back_inserter(s), "\"{}\"{};\n", package.package, get_dot_element_style(package.package));
if (package.dependencies.empty())
{
empty_node_count++;
Expand All @@ -182,7 +195,8 @@ namespace vcpkg

for (const auto& d : package.dependencies)
{
fmt::format_to(std::back_inserter(s), "\"{}\" -> \"{}\";\n", package.package, d);
fmt::format_to(
std::back_inserter(s), "\"{}\" -> \"{}\"{};\n", package.package, d, get_dot_element_style(d));
}
}

Expand Down
Loading