diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2018-01-13 18:23:44 +0200 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2018-01-19 15:49:49 +0200 |
commit | 5e4538fe63c49192716528758c6392b8d2057fd0 (patch) | |
tree | e939f74ed62bd47227f609f5e52aab1671324ff0 | |
parent | 714ac85d220cf822491e50b6cd84385b3529178d (diff) | |
download | meson-5e4538fe63c49192716528758c6392b8d2057fd0.zip meson-5e4538fe63c49192716528758c6392b8d2057fd0.tar.gz meson-5e4538fe63c49192716528758c6392b8d2057fd0.tar.bz2 |
Add external dependencies to pc files only if found. Closes #2911.
-rw-r--r-- | mesonbuild/modules/pkgconfig.py | 5 | ||||
-rwxr-xr-x | run_unittests.py | 7 | ||||
-rw-r--r-- | test cases/unit/22 unfound pkgconfig/meson.build | 15 | ||||
-rw-r--r-- | test cases/unit/22 unfound pkgconfig/some.c | 3 |
4 files changed, 29 insertions, 1 deletions
diff --git a/mesonbuild/modules/pkgconfig.py b/mesonbuild/modules/pkgconfig.py index 54c2126..c951920 100644 --- a/mesonbuild/modules/pkgconfig.py +++ b/mesonbuild/modules/pkgconfig.py @@ -79,7 +79,7 @@ class DependenciesHelper: if not hasattr(obj, 'generated_pc'): obj.generated_pc = self.name self.add_priv_libs(obj.get_dependencies()) - self.add_priv_libs(obj.get_external_deps()) + self.add_priv_libs(self.strip_unfound(obj.get_external_deps())) elif isinstance(obj, str): processed_libs.append(obj) else: @@ -87,6 +87,9 @@ class DependenciesHelper: return processed_libs, processed_reqs, processed_cflags + def strip_unfound(self, deps): + return [x for x in deps if not hasattr(x, 'found') or x.found()] + def remove_dups(self): self.pub_libs = list(set(self.pub_libs)) self.pub_reqs = list(set(self.pub_reqs)) diff --git a/run_unittests.py b/run_unittests.py index 92bfc67..eef4fe8 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -436,6 +436,7 @@ class BasePlatformTests(unittest.TestCase): # In case the directory is inside a symlinked directory, find the real # path otherwise we might not find the srcdir from inside the builddir. self.builddir = os.path.realpath(tempfile.mkdtemp()) + self.privatedir = os.path.join(self.builddir, 'meson-private') self.logdir = os.path.join(self.builddir, 'meson-logs') self.prefix = '/usr' self.libdir = os.path.join(self.prefix, 'lib') @@ -2085,6 +2086,12 @@ class LinuxlikeTests(BasePlatformTests): '-llibinternal', '-lcustom2', '-lfoo'])) + def test_pkg_unfound(self): + testdir = os.path.join(self.unit_test_dir, '22 unfound pkgconfig') + self.init(testdir) + pcfile = open(os.path.join(self.privatedir, 'somename.pc')).read() + self.assertFalse('blub_blob_blib' in pcfile) + def test_vala_c_warnings(self): ''' Test that no warnings are emitted for C code generated by Vala. This diff --git a/test cases/unit/22 unfound pkgconfig/meson.build b/test cases/unit/22 unfound pkgconfig/meson.build new file mode 100644 index 0000000..1285c0a --- /dev/null +++ b/test cases/unit/22 unfound pkgconfig/meson.build @@ -0,0 +1,15 @@ +project('foobar', 'c') + +unfound = dependency('blub_blob_blib', required : false) + +pkgg = import('pkgconfig') + +l = shared_library('somename', 'some.c', + dependencies : unfound) + +pkgg.generate( + libraries : l, + name : 'somename', + version : '1.0.0', + description : 'A test library.', +) diff --git a/test cases/unit/22 unfound pkgconfig/some.c b/test cases/unit/22 unfound pkgconfig/some.c new file mode 100644 index 0000000..fb765fb --- /dev/null +++ b/test cases/unit/22 unfound pkgconfig/some.c @@ -0,0 +1,3 @@ +int some() { + return 6; +} |