This document explains how to use the Component Catalog to answer some questions about components in the build graph.
This guide assumes that you already configured your args.gn
, such as using an fx set
command, for instance fx set core.x64
.
To regenerate all component catalog reports, use fx gen
.
All reports have the filename suffix .component_catalog.json
. To find all reports, you can use for instance:
find $(fx get-build-dir) -name "*.component_catalog.json"
The directory structure generally follows the target names. For instance a component target //foo/bar:qux
will emit $(fx get-build-dir)/obj/foo/bar/qux_component_catalog.json
.
The Component Catalog is presented in human-readable JSON for some definition of human and readable.
To clean stale metadata reports (such as from a previous build), you may use fx clean
.
A report might look as follows:
[ { "label": "//sdk/lib/syslog/cpp:backend(//build/toolchain/fuchsia:x64)", "sdk_id": "sdk://pkg/syslog_cpp_backend" }, { "has_cxx": true, "label": "//src/developer/debug/debug_agent:bin(//build/toolchain/fuchsia:x64)" }, { "has_cxx": true, "label": "//src/developer/debug/debug_agent:launcher(//build/toolchain/fuchsia:x64)" }, { "component_manifest_path": "meta/debug_agent.cml", "label": "//src/developer/debug/debug_agent:debug_agent-component_manifest_compile(//build/toolchain/fuchsia:x64)" } ]
Each clause tells you something about some aspect of the component. Clauses have a label associated with them for troubleshooting reasons. This indicates where the metadata was defined. Clauses with has_*
keys indicate some additive boolean aspect of the component. For instance in the example above we see two clauses that indicate that this component has C++ code. Clauses with sdk_id
indicate an SDK atom that is used by this component.
Use fx gn meta
for more information on how metadata is generated. For instance:
fx gn meta $(fx get-build-dir) sdk/lib/input_report_reader:input_report_test --data=component_catalog
This should print the same information as what's presented in the generated file, but additionally list all the targets that had metadata collected from.
Use component_catalog.py
to harvest all component catalog files in the tree and produce a single table in CSV format.