Commit 5f42d9b7 authored by brettw's avatar brettw Committed by Commit bot

Reverse the order of GN's cycle printing.

When printing dependency cycles, the old meticulously walked the list backwards and explained that this was because the list was in the reverse order of the dependencies.

This is wrong, the list is in the normal forward direction and doing that prints out the reverse cycle which is very confusing. Reverse the order of printing to get the correct cycle.

Review URL: https://codereview.chromium.org/557103003

Cr-Commit-Position: refs/heads/master@{#294436}
parent 91b13af6
...@@ -208,7 +208,7 @@ bool Builder::CheckForBadItems(Err* err) const { ...@@ -208,7 +208,7 @@ bool Builder::CheckForBadItems(Err* err) const {
if (depstring.empty()) { if (depstring.empty()) {
// Something's very wrong, just dump out the bad nodes. // Something's very wrong, just dump out the bad nodes.
depstring = "I have no idea what went wrong, but these are unresolved, " depstring = "I have no idea what went wrong, but these are unresolved, "
"possible due to an\ninternal error:"; "possibly due to an\ninternal error:";
for (size_t i = 0; i < bad_records.size(); i++) { for (size_t i = 0; i < bad_records.size(); i++) {
depstring += "\n\"" + depstring += "\n\"" +
bad_records[i]->label().GetUserVisibleName(false) + "\""; bad_records[i]->label().GetUserVisibleName(false) + "\"";
...@@ -526,12 +526,12 @@ std::string Builder::CheckForCircularDependencies( ...@@ -526,12 +526,12 @@ std::string Builder::CheckForCircularDependencies(
if (!RecursiveFindCycle(bad_records[0], &cycle)) if (!RecursiveFindCycle(bad_records[0], &cycle))
return std::string(); // Didn't find a cycle, something else is wrong. return std::string(); // Didn't find a cycle, something else is wrong.
// Walk backwards since the dependency arrows point in the reverse direction.
std::string ret; std::string ret;
for (int i = static_cast<int>(cycle.size()) - 1; i >= 0; i--) { for (size_t i = 0; i < cycle.size(); i++) {
ret += " " + cycle[i]->label().GetUserVisibleName(false); ret += " " + cycle[i]->label().GetUserVisibleName(false);
if (i != 0) if (i != cycle.size() - 1)
ret += " ->\n"; ret += " ->";
ret += "\n";
} }
return ret; return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment