Skip to content

Commit 4bd7d63

Browse files
bonzinieli-schwartz
authored andcommitted
options: allow setting subproject options in subproject() call
Something like subproject('sub', default_options: ['sub2:from_subp=true']) will cause an assertion failure due to "key.subproject is None" obviously being false. Just support this, since it's easy to do so. (cherry picked from commit 8e2e5c5)
1 parent de70eb2 commit 4bd7d63

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

mesonbuild/options.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1418,15 +1418,18 @@ def initialize_from_subproject_call(self,
14181418
for o in itertools.chain(project_default_options, spcall_default_options):
14191419
keystr, valstr = o.split('=', 1)
14201420
key = OptionKey.from_string(keystr)
1421-
assert key.subproject is None
1422-
key = key.evolve(subproject=subproject)
1421+
if key.subproject is None:
1422+
key = key.evolve(subproject=subproject)
1423+
elif key.subproject == subproject:
1424+
without_subp = key.evolve(subproject=None)
1425+
raise MesonException(f'subproject name not needed in default_options; use "{without_subp}" instead of "{key}"')
14231426
# If the key points to a project option, set the value from that.
14241427
# Otherwise set an augment.
14251428
if key in self.project_options:
14261429
self.set_option(key, valstr, is_first_invocation)
14271430
else:
14281431
self.pending_options.pop(key, None)
1429-
aug_str = f'{subproject}:{keystr}'
1432+
aug_str = str(key)
14301433
self.augments[aug_str] = valstr
14311434
# Check for pending options
14321435
assert isinstance(cmd_line_options, dict)

0 commit comments

Comments
 (0)