GN: Prefer toplevel targets for phony names.

This rewrites the phony target generation in GN to be more scalable. Previously there were two loops and it ahd a lot of conditions in the loop for when to generate certain names. This was subtle and difficult to maintain as we added more variants.

The new scheme has many passes, each lower in priority, that generate rules only if the name hasn't already been taken by something else. This is much easier to reason about and enhance. The new code also accounts for collisions among all output files (previously only some things checked for output file collisions).

In this new scheme we now allow toplevel targets like "//:foo" to claim the name "foo" even when there are multiple things called "foo", as long as none of them are executables or duplicate an output name. This results in some minor and not-material changes in ordering and formatting in the output.

This now uses PathOutput for all file names (previously the "all" rule just wrote the names directly, which could miss some escaping). As a result, some paths have changed slightly but not in meaningful ways.

Doing basic sorting of the files before and after and removing " ./" gives the same set of rules in the current build before and after this change.

Review-Url: https://codereview.chromium.org/1958783003
Cr-Original-Commit-Position: refs/heads/master@{#392491}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 66bbbab9be0a7ecf97c124b24d2be4bc7975a0a5
3 files changed
tree: d23a19dda1a4e87e3b2fd8358b252d39c6b53dc1
  1. tools/