SHA256
1
0
forked from pool/meson
meson/meson-keep-spaces-in-pc-files.patch
Dominique Leuenberger e3d4a78d0b Accepting request 602460 from GNOME:Next
- Add meson-keep-spaces-in-pc-files.patch: Keep spaces in generated
  pkgconfig files (gh#mesonbuild/meson#3479).

- Add meson-keep-spaces-in-pc-files.patch: Keep spaces in generated
  pkgconfig files (gh#mesonbuild/meson#3479).

OBS-URL: https://build.opensuse.org/request/show/602460
OBS-URL: https://build.opensuse.org/package/show/devel:tools:building/meson?expand=0&rev=96
2018-04-30 09:19:08 +00:00

85 lines
3.3 KiB
Diff

From cbc2f2d1df769123caa2e4562dbe1809cca1304d Mon Sep 17 00:00:00 2001
From: Jussi Pakkanen <jpakkane@gmail.com>
Date: Sun, 29 Apr 2018 21:43:24 +0300
Subject: [PATCH] Keep separator spaces in pkg-config declarations. Closes
#3479.
---
mesonbuild/modules/pkgconfig.py | 6 ++++--
run_unittests.py | 11 +++++++++++
test cases/unit/31 pkgconfig format/meson.build | 12 ++++++++++++
test cases/unit/31 pkgconfig format/somelib.c | 5 +++++
4 files changed, 32 insertions(+), 2 deletions(-)
create mode 100644 test cases/unit/31 pkgconfig format/meson.build
create mode 100644 test cases/unit/31 pkgconfig format/somelib.c
diff --git a/mesonbuild/modules/pkgconfig.py b/mesonbuild/modules/pkgconfig.py
index a3ba973f3..419a14c77 100644
--- a/mesonbuild/modules/pkgconfig.py
+++ b/mesonbuild/modules/pkgconfig.py
@@ -139,8 +139,10 @@ def add_version_reqs(self, name, version_reqs):
if version_reqs:
if name not in self.version_reqs:
self.version_reqs[name] = set()
- # We could have '>=1.0' or '>= 1.0', remove spaces to normalize
- new_vreqs = [s.replace(' ', '') for s in mesonlib.stringlistify(version_reqs)]
+ # Note that pkg-config is picky about whitespace.
+ # 'foo > 1.2' is ok but 'foo>1.2' is not.
+ # foo, bar' is ok, but 'foo,bar' is not.
+ new_vreqs = [s for s in mesonlib.stringlistify(version_reqs)]
self.version_reqs[name].update(new_vreqs)
def split_version_req(self, s):
diff --git a/run_unittests.py b/run_unittests.py
index f06c9a0ea..ce5fe14dd 100755
--- a/run_unittests.py
+++ b/run_unittests.py
@@ -3056,6 +3056,17 @@ def test_pkgconfig_internal_libraries(self):
self.init(os.path.join(testdirbase, 'app'))
self.build()
+ @unittest.skipIf(shutil.which('pkg-config') is None, 'Pkg-config not found.')
+ def test_pkgconfig_formatting(self):
+ testdir = os.path.join(self.unit_test_dir, '31 pkgconfig format')
+ self.init(testdir)
+ myenv = os.environ.copy()
+ myenv['PKG_CONFIG_PATH'] = self.privatedir
+ ro = subprocess.run(['pkg-config', '--libs', 'libsomething'], stdout=subprocess.PIPE,
+ env=myenv)
+ self.assertEqual(ro.returncode, 0)
+ self.assertIn(b'-lgobject-2.0', ro.stdout)
+ self.assertIn(b'-lgio-2.0', ro.stdout)
class LinuxArmCrossCompileTests(BasePlatformTests):
'''
diff --git a/test cases/unit/31 pkgconfig format/meson.build b/test cases/unit/31 pkgconfig format/meson.build
new file mode 100644
index 000000000..bb702401f
--- /dev/null
+++ b/test cases/unit/31 pkgconfig format/meson.build
@@ -0,0 +1,12 @@
+project('pkgformat', 'c',
+ version : '1.0')
+
+pkgg = import('pkgconfig')
+
+l = shared_library('something', 'somelib.c')
+
+pkgg.generate(libraries: l,
+ version: '1.0',
+ name: 'libsomething',
+ description: 'A library that does something',
+ requires: 'gobject-2.0 >= 2.54, gio-2.0 >= 2.54')
diff --git a/test cases/unit/31 pkgconfig format/somelib.c b/test cases/unit/31 pkgconfig format/somelib.c
new file mode 100644
index 000000000..6d876c8f2
--- /dev/null
+++ b/test cases/unit/31 pkgconfig format/somelib.c
@@ -0,0 +1,5 @@
+#include<stdio.h>
+
+int some_func() {
+ return 0;
+}