aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2018-01-22 00:15:29 +0200
committerGitHub <noreply@github.com>2018-01-22 00:15:29 +0200
commit2757d7fd127c9ab7cf81205634fb64615782e818 (patch)
treebe150de46a09870a6604811f16263af1dc37a89c
parent22be11514d54c3c32bd0dcceabcedc52833508db (diff)
parent6e2e94c6452c12af224515e70aa88a63fb5adc65 (diff)
downloadmeson-2757d7fd127c9ab7cf81205634fb64615782e818.zip
meson-2757d7fd127c9ab7cf81205634fb64615782e818.tar.gz
meson-2757d7fd127c9ab7cf81205634fb64615782e818.tar.bz2
Merge pull request #2955 from xclaesse/unfound
pkgconfig: Also ignore not found deps passed directly to pc generator
-rw-r--r--mesonbuild/modules/pkgconfig.py13
-rwxr-xr-xrun_unittests.py41
-rw-r--r--test cases/common/51 pkgconfig-gen/dependencies/exposed.c3
-rw-r--r--test cases/common/51 pkgconfig-gen/dependencies/internal.c3
-rw-r--r--test cases/common/51 pkgconfig-gen/dependencies/meson.build38
-rw-r--r--test cases/common/51 pkgconfig-gen/meson.build33
6 files changed, 77 insertions, 54 deletions
diff --git a/mesonbuild/modules/pkgconfig.py b/mesonbuild/modules/pkgconfig.py
index c951920..5573a2e 100644
--- a/mesonbuild/modules/pkgconfig.py
+++ b/mesonbuild/modules/pkgconfig.py
@@ -66,20 +66,22 @@ class DependenciesHelper:
elif hasattr(obj, 'generated_pc'):
processed_reqs.append(obj.generated_pc)
elif isinstance(obj, dependencies.PkgConfigDependency):
- processed_reqs.append(obj.name)
+ if obj.found():
+ processed_reqs.append(obj.name)
elif isinstance(obj, dependencies.ThreadDependency):
processed_libs += obj.get_compiler().thread_link_flags(obj.env)
processed_cflags += obj.get_compiler().thread_flags(obj.env)
elif isinstance(obj, dependencies.Dependency):
- processed_libs += obj.get_link_args()
- processed_cflags += obj.get_compile_args()
+ if obj.found():
+ processed_libs += obj.get_link_args()
+ processed_cflags += obj.get_compile_args()
elif isinstance(obj, (build.SharedLibrary, build.StaticLibrary)):
processed_libs.append(obj)
if public:
if not hasattr(obj, 'generated_pc'):
obj.generated_pc = self.name
self.add_priv_libs(obj.get_dependencies())
- self.add_priv_libs(self.strip_unfound(obj.get_external_deps()))
+ self.add_priv_libs(obj.get_external_deps())
elif isinstance(obj, str):
processed_libs.append(obj)
else:
@@ -87,9 +89,6 @@ 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 eef4fe8..7abbe6c 100755
--- a/run_unittests.py
+++ b/run_unittests.py
@@ -433,15 +433,8 @@ class BasePlatformTests(unittest.TestCase):
src_root = os.path.dirname(__file__)
src_root = os.path.join(os.getcwd(), src_root)
self.src_root = src_root
- # 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')
- self.installdir = os.path.join(self.builddir, 'install')
- self.distdir = os.path.join(self.builddir, 'meson-dist')
# Get the backend
# FIXME: Extract this from argv?
self.backend = getattr(Backend, os.environ.get('MESON_UNIT_TEST_BACKEND', 'ninja'))
@@ -450,7 +443,6 @@ class BasePlatformTests(unittest.TestCase):
self.meson_command = meson_command + self.meson_args
self.mconf_command = meson_command + ['configure']
self.mintro_command = meson_command + ['introspect']
- self.mtest_command = meson_command + ['test', '-C', self.builddir]
self.wrap_command = meson_command + ['wrap']
# Backend-specific build commands
self.build_command, self.clean_command, self.test_command, self.install_command, \
@@ -469,6 +461,20 @@ class BasePlatformTests(unittest.TestCase):
# XCode backend is untested with unit tests, help welcome!
self.no_rebuild_stdout = 'UNKNOWN BACKEND {!r}'.format(self.backend.name)
+ self.builddirs = []
+ self.new_builddir()
+
+ def new_builddir(self):
+ # 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.installdir = os.path.join(self.builddir, 'install')
+ self.distdir = os.path.join(self.builddir, 'meson-dist')
+ self.mtest_command = meson_command + ['test', '-C', self.builddir]
+ self.builddirs.append(self.builddir)
+
def _print_meson_log(self):
log = os.path.join(self.logdir, 'meson-log.txt')
if not os.path.isfile(log):
@@ -478,10 +484,11 @@ class BasePlatformTests(unittest.TestCase):
print(f.read())
def tearDown(self):
- try:
- windows_proof_rmtree(self.builddir)
- except FileNotFoundError:
- pass
+ for path in self.builddirs:
+ try:
+ windows_proof_rmtree(path)
+ except FileNotFoundError:
+ pass
os.environ = self.orig_env
super().tearDown()
@@ -2060,11 +2067,17 @@ class LinuxlikeTests(BasePlatformTests):
'''
Test that generated pkg-config files correctly handle dependencies
'''
-
testdir = os.path.join(self.common_test_dir, '51 pkgconfig-gen')
self.init(testdir)
+ privatedir1 = self.privatedir
- os.environ['PKG_CONFIG_LIBDIR'] = self.privatedir
+ self.new_builddir()
+ os.environ['PKG_CONFIG_LIBDIR'] = privatedir1
+ testdir = os.path.join(self.common_test_dir, '51 pkgconfig-gen', 'dependencies')
+ self.init(testdir)
+ privatedir2 = self.privatedir
+
+ os.environ['PKG_CONFIG_LIBDIR'] = os.pathsep.join([privatedir1, privatedir2])
cmd = ['pkg-config', 'dependency-test']
out = self._run(cmd + ['--print-requires']).strip().split()
diff --git a/test cases/common/51 pkgconfig-gen/dependencies/exposed.c b/test cases/common/51 pkgconfig-gen/dependencies/exposed.c
new file mode 100644
index 0000000..005202e
--- /dev/null
+++ b/test cases/common/51 pkgconfig-gen/dependencies/exposed.c
@@ -0,0 +1,3 @@
+int exposed_function() {
+ return 42;
+}
diff --git a/test cases/common/51 pkgconfig-gen/dependencies/internal.c b/test cases/common/51 pkgconfig-gen/dependencies/internal.c
new file mode 100644
index 0000000..1a41b11
--- /dev/null
+++ b/test cases/common/51 pkgconfig-gen/dependencies/internal.c
@@ -0,0 +1,3 @@
+int internal_function() {
+ return 42;
+}
diff --git a/test cases/common/51 pkgconfig-gen/dependencies/meson.build b/test cases/common/51 pkgconfig-gen/dependencies/meson.build
new file mode 100644
index 0000000..a767eb5
--- /dev/null
+++ b/test cases/common/51 pkgconfig-gen/dependencies/meson.build
@@ -0,0 +1,38 @@
+project('pkgconfig-gen-dependencies', 'c')
+
+pkgg = import('pkgconfig')
+
+# libmain internally use libinternal and expose libexpose in its API
+exposed_lib = shared_library('libexposed', 'exposed.c')
+internal_lib = shared_library('libinternal', 'internal.c')
+main_lib = shared_library('libmain', link_with : [exposed_lib, internal_lib])
+
+pkgg.generate(libraries : exposed_lib,
+ version : '1.0',
+ name : 'libexposed',
+ description : 'An exposed library in dependency test.'
+)
+
+# Declare a few different Dependency objects
+pc_dep = dependency('libfoo')
+notfound_dep = dependency('notfound', required : false)
+threads_dep = dependency('threads')
+custom_dep = declare_dependency(link_args : ['-lcustom'], compile_args : ['-DCUSTOM'])
+custom2_dep = declare_dependency(link_args : ['-lcustom2'], compile_args : ['-DCUSTOM2'])
+
+# Generate a PC file:
+# - Having libmain in libraries should pull implicitely libexposed and libinternal in Libs.private
+# - Having libexposed in libraries should remove it from Libs.private
+# - We generated a pc file for libexposed so it should be in Requires instead of Libs
+# - Having threads_dep in libraries should add '-pthread' in both Libs and Cflags
+# - Having custom_dep in libraries and libraries_private should only add it in Libs
+# - Having custom2_dep in libraries_private should not add its Cflags
+# - Having pc_dep in libraries_private should add it in Requires.private
+# - notfound_dep is not required so it shouldn't appear in the pc file.
+pkgg.generate(libraries : [main_lib, exposed_lib, threads_dep , custom_dep],
+ libraries_private : [custom_dep, custom2_dep, pc_dep, notfound_dep],
+ version : '1.0',
+ name : 'dependency-test',
+ filebase : 'dependency-test',
+ description : 'A dependency test.'
+)
diff --git a/test cases/common/51 pkgconfig-gen/meson.build b/test cases/common/51 pkgconfig-gen/meson.build
index a8dd092..f9d7f7f 100644
--- a/test cases/common/51 pkgconfig-gen/meson.build
+++ b/test cases/common/51 pkgconfig-gen/meson.build
@@ -46,36 +46,3 @@ pkgg.generate(
description : 'A foo library.',
variables : ['foo=bar', 'datadir=${prefix}/data']
)
-
-# libmain internally use libinternal and expose libexpose in its API
-exposed_lib = shared_library('libexposed', 'simple.c')
-internal_lib = shared_library('libinternal', 'simple.c')
-main_lib = shared_library('libmain', link_with : [exposed_lib, internal_lib])
-
-pkgg.generate(libraries : exposed_lib,
- version : libver,
- name : 'libexposed',
- description : 'An exposed library in dependency test.'
-)
-
-# Declare a few different Dependency objects
-pc_dep = dependency('libfoo', required : false)
-threads_dep = dependency('threads', required : false)
-custom_dep = declare_dependency(link_args : ['-lcustom'], compile_args : ['-DCUSTOM'])
-custom2_dep = declare_dependency(link_args : ['-lcustom2'], compile_args : ['-DCUSTOM2'])
-
-# Generate a PC file:
-# - Having libmain in libraries should pull implicitely libexposed and libinternal in Libs.private
-# - Having libexposed in libraries should remove it from Libs.private
-# - We generated a pc file for libexposed so it should be in Requires instead of Libs
-# - Having threads_dep in libraries should add '-pthread' in both Libs and Cflags
-# - Having custom_dep in libraries and libraries_private should only add it in Libs
-# - Having custom2_dep in libraries_private should not add its Cflags
-# - Having pc_dep in libraries_private should add it in Requires.private
-pkgg.generate(libraries : [main_lib, exposed_lib, threads_dep , custom_dep],
- libraries_private : [custom_dep, custom2_dep, pc_dep],
- version : libver,
- name : 'dependency-test',
- filebase : 'dependency-test',
- description : 'A dependency test.'
-)