aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/markdown/Pkgconfig-module.md5
-rw-r--r--docs/markdown/Reference-manual.md2
-rw-r--r--docs/markdown/snippets/pkgconfig-requires-non-string.md5
-rwxr-xr-xghwt.py2
-rw-r--r--mesonbuild/backend/xcodebackend.py2
-rw-r--r--mesonbuild/dependencies/base.py32
-rw-r--r--mesonbuild/modules/pkgconfig.py30
-rwxr-xr-xrun_unittests.py10
-rw-r--r--test cases/common/51 pkgconfig-gen/dependencies/meson.build16
-rw-r--r--test cases/common/51 pkgconfig-gen/meson.build6
10 files changed, 82 insertions, 28 deletions
diff --git a/docs/markdown/Pkgconfig-module.md b/docs/markdown/Pkgconfig-module.md
index cbe01b4..853cf50 100644
--- a/docs/markdown/Pkgconfig-module.md
+++ b/docs/markdown/Pkgconfig-module.md
@@ -38,8 +38,9 @@ keyword arguments.
search path, for example if you install headers into
`${PREFIX}/include/foobar-1`, the correct value for this argument
would be `foobar-1`
-- `requires` list of strings to put in the `Requires` field
-- `requires_private` list of strings to put in the `Requires.private`
+- `requires` list of strings, pkgconfig-dependencies or libraries that
+ `pkgconfig.generate()` was used on to put in the `Requires` field
+- `requires_private` same as `requires` but for `Requires.private` field
field
- `url` a string with a url for the library
- `variables` a list of strings with custom variables to add to the
diff --git a/docs/markdown/Reference-manual.md b/docs/markdown/Reference-manual.md
index 8798a3a..589baf1 100644
--- a/docs/markdown/Reference-manual.md
+++ b/docs/markdown/Reference-manual.md
@@ -999,6 +999,8 @@ Meson will set three environment variables `MESON_SOURCE_ROOT`,
directory, build directory and subdirectory the target was defined in,
respectively.
+See also [External commands](External-commands.md).
+
### run_target
``` meson
diff --git a/docs/markdown/snippets/pkgconfig-requires-non-string.md b/docs/markdown/snippets/pkgconfig-requires-non-string.md
new file mode 100644
index 0000000..fc848a8
--- /dev/null
+++ b/docs/markdown/snippets/pkgconfig-requires-non-string.md
@@ -0,0 +1,5 @@
+# pkgconfig.generate() requires parameters non-string arguments
+
+`pkgconfig.generate()` `requires` and `requires_private` parameters
+accept pkgconfig-dependencies and libraries that pkgconfig-files were
+generated for.
diff --git a/ghwt.py b/ghwt.py
index bf06e19..32db4be 100755
--- a/ghwt.py
+++ b/ghwt.py
@@ -55,7 +55,7 @@ def unpack(sproj, branch, outdir):
print(' expected:', dig)
print(' obtained:', should)
return 1
- spdir = os.path.split(outdir)[0]
+ spdir = os.path.dirname(outdir)
ofilename = os.path.join(spdir, config['wrap-file']['source_filename'])
with open(ofilename, 'wb') as ofile:
ofile.write(us)
diff --git a/mesonbuild/backend/xcodebackend.py b/mesonbuild/backend/xcodebackend.py
index e2204fe..9a9f88b 100644
--- a/mesonbuild/backend/xcodebackend.py
+++ b/mesonbuild/backend/xcodebackend.py
@@ -706,7 +706,7 @@ class XCodeBackend(backends.Backend):
if isinstance(target, build.SharedLibrary):
ldargs = ['-dynamiclib', '-Wl,-headerpad_max_install_names'] + dep_libs
install_path = os.path.join(self.environment.get_build_dir(), target.subdir, buildtype)
- dylib_version = target.version
+ dylib_version = target.soversion
else:
ldargs = dep_libs
install_path = ''
diff --git a/mesonbuild/dependencies/base.py b/mesonbuild/dependencies/base.py
index b6d1983..0375102 100644
--- a/mesonbuild/dependencies/base.py
+++ b/mesonbuild/dependencies/base.py
@@ -381,9 +381,7 @@ class PkgConfigDependency(ExternalDependency):
pkgname = environment.cross_info.config['binaries']['pkgconfig']
potential_pkgbin = ExternalProgram(pkgname, silent=True)
if potential_pkgbin.found():
- # FIXME, we should store all pkg-configs in ExternalPrograms.
- # However that is too destabilizing a change to do just before release.
- self.pkgbin = potential_pkgbin.get_command()[0]
+ self.pkgbin = potential_pkgbin
PkgConfigDependency.class_pkgbin = self.pkgbin
else:
mlog.debug('Cross pkg-config %s not found.' % potential_pkgbin.name)
@@ -405,7 +403,7 @@ class PkgConfigDependency(ExternalDependency):
self.type_string = 'Native'
mlog.debug('Determining dependency {!r} with pkg-config executable '
- '{!r}'.format(name, self.pkgbin))
+ '{!r}'.format(name, self.pkgbin.get_path()))
ret, self.version = self._call_pkgbin(['--modversion', name])
if ret != 0:
if self.required:
@@ -464,7 +462,7 @@ class PkgConfigDependency(ExternalDependency):
def _call_pkgbin(self, args, env=None):
if not env:
env = os.environ
- p, out = Popen_safe([self.pkgbin] + args, env=env)[0:2]
+ p, out = Popen_safe(self.pkgbin.get_command() + args, env=env)[0:2]
return p.returncode, out.strip()
def _convert_mingw_paths(self, args):
@@ -609,21 +607,23 @@ class PkgConfigDependency(ExternalDependency):
pkgbin = os.environ[evar].strip()
else:
pkgbin = 'pkg-config'
- try:
- p, out = Popen_safe([pkgbin, '--version'])[0:2]
- if p.returncode != 0:
- # Set to False instead of None to signify that we've already
- # searched for it and not found it
+ pkgbin = ExternalProgram(pkgbin, silent=True)
+ if pkgbin.found():
+ try:
+ p, out = Popen_safe(pkgbin.get_command() + ['--version'])[0:2]
+ if p.returncode != 0:
+ mlog.warning('Found pkg-config {!r} but couldn\'t run it'
+ ''.format(' '.join(pkgbin.get_command())))
+ # Set to False instead of None to signify that we've already
+ # searched for it and not found it
+ pkgbin = False
+ except (FileNotFoundError, PermissionError):
pkgbin = False
- except (FileNotFoundError, PermissionError):
+ else:
pkgbin = False
- if pkgbin and not os.path.isabs(pkgbin) and shutil.which(pkgbin):
- # Sometimes shutil.which fails where Popen succeeds, so
- # only find the abs path if it can be found by shutil.which
- pkgbin = shutil.which(pkgbin)
if not self.silent:
if pkgbin:
- mlog.log('Found pkg-config:', mlog.bold(pkgbin),
+ mlog.log('Found pkg-config:', mlog.bold(pkgbin.get_path()),
'(%s)' % out.strip())
else:
mlog.log('Found Pkg-config:', mlog.red('NO'))
diff --git a/mesonbuild/modules/pkgconfig.py b/mesonbuild/modules/pkgconfig.py
index 5573a2e..2f4dfae 100644
--- a/mesonbuild/modules/pkgconfig.py
+++ b/mesonbuild/modules/pkgconfig.py
@@ -44,22 +44,40 @@ class DependenciesHelper:
self.priv_reqs += reqs
def add_pub_reqs(self, reqs):
- self.pub_reqs += mesonlib.stringlistify(reqs)
+ self.pub_reqs += self._process_reqs(reqs)
def add_priv_reqs(self, reqs):
- self.priv_reqs += mesonlib.stringlistify(reqs)
+ self.priv_reqs += self._process_reqs(reqs)
+
+ def _process_reqs(self, reqs):
+ '''Returns string names of requirements'''
+ processed_reqs = []
+ for obj in mesonlib.listify(reqs, unholder=True):
+ if hasattr(obj, 'generated_pc'):
+ processed_reqs.append(obj.generated_pc)
+ elif hasattr(obj, 'pcdep'):
+ pcdeps = mesonlib.listify(obj.pcdep)
+ processed_reqs += [i.name for i in pcdeps]
+ elif isinstance(obj, dependencies.PkgConfigDependency):
+ if obj.found():
+ processed_reqs.append(obj.name)
+ elif isinstance(obj, str):
+ processed_reqs.append(obj)
+ else:
+ raise mesonlib.MesonException('requires argument not a string, '
+ 'library with pkgconfig-generated file '
+ 'or pkgconfig-dependency object.')
+ return processed_reqs
def add_cflags(self, cflags):
self.cflags += mesonlib.stringlistify(cflags)
def _process_libs(self, libs, public):
- libs = mesonlib.listify(libs)
+ libs = mesonlib.listify(libs, unholder=True)
processed_libs = []
processed_reqs = []
processed_cflags = []
for obj in libs:
- if hasattr(obj, 'held_object'):
- obj = obj.held_object
if hasattr(obj, 'pcdep'):
pcdeps = mesonlib.listify(obj.pcdep)
processed_reqs += [i.name for i in pcdeps]
@@ -96,7 +114,7 @@ class DependenciesHelper:
self.priv_reqs = list(set(self.priv_reqs))
self.cflags = list(set(self.cflags))
- # Remove from pivate libs/reqs if they are in public already
+ # Remove from private libs/reqs if they are in public already
self.priv_libs = [i for i in self.priv_libs if i not in self.pub_libs]
self.priv_reqs = [i for i in self.priv_reqs if i not in self.pub_reqs]
diff --git a/run_unittests.py b/run_unittests.py
index cbae559..9c7b16b 100755
--- a/run_unittests.py
+++ b/run_unittests.py
@@ -2234,6 +2234,14 @@ class LinuxlikeTests(BasePlatformTests):
'-llibinternal', '-lcustom2',
'-lfoo']))
+ cmd = ['pkg-config', 'requires-test']
+ out = self._run(cmd + ['--print-requires']).strip().split()
+ self.assertEqual(sorted(out), sorted(['libexposed', 'libfoo', 'libhello']))
+
+ cmd = ['pkg-config', 'requires-private-test']
+ out = self._run(cmd + ['--print-requires-private']).strip().split()
+ self.assertEqual(sorted(out), sorted(['libexposed', 'libfoo', 'libhello']))
+
def test_pkg_unfound(self):
testdir = os.path.join(self.unit_test_dir, '22 unfound pkgconfig')
self.init(testdir)
@@ -2318,7 +2326,7 @@ class LinuxlikeTests(BasePlatformTests):
self.assertTrue(msg in mesonlog or msg2 in mesonlog)
def _test_soname_impl(self, libpath, install):
- if is_cygwin() or is_osx:
+ if is_cygwin() or is_osx():
raise unittest.SkipTest('Test only applicable to ELF and linuxlike sonames')
testdir = os.path.join(self.unit_test_dir, '1 soname')
diff --git a/test cases/common/51 pkgconfig-gen/dependencies/meson.build b/test cases/common/51 pkgconfig-gen/dependencies/meson.build
index a767eb5..018b72f 100644
--- a/test cases/common/51 pkgconfig-gen/dependencies/meson.build
+++ b/test cases/common/51 pkgconfig-gen/dependencies/meson.build
@@ -21,7 +21,7 @@ custom_dep = declare_dependency(link_args : ['-lcustom'], compile_args : ['-DCUS
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 libmain in libraries should pull implicitly 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
@@ -36,3 +36,17 @@ pkgg.generate(libraries : [main_lib, exposed_lib, threads_dep , custom_dep],
filebase : 'dependency-test',
description : 'A dependency test.'
)
+
+pkgg.generate(
+ name : 'requires-test',
+ version : '1.0',
+ description : 'Dependency Requires field test.',
+ requires : [exposed_lib, pc_dep, 'libhello'],
+)
+
+pkgg.generate(
+ name : 'requires-private-test',
+ version : '1.0',
+ description : 'Dependency Requires.private field test.',
+ requires_private : [exposed_lib, pc_dep, 'libhello', notfound_dep],
+)
diff --git a/test cases/common/51 pkgconfig-gen/meson.build b/test cases/common/51 pkgconfig-gen/meson.build
index f9d7f7f..7e6c670 100644
--- a/test cases/common/51 pkgconfig-gen/meson.build
+++ b/test cases/common/51 pkgconfig-gen/meson.build
@@ -46,3 +46,9 @@ pkgg.generate(
description : 'A foo library.',
variables : ['foo=bar', 'datadir=${prefix}/data']
)
+
+pkgg.generate(
+ name : 'libhello',
+ description : 'A minimalistic pkgconfig file.',
+ version : libver,
+)