diff options
| author | Paolo Bonzini <pbonzini@redhat.com> | 2025-09-02 06:40:04 +0200 |
|---|---|---|
| committer | Eli Schwartz <eschwartz93@gmail.com> | 2025-09-09 09:23:04 -0400 |
| commit | e0ea239397ab585c8490ca704b14ce2bf66ed7c4 (patch) | |
| tree | 2093dc60ddf4676990aa0ed2e5cb2549e340513a | |
| parent | 6174a49522cb3d7b9f925d96ca68c390cb833594 (diff) | |
| download | meson-e0ea239397ab585c8490ca704b14ce2bf66ed7c4.tar.gz | |
msetup: not-found subprojects do not have known options
If a subproject had its SubprojectHolder created, but was disabled, its options were not
parsed; therefore the subproject should not be checked for unknown options.
Fixes: #14969
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
| -rw-r--r-- | mesonbuild/msetup.py | 5 | ||||
| -rw-r--r-- | test cases/common/42 subproject/meson.build | 4 | ||||
| -rw-r--r-- | test cases/common/42 subproject/meson.options | 1 | ||||
| -rw-r--r-- | test cases/common/42 subproject/subprojects/subunused/meson.build | 1 | ||||
| -rw-r--r-- | test cases/common/42 subproject/subprojects/subunused/meson.options | 1 | ||||
| -rw-r--r-- | test cases/common/42 subproject/test.json | 9 |
6 files changed, 18 insertions, 3 deletions
diff --git a/mesonbuild/msetup.py b/mesonbuild/msetup.py index 8d7dd0bbf..f1fa777d1 100644 --- a/mesonbuild/msetup.py +++ b/mesonbuild/msetup.py @@ -16,6 +16,7 @@ from .options import OptionKey if T.TYPE_CHECKING: from typing_extensions import Protocol from .coredata import SharedCMDOptions + from .interpreter import SubprojectHolder class CMDOptions(SharedCMDOptions, Protocol): @@ -192,9 +193,9 @@ class MesonApp: 'Some other Meson process is already using this build directory. Exiting.'): return self._generate(env, capture, vslite_ctx) - def check_unused_options(self, coredata: 'coredata.CoreData', cmd_line_options: T.Dict[OptionKey, str], all_subprojects: T.Mapping[str, object]) -> None: + def check_unused_options(self, coredata: 'coredata.CoreData', cmd_line_options: T.Dict[OptionKey, str], all_subprojects: T.Mapping[str, SubprojectHolder]) -> None: errlist: T.List[str] = [] - known_subprojects = all_subprojects.keys() + known_subprojects = [name for name, obj in all_subprojects.items() if obj.found()] for opt in cmd_line_options: # Accept options that exist or could appear in subsequent reconfigurations, # including options for subprojects that were not used diff --git a/test cases/common/42 subproject/meson.build b/test cases/common/42 subproject/meson.build index bc24adbcc..be2d90f7c 100644 --- a/test cases/common/42 subproject/meson.build +++ b/test cases/common/42 subproject/meson.build @@ -8,6 +8,7 @@ project('subproj user', 'c', assert(meson.project_name() == 'subproj user', 'Incorrect project name') sub = subproject('sublib', version : '1.0.0') +assert(sub.found()) if meson.project_version() != '2.3.4' error('Incorrect master project version string:' + meson.project_version()) @@ -29,3 +30,6 @@ unknown_var = sub.get_variable('does-not-exist', []) if unknown_var != [] error ('unexpected fallback value for subproject.get_variable()') endif + +unusedsub = subproject('subunused', required: get_option('disabled_feature')) +assert(not unusedsub.found()) diff --git a/test cases/common/42 subproject/meson.options b/test cases/common/42 subproject/meson.options new file mode 100644 index 000000000..ae9a39fb1 --- /dev/null +++ b/test cases/common/42 subproject/meson.options @@ -0,0 +1 @@ +option('disabled_feature', type: 'feature', value: 'disabled') diff --git a/test cases/common/42 subproject/subprojects/subunused/meson.build b/test cases/common/42 subproject/subprojects/subunused/meson.build new file mode 100644 index 000000000..a42fed38b --- /dev/null +++ b/test cases/common/42 subproject/subprojects/subunused/meson.build @@ -0,0 +1 @@ +syntax error because the subproject is unused diff --git a/test cases/common/42 subproject/subprojects/subunused/meson.options b/test cases/common/42 subproject/subprojects/subunused/meson.options new file mode 100644 index 000000000..a42fed38b --- /dev/null +++ b/test cases/common/42 subproject/subprojects/subunused/meson.options @@ -0,0 +1 @@ +syntax error because the subproject is unused diff --git a/test cases/common/42 subproject/test.json b/test cases/common/42 subproject/test.json index e469052f4..7400ff4a0 100644 --- a/test cases/common/42 subproject/test.json +++ b/test cases/common/42 subproject/test.json @@ -7,5 +7,12 @@ {"type": "file", "file": "usr/share/sublib/COPYING"}, {"type": "file", "file": "usr/share/sublib/subprojects/sublib/sublicense1.txt"}, {"type": "file", "file": "usr/share/sublib/subprojects/sublib/sublicense2.txt"} - ] + ], + "matrix": { + "options": { + "subunused:opt1": [ + { "val": "42" } + ] + } + } } |
