aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2017-11-03 13:26:41 +0530
committerNirbheek Chauhan <nirbheek@centricular.com>2017-11-11 23:06:49 +0530
commit65edbf35ef728034a9bf4dfd304e6d42aac384b7 (patch)
treeefbdcdf74da2811194fc636276327a6c30bba64e
parent22f459a7dd8d6d815ade836b6ea9404572cbc92b (diff)
downloadmeson-65edbf35ef728034a9bf4dfd304e6d42aac384b7.zip
meson-65edbf35ef728034a9bf4dfd304e6d42aac384b7.tar.gz
meson-65edbf35ef728034a9bf4dfd304e6d42aac384b7.tar.bz2
dependencies: Use shlex to parse pkg-config cflags and libs
Escaping spaces with '\ ' is the only way that works with both pkg-config and pkgconf, so quote that way and unquote inside Meson. This should work on all platforms. Also fix the unit test to do the same. https://github.com/pkgconf/pkgconf/issues/153
-rw-r--r--mesonbuild/dependencies/base.py9
-rw-r--r--test cases/unit/17 pkgconfig static/foo.pc.in20
-rw-r--r--test cases/unit/17 pkgconfig static/meson.build4
3 files changed, 19 insertions, 14 deletions
diff --git a/mesonbuild/dependencies/base.py b/mesonbuild/dependencies/base.py
index 6592495..8d364a8 100644
--- a/mesonbuild/dependencies/base.py
+++ b/mesonbuild/dependencies/base.py
@@ -16,9 +16,10 @@
# Custom logic for several other packages are in separate files.
import os
-import shutil
-import stat
import sys
+import stat
+import shlex
+import shutil
from enum import Enum
from .. import mlog
@@ -267,7 +268,7 @@ class PkgConfigDependency(ExternalDependency):
if ret != 0:
raise DependencyException('Could not generate cargs for %s:\n\n%s' %
(self.name, out))
- self.compile_args = out.split()
+ self.compile_args = shlex.split(out)
def _set_libs(self):
libcmd = [self.name, '--libs']
@@ -279,7 +280,7 @@ class PkgConfigDependency(ExternalDependency):
(self.name, out))
self.link_args = []
libpaths = []
- for lib in out.split():
+ for lib in shlex.split(out):
# If we want to use only static libraries, we have to look for the
# file ourselves instead of depending on the compiler to find it
# with -lfoo or foo.lib. However, we can only do this if we already
diff --git a/test cases/unit/17 pkgconfig static/foo.pc.in b/test cases/unit/17 pkgconfig static/foo.pc.in
index 2dfa7c1..94d8031 100644
--- a/test cases/unit/17 pkgconfig static/foo.pc.in
+++ b/test cases/unit/17 pkgconfig static/foo.pc.in
@@ -1,10 +1,10 @@
-prefix=@PREFIX@
-libdir=${prefix}
-includedir=${prefix}/include
-datadir=${prefix}/data
-
-Name: libfoo
-Description: A foo library.
-Version: 1.0
-Libs: -L${libdir} -lfoo
-Cflags: -I${includedir}
+prefix=@PREFIX@
+libdir=${prefix}
+includedir=${prefix}/include
+datadir=${prefix}/data
+
+Name: libfoo
+Description: A foo library.
+Version: 1.0
+Libs: -L${libdir} -lfoo
+Cflags: -I${includedir}
diff --git a/test cases/unit/17 pkgconfig static/meson.build b/test cases/unit/17 pkgconfig static/meson.build
index 2327a50..caeb4aa 100644
--- a/test cases/unit/17 pkgconfig static/meson.build
+++ b/test cases/unit/17 pkgconfig static/meson.build
@@ -8,6 +8,10 @@ else
prefix = '/'.join(prefix_parts)
endif
+# Escape spaces
+prefix_parts = prefix.split(' ')
+prefix = '\ '.join(prefix_parts)
+
conf = configuration_data()
conf.set('PREFIX', prefix)
configure_file(input : 'foo.pc.in',