interpreter: Dependency variables can be empty string

There is no reason to forbid empty variables, PkgConfigCLI.variable()
even has code specifically for handling that case.
pull/11867/head
Xavier Claessens 2 years ago
parent 42944f72a4
commit 5654f03450
  1. 2
      mesonbuild/interpreter/interpreter.py
  2. 2
      mesonbuild/interpreter/type_checking.py
  3. 2
      mesonbuild/modules/pkgconfig.py
  4. 16
      test cases/failing/47 pkgconfig variables zero length value/meson.build
  5. 5
      test cases/failing/47 pkgconfig variables zero length value/simple.c
  6. 6
      test cases/failing/47 pkgconfig variables zero length value/simple.h
  7. 7
      test cases/failing/47 pkgconfig variables zero length value/test.json

@ -702,6 +702,8 @@ class Interpreter(InterpreterBase, HoldableObject):
srcdir = Path(self.environment.source_dir)
# convert variables which refer to an -uninstalled.pc style datadir
for k, v in variables.items():
if not v:
FeatureNew.single_use('empty variable value in declare_dependency', '1.4.0', self.subproject, location=node)
try:
p = Path(v)
except ValueError:

@ -144,8 +144,6 @@ def variables_validator(contents: T.Union[str, T.List[str], T.Dict[str, str]]) -
for k, v in variables.items():
if not k:
return 'empty variable name'
if not v:
return 'empty variable value'
if any(c.isspace() for c in k):
return f'invalid whitespace in variable name {k!r}'
return None

@ -680,6 +680,8 @@ class PkgConfigModule(NewExtensionModule):
reserved = ['prefix', 'libdir', 'includedir']
variables = []
for name, value in vardict.items():
if not value:
FeatureNew.single_use('empty variable value in pkg.generate', '1.4.0', state.subproject, location=state.current_node)
if not dataonly and name in reserved:
raise mesonlib.MesonException(f'Variable "{name}" is reserved')
variables.append((name, value))

@ -1,16 +0,0 @@
project('variables-zero-length-value-test', 'c', version : '1.0')
pkgg = import('pkgconfig')
lib = shared_library('simple', 'simple.c')
libver = '1.0'
h = install_headers('simple.h')
pkgg.generate(
libraries : [lib, '-lz'],
subdirs : '.',
version : libver,
name : 'libsimple',
filebase : 'simple',
description : 'A simple demo library.',
variables : [ 'key=' ]
)

@ -1,5 +0,0 @@
#include"simple.h"
int simple_function() {
return 42;
}

@ -1,6 +0,0 @@
#ifndef SIMPLE_H_
#define SIMPLE_H_
int simple_function();
#endif

@ -1,7 +0,0 @@
{
"stdout": [
{
"line": "test cases/failing/47 pkgconfig variables zero length value/meson.build:8:5: ERROR: pkgconfig.generate keyword argument \"variables\" empty variable value"
}
]
}
Loading…
Cancel
Save