diff options
-rw-r--r-- | mesonbuild/modules/pkgconfig.py | 6 | ||||
-rwxr-xr-x | run_unittests.py | 1 | ||||
-rw-r--r-- | test cases/common/45 pkgconfig-gen/meson.build | 7 |
3 files changed, 11 insertions, 3 deletions
diff --git a/mesonbuild/modules/pkgconfig.py b/mesonbuild/modules/pkgconfig.py index fd2c24a..c9af5bf 100644 --- a/mesonbuild/modules/pkgconfig.py +++ b/mesonbuild/modules/pkgconfig.py @@ -469,10 +469,12 @@ class PkgConfigModule(ExtensionModule): raise mesonlib.MesonException('Too many positional arguments passed to Pkgconfig_gen.') dataonly = kwargs.get('dataonly', False) + if not isinstance(dataonly, bool): + raise mesonlib.MesonException('dataonly must be boolean.') if dataonly: default_subdirs = [] blocked_vars = ['libraries', 'libraries_private', 'require_private', 'extra_cflags', 'subdirs'] - if len(set(kwargs) & set(blocked_vars)) > 0: + if any(k in kwargs for k in blocked_vars): raise mesonlib.MesonException(f'Cannot combine dataonly with any of {blocked_vars}') subdirs = mesonlib.stringlistify(kwargs.get('subdirs', default_subdirs)) @@ -519,7 +521,7 @@ class PkgConfigModule(ExtensionModule): reserved = ['prefix', 'libdir', 'includedir'] variables = [] for name, value in vardict.items(): - if name in reserved: + if not dataonly and name in reserved: raise mesonlib.MesonException(f'Variable "{name}" is reserved') variables.append((name, value)) return variables diff --git a/run_unittests.py b/run_unittests.py index 5362616..0888a97 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -6444,6 +6444,7 @@ class LinuxlikeTests(BasePlatformTests): self.assertEqual(libhello_nolib.get_link_args(), []) self.assertEqual(libhello_nolib.get_compile_args(), []) self.assertEqual(libhello_nolib.get_pkgconfig_variable('foo', {}), 'bar') + self.assertEqual(libhello_nolib.get_pkgconfig_variable('prefix', {}), self.prefix) def test_pkgconfig_gen_deps(self): ''' diff --git a/test cases/common/45 pkgconfig-gen/meson.build b/test cases/common/45 pkgconfig-gen/meson.build index 4638123..6a3b788 100644 --- a/test cases/common/45 pkgconfig-gen/meson.build +++ b/test cases/common/45 pkgconfig-gen/meson.build @@ -65,7 +65,12 @@ pkgg.generate( description : 'A minimalistic pkgconfig file.', version : libver, dataonly: true, - variables : {'foo': 'bar'}, + variables : { + 'foo': 'bar', + # prefix is not set by default for dataonly pc files, but it is allowed to + # define it manually. + 'prefix': get_option('prefix'), + }, ) # Regression test for 2 cases: |