Skip to content
Latchkey

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

Terminal
meson introspect build --targets
meson introspect build --tests
meson introspect build --buildoptions
meson introspect build --projectinfo

Options

FlagWhat it does
--targetsList build targets and their output filenames
--testsList registered tests and their commands
--buildoptionsList configured options and their values
--dependenciesList resolved external dependencies
--projectinfoProject name, version, and subprojects
-i / --indentPretty-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.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →