meson introspect: Query Build Metadata
meson introspect prints machine-readable JSON about a Meson project: its targets, tests, options, and dependencies.
When CI needs to reason about a Meson build, for example listing targets to package or checking configured options, introspect gives structured JSON instead of scraping human output.
What it does
meson introspect reads a build directory (or source meson.build) and emits JSON for the requested aspect: targets and their output paths, the test list, configured build options, or resolved dependencies. It is the API tooling uses to inspect a build.
Common usage
meson introspect build --targets
meson introspect build --tests
meson introspect build --buildoptions
meson introspect build --projectinfoOptions
| Flag | What it does |
|---|---|
| --targets | List build targets and their output filenames |
| --tests | List registered tests and their commands |
| --buildoptions | List configured options and their values |
| --dependencies | List resolved external dependencies |
| --projectinfo | Project name, version, and subprojects |
| -i / --indent | Pretty-print the JSON output |
In CI
Pipe introspect JSON through jq to find output artifacts to upload, or to assert an option was configured as expected (e.g. that -Db_sanitize was applied). Run it against the build dir after setup; it does not require a build.
Common errors in CI
"Current directory is not a meson build directory." means the argument does not point at a configured build dir. Empty results for --tests mean no test() calls exist. If jq errors on the output, add --indent for valid multi-line JSON or make sure only introspect output (not warnings on stderr) is piped in.