Skip to content

Commit e0ea239

Browse files
bonzinieli-schwartz
authored andcommitted
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 <[email protected]>
1 parent 6174a49 commit e0ea239

File tree

6 files changed

+18
-3
lines changed

6 files changed

+18
-3
lines changed

mesonbuild/msetup.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
if T.TYPE_CHECKING:
1717
from typing_extensions import Protocol
1818
from .coredata import SharedCMDOptions
19+
from .interpreter import SubprojectHolder
1920

2021
class CMDOptions(SharedCMDOptions, Protocol):
2122

@@ -192,9 +193,9 @@ def generate(self, capture: bool = False, vslite_ctx: T.Optional[dict] = None) -
192193
'Some other Meson process is already using this build directory. Exiting.'):
193194
return self._generate(env, capture, vslite_ctx)
194195

195-
def check_unused_options(self, coredata: 'coredata.CoreData', cmd_line_options: T.Dict[OptionKey, str], all_subprojects: T.Mapping[str, object]) -> None:
196+
def check_unused_options(self, coredata: 'coredata.CoreData', cmd_line_options: T.Dict[OptionKey, str], all_subprojects: T.Mapping[str, SubprojectHolder]) -> None:
196197
errlist: T.List[str] = []
197-
known_subprojects = all_subprojects.keys()
198+
known_subprojects = [name for name, obj in all_subprojects.items() if obj.found()]
198199
for opt in cmd_line_options:
199200
# Accept options that exist or could appear in subsequent reconfigurations,
200201
# including options for subprojects that were not used

test cases/common/42 subproject/meson.build

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ project('subproj user', 'c',
88
assert(meson.project_name() == 'subproj user', 'Incorrect project name')
99

1010
sub = subproject('sublib', version : '1.0.0')
11+
assert(sub.found())
1112

1213
if meson.project_version() != '2.3.4'
1314
error('Incorrect master project version string:' + meson.project_version())
@@ -29,3 +30,6 @@ unknown_var = sub.get_variable('does-not-exist', [])
2930
if unknown_var != []
3031
error ('unexpected fallback value for subproject.get_variable()')
3132
endif
33+
34+
unusedsub = subproject('subunused', required: get_option('disabled_feature'))
35+
assert(not unusedsub.found())
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
option('disabled_feature', type: 'feature', value: 'disabled')
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
syntax error because the subproject is unused
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
syntax error because the subproject is unused

test cases/common/42 subproject/test.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,12 @@
77
{"type": "file", "file": "usr/share/sublib/COPYING"},
88
{"type": "file", "file": "usr/share/sublib/subprojects/sublib/sublicense1.txt"},
99
{"type": "file", "file": "usr/share/sublib/subprojects/sublib/sublicense2.txt"}
10-
]
10+
],
11+
"matrix": {
12+
"options": {
13+
"subunused:opt1": [
14+
{ "val": "42" }
15+
]
16+
}
17+
}
1118
}

0 commit comments

Comments
 (0)