summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2025-08-26 10:09:17 +0200
committerJussi Pakkanen <jussi.pakkanen@mailbox.org>2025-09-15 23:22:00 +0300
commita2111ccd2e9810ec146a8f3050983801db844a95 (patch)
treed570c0d6d160342a0092f959ac1c3ebcb9ee9ac3
parent078b8d17d4b200aa258f3b68ab33c81450486553 (diff)
downloadmeson-a2111ccd2e9810ec146a8f3050983801db844a95.tar.gz
options: put back in place 1.7 ordering of opt=value vs subp:opt=value
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r--docs/markdown/Builtin-options.md4
-rw-r--r--mesonbuild/options.py16
-rw-r--r--unittests/machinefiletests.py13
3 files changed, 13 insertions, 20 deletions
diff --git a/docs/markdown/Builtin-options.md b/docs/markdown/Builtin-options.md
index e52ba3f5d..27efbf2ae 100644
--- a/docs/markdown/Builtin-options.md
+++ b/docs/markdown/Builtin-options.md
@@ -384,10 +384,10 @@ command line: `-Dfoo:default_library=static`.
The value is overridden in this order:
- `opt=value` from parent project's `default_options`
- `opt=value` from subproject's `default_options`
-- `subp:opt=value` from parent project's default options
-- `opt=value` from `subproject()` `default_options`
- `opt=value` from machine file
- `opt=value` from command line
+- `subp:opt=value` from parent project's default options
+- `opt=value` from `subproject()` `default_options`
- `subp:opt=value` from machine file
- `subp:opt=value` from command line
diff --git a/mesonbuild/options.py b/mesonbuild/options.py
index 1b2bfc64e..0ada8432c 100644
--- a/mesonbuild/options.py
+++ b/mesonbuild/options.py
@@ -1380,6 +1380,14 @@ class OptionStore:
key = key.evolve(subproject=subproject)
options[key] = valstr
+ # then global settings from machine file and command line
+ # **but not if they are toplevel project options**
+ for key, valstr in itertools.chain(machine_file_options.items(), cmd_line_options.items()):
+ if key.subproject is None and not self.is_project_option(key.as_root()):
+ subp_key = key.evolve(subproject=subproject)
+ # just leave in place the value that was set for the toplevel project
+ options.pop(subp_key, None)
+
# augments from the toplevel project() default_options
for key, valstr in self.pending_subproject_options.items():
if key.subproject == subproject:
@@ -1395,14 +1403,6 @@ class OptionStore:
key = key.evolve(subproject=subproject)
options[key] = valstr
- # then global settings from machine file and command line
- # **but not if they are toplevel project options**
- for key, valstr in itertools.chain(machine_file_options.items(), cmd_line_options.items()):
- if key.subproject is None and not self.is_project_option(key.as_root()):
- subp_key = key.evolve(subproject=subproject)
- self.pending_subproject_options.pop(subp_key, None)
- options.pop(subp_key, None)
-
# then finally per project augments from machine file and command line
for key, valstr in itertools.chain(machine_file_options.items(), cmd_line_options.items()):
if key.subproject == subproject:
diff --git a/unittests/machinefiletests.py b/unittests/machinefiletests.py
index 7f88a54bf..15c0e5728 100644
--- a/unittests/machinefiletests.py
+++ b/unittests/machinefiletests.py
@@ -563,18 +563,11 @@ class NativeFileTests(BasePlatformTests):
check = cm.exception.stdout
self.assertIn(check, 'Parent should override default_library')
- def test_builtin_options_machinefile_global_overrides_subproject(self):
- # The buildfile says subproject(... default_library: static), ensure that's overridden
+ def test_builtin_options_machinefile_global_loses_over_subproject(self):
+ # The buildfile says subproject(... default_library: static), ensure that it overrides the machinefile
testcase = os.path.join(self.common_test_dir, '223 persubproject options')
config = self.helper_create_native_file({'built-in options': {'default_library': 'both'}})
-
- with self.assertRaises((RuntimeError, subprocess.CalledProcessError)) as cm:
- self.init(testcase, extra_args=['--native-file', config])
- if isinstance(cm, RuntimeError):
- check = str(cm.exception)
- else:
- check = cm.exception.stdout
- self.assertIn(check, 'Parent should override default_library')
+ self.init(testcase, extra_args=['--native-file', config])
def test_builtin_options_compiler_properties(self):
# the properties section can have lang_args, and those need to be