aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavier Claessens <xavier.claessens@collabora.com>2022-01-31 14:45:12 -0500
committerJussi Pakkanen <jpakkane@gmail.com>2022-02-01 00:47:33 +0200
commit0185f2ed61290715f990f786597f3b73a36e678f (patch)
tree63bc5cf91c55d04fcd09974d29b16f92abaa9cb0
parent577842912266b61f7cdfa569d9ea99d0b0fa3b01 (diff)
downloadmeson-0185f2ed61290715f990f786597f3b73a36e678f.zip
meson-0185f2ed61290715f990f786597f3b73a36e678f.tar.gz
meson-0185f2ed61290715f990f786597f3b73a36e678f.tar.bz2
Fix dep.get_variable() with empty string default_value
-rw-r--r--mesonbuild/dependencies/pkgconfig.py2
-rw-r--r--test cases/common/211 dependency get_variable method/meson.build1
-rw-r--r--test cases/common/211 dependency get_variable method/test.json9
3 files changed, 11 insertions, 1 deletions
diff --git a/mesonbuild/dependencies/pkgconfig.py b/mesonbuild/dependencies/pkgconfig.py
index a7b7fc8..73f2e60 100644
--- a/mesonbuild/dependencies/pkgconfig.py
+++ b/mesonbuild/dependencies/pkgconfig.py
@@ -402,7 +402,7 @@ class PkgConfigDependency(ExternalDependency):
if not variable:
ret, out, _ = self._call_pkgbin(['--print-variables', self.name])
if not re.search(r'^' + variable_name + r'$', out, re.MULTILINE):
- if default:
+ if default is not None:
variable = default
else:
mlog.warning(f"pkgconfig variable '{variable_name}' not defined for dependency {self.name}.")
diff --git a/test cases/common/211 dependency get_variable method/meson.build b/test cases/common/211 dependency get_variable method/meson.build
index 384b3f3..b7e7035 100644
--- a/test cases/common/211 dependency get_variable method/meson.build
+++ b/test cases/common/211 dependency get_variable method/meson.build
@@ -19,6 +19,7 @@ else
'pkg-config didn\'t get default when we should have.')
assert(dep.get_variable(pkgconfig : 'prefix', default_value : default) != default,
'pkg-config got default when we shouldn\'t have.')
+ assert(dep.get_variable(pkgconfig : 'pkgvarnotfound', default_value : '') == '')
endif
dep_ct = dependency('llvm', method : 'config-tool', required : false)
diff --git a/test cases/common/211 dependency get_variable method/test.json b/test cases/common/211 dependency get_variable method/test.json
new file mode 100644
index 0000000..5281618
--- /dev/null
+++ b/test cases/common/211 dependency get_variable method/test.json
@@ -0,0 +1,9 @@
+{
+ "stdout": [
+ {
+ "line": ".*pkgvarnotfound.*",
+ "match": "re",
+ "count": 0
+ }
+ ]
+ }