diff options
| author | Jussi Pakkanen <jpakkane@gmail.com> | 2024-12-16 13:29:15 +0200 |
|---|---|---|
| committer | Jussi Pakkanen <jpakkane@gmail.com> | 2024-12-16 21:12:39 +0200 |
| commit | 16cf71f0512ec26633b6d21e9c5b28613c36596b (patch) | |
| tree | 793832cbe8d3733bd5e7815ce36734d5a44da468 | |
| parent | 0b41b364be716064285928c00330d1fc6b07cd88 (diff) | |
| download | meson-16cf71f0512ec26633b6d21e9c5b28613c36596b.tar.gz | |
Handle top level options set in subprojects. Closes #13847.
| -rw-r--r-- | mesonbuild/coredata.py | 17 | ||||
| -rw-r--r-- | test cases/unit/123 pkgsubproj/meson.build | 3 | ||||
| -rw-r--r-- | test cases/unit/123 pkgsubproj/subprojects/sub/meson.build | 1 | ||||
| -rw-r--r-- | unittests/linuxliketests.py | 4 |
4 files changed, 22 insertions, 3 deletions
diff --git a/mesonbuild/coredata.py b/mesonbuild/coredata.py index 98656b27d..c3e435271 100644 --- a/mesonbuild/coredata.py +++ b/mesonbuild/coredata.py @@ -658,9 +658,20 @@ class CoreData: elif k.machine != MachineChoice.BUILD and not self.optstore.is_compiler_option(k): unknown_options.append(k) if unknown_options: - unknown_options_str = ', '.join(sorted(str(s) for s in unknown_options)) - sub = f'In subproject {subproject}: ' if subproject else '' - raise MesonException(f'{sub}Unknown options: "{unknown_options_str}"') + if subproject: + # The subproject may have top-level options that should be used + # when it is not a subproject. Ignore those for now. With option + # refactor they will get per-subproject values. + really_unknown = [] + for uo in unknown_options: + topkey = uo.evolve(subproject='') + if topkey not in self.optstore: + really_unknown.append(uo) + unknown_options = really_unknown + if unknown_options: + unknown_options_str = ', '.join(sorted(str(s) for s in unknown_options)) + sub = f'In subproject {subproject}: ' if subproject else '' + raise MesonException(f'{sub}Unknown options: "{unknown_options_str}"') if not self.is_cross_build(): dirty |= self.copy_build_options_from_regular_ones() diff --git a/test cases/unit/123 pkgsubproj/meson.build b/test cases/unit/123 pkgsubproj/meson.build new file mode 100644 index 000000000..b4cf89fa0 --- /dev/null +++ b/test cases/unit/123 pkgsubproj/meson.build @@ -0,0 +1,3 @@ +project('pkg_opt_test') + +subproject('sub') diff --git a/test cases/unit/123 pkgsubproj/subprojects/sub/meson.build b/test cases/unit/123 pkgsubproj/subprojects/sub/meson.build new file mode 100644 index 000000000..99622b681 --- /dev/null +++ b/test cases/unit/123 pkgsubproj/subprojects/sub/meson.build @@ -0,0 +1 @@ +project('subproject', default_options: 'pkgconfig.relocatable=true') diff --git a/unittests/linuxliketests.py b/unittests/linuxliketests.py index 1e9e38d1b..c8d5a538d 100644 --- a/unittests/linuxliketests.py +++ b/unittests/linuxliketests.py @@ -1863,3 +1863,7 @@ class LinuxlikeTests(BasePlatformTests): self.assertIn('build t9-e1: c_LINKER t9-e1.p/main.c.o | libt9-s1.a libt9-s2.a libt9-s3.a\n', content) self.assertIn('build t12-e1: c_LINKER t12-e1.p/main.c.o | libt12-s1.a libt12-s2.a libt12-s3.a\n', content) self.assertIn('build t13-e1: c_LINKER t13-e1.p/main.c.o | libt12-s1.a libt13-s3.a\n', content) + + def test_top_options_in_sp(self): + testdir = os.path.join(self.unit_test_dir, '123 pkgsubproj') + self.init(testdir) |
