summaryrefslogtreecommitdiff
path: root/mesonbuild/interpreter/interpreterobjects.py
diff options
context:
space:
mode:
authorEli Schwartz <eschwartz93@gmail.com>2023-11-13 18:45:54 -0500
committerEli Schwartz <eschwartz93@gmail.com>2023-11-14 14:59:12 -0500
commit398c4b22874c2f67eb2eca6371e5a94d21ab8eed (patch)
treea104717f2a517dd38b331ca313a705e706d043ec /mesonbuild/interpreter/interpreterobjects.py
parentdac3f26ee5e8bd841023ecdd3d83c6b2e1ca60b5 (diff)
downloadmeson-398c4b22874c2f67eb2eca6371e5a94d21ab8eed.tar.gz
dependencies: allow get_variable to define multiple pkgconfig defines
It was previously impossible to do this: ``` dep.get_pkgconfig_variable( 'foo', define_variable: ['prefix', '/usr', 'datadir', '/usr/share'], ) ``` since get_pkgconfig_variable mandated exactly two (if any) arguments. However, you could do this: ``` dep.get_variable( 'foo', pkgconfig_define: ['prefix', '/usr', 'datadir', '/usr/share'], ) ``` It would silently do the wrong thing, by defining "prefix" as `/usr=datadir=/usr/share`, which might not "matter" if only datadir was used in the "foo" variable as the unmodified value might be adequate. The actual intention of anyone writing such a meson.build is that they aren't sure whether the .pc file uses ${prefix} or ${datadir} (or which one gets used, might have changed between versions of that .pc file, even). A recent refactor made this into a hard error, which broke some projects that were doing this and inadvertently depending on some .pc file that only used the second variable. (This was "fine" since the result was essentially meaningful, and even resulted in behavior identical to the intended behavior if both projects were installed into the same prefix -- in which case there's nothing to remap.) Re-allow this. There are two ways we could re-allow this: - ignore it with a warning - add a new feature to allow actually doing this Since the use case which triggered this bug actually has a pretty good reason to want to do this, it makes sense to add the new feature. Fixes https://bugs.gentoo.org/916576 Fixes https://github.com/containers/bubblewrap/issues/609
Diffstat (limited to 'mesonbuild/interpreter/interpreterobjects.py')
-rw-r--r--mesonbuild/interpreter/interpreterobjects.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/mesonbuild/interpreter/interpreterobjects.py b/mesonbuild/interpreter/interpreterobjects.py
index effeebb20..f13e3ff4a 100644
--- a/mesonbuild/interpreter/interpreterobjects.py
+++ b/mesonbuild/interpreter/interpreterobjects.py
@@ -494,6 +494,9 @@ class DependencyHolder(ObjectHolder[Dependency]):
from ..dependencies.pkgconfig import PkgConfigDependency
if not isinstance(self.held_object, PkgConfigDependency):
raise InvalidArguments(f'{self.held_object.get_name()!r} is not a pkgconfig dependency')
+ if kwargs['define_variable'] and len(kwargs['define_variable']) > 1:
+ FeatureNew.single_use('dependency.get_pkgconfig_variable keyword argument "define_variable" with more than one pair',
+ '1.3.0', self.subproject, location=self.current_node)
return self.held_object.get_variable(
pkgconfig=args[0],
default_value=kwargs['default'],
@@ -536,6 +539,10 @@ class DependencyHolder(ObjectHolder[Dependency]):
default_varname = args[0]
if default_varname is not None:
FeatureNew('Positional argument to dependency.get_variable()', '0.58.0').use(self.subproject, self.current_node)
+ if kwargs['pkgconfig_define'] and len(kwargs['pkgconfig_define']) > 1:
+ FeatureNew.single_use('dependency.get_variable keyword argument "pkgconfig_define" with more than one pair',
+ '1.3.0', self.subproject, 'In previous versions, this silently returned a malformed value.',
+ self.current_node)
return self.held_object.get_variable(
cmake=kwargs['cmake'] or default_varname,
pkgconfig=kwargs['pkgconfig'] or default_varname,