Skip to content

Source-only introspection ignores default_options passed to subprojects #15994

Description

@MaxandreOgeret

Describe the bug
Source-only introspection (meson introspect --buildoptions meson.build, without a configured build dir) lists subproject options with the subproject's own default values, ignoring values the parent project passes down via default_options (either in the subproject() call or as sub:opt=... in the project() call).

The IntrospectionInterpreter (mesonbuild/ast/introspection.py) collects option definitions from each subproject but never applies the parent's default_options, unlike the real interpreter which resolves them via initialize_from_subproject_call(). After a real meson setup, introspection from the build dir reports the correct value.

To Reproduce

mkdir -p repro/subprojects/sub && cd repro
cat > meson.build <<'MESON'
project('main', 'c')
subproject('sub', default_options: ['myopt=fromparent'])
MESON
cat > subprojects/sub/meson.build <<'MESON'
project('sub', 'c')
MESON
cat > subprojects/sub/meson_options.txt <<'MESON'
option('myopt', type: 'string', value: 'default')
MESON
meson introspect --buildoptions meson.build
# reports sub:myopt = "default"

meson setup build
meson introspect --buildoptions build
# reports sub:myopt = "fromparent" (correct)

Expected behavior
Source-only introspection reports the value that a real configuration would use, i.e. sub:myopt = fromparent.

system parameters

  • Plain native build
  • Debian GNU/Linux (forky/sid)
  • Python 3.13.14
  • meson 1.10.0, also reproduced on current master (1.12.0.rc1, 2b4f5dc)
  • ninja 1.13.2 (not relevant, no build dir needed)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions