gn_desc: A tool for rapidly querying the GN build graphThe gn_desc cli tool uses the project.json produced by GN to more rapidly query GN's build graph than can be done using fx gn desc.
To list targets that match a pattern:
fx gn_desc -v --file out/default/project.json match <pattern> list
The <pattern> is a regex.
If the GN files have been changed, and a build hasn't been performed, run fx gen to update project.json.
The tool does the following when run:
project.json filegn_desc has the following target selection mechanisms:
match <regex> - selects all targets that match the given regexmatch-file [-a|-ois] <regex> - selects all targets that have files that match the given regex:-a - any file (the default)-i - inputs-o - outputs-s - sources-x - scripts (executable things)label <label> - Selects only given label (via an exact match, including the toolchain).gn_desc has the following commands that can be run on the selected targets:
list - lists the labels of the selected targets, one per linesummarize - provides a summary description of the targets, which can be customized by various flags, see the tool's own help for more information: gn_desc --file <file> exact <label> summarize --helpPlanned future commands are:
dep-tree - prints an ascii-art or dot-file format dependency treefile-tree - prints an ascii-art or dor-file format file input->output treemetadata query - performs a metadata-query similar to what gn doesPlanned future selectors are:
match-metadata - selects all targets that have a given metadata key