summaryrefslogtreecommitdiff
path: root/mesonbuild
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2025-05-03 18:21:55 +0200
committerDylan Baker <dylan@pnwbakers.com>2025-05-06 13:21:24 -0700
commit8e2e5c52d00c014ffb90464fa09633fb2a0cc6a4 (patch)
tree28c43a9ab0e69d05d4588e361d394286e78640ca /mesonbuild
parent1a6a9d603248a2f8b659ab80b0bdbe4f0e74cb64 (diff)
downloadmeson-8e2e5c52d00c014ffb90464fa09633fb2a0cc6a4.tar.gz
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.
Diffstat (limited to 'mesonbuild')
-rw-r--r--mesonbuild/options.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/mesonbuild/options.py b/mesonbuild/options.py
index 352494df5..8a6387894 100644
--- a/mesonbuild/options.py
+++ b/mesonbuild/options.py
@@ -1412,15 +1412,18 @@ class OptionStore:
for o in itertools.chain(project_default_options, spcall_default_options):
keystr, valstr = o.split('=', 1)
key = OptionKey.from_string(keystr)
- assert key.subproject is None
- key = key.evolve(subproject=subproject)
+ if key.subproject is None:
+ key = key.evolve(subproject=subproject)
+ elif key.subproject == subproject:
+ without_subp = key.evolve(subproject=None)
+ raise MesonException(f'subproject name not needed in default_options; use "{without_subp}" instead of "{key}"')
# If the key points to a project option, set the value from that.
# Otherwise set an augment.
if key in self.project_options:
self.set_option(key, valstr, is_first_invocation)
else:
self.pending_options.pop(key, None)
- aug_str = f'{subproject}:{keystr}'
+ aug_str = str(key)
self.augments[aug_str] = valstr
# Check for pending options
assert isinstance(cmd_line_options, dict)