diff options
author | Xavier Claessens <xavier.claessens@collabora.com> | 2021-04-06 14:29:23 -0400 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2021-04-19 17:57:34 +0300 |
commit | 3c64ecaf866ca611b40287c78f622e370f90f272 (patch) | |
tree | f9d39368fe36c75295ed2d60d045392a98da166e /mesonbuild | |
parent | 8f6ad8e52e7ad7663b7737f32cb6c624971830fe (diff) | |
download | meson-3c64ecaf866ca611b40287c78f622e370f90f272.zip meson-3c64ecaf866ca611b40287c78f622e370f90f272.tar.gz meson-3c64ecaf866ca611b40287c78f622e370f90f272.tar.bz2 |
pkgconfig: Add support for CustomTarget objects in generator
Fixes: #8618.
Diffstat (limited to 'mesonbuild')
-rw-r--r-- | mesonbuild/build.py | 3 | ||||
-rw-r--r-- | mesonbuild/modules/pkgconfig.py | 24 |
2 files changed, 21 insertions, 6 deletions
diff --git a/mesonbuild/build.py b/mesonbuild/build.py index 69e853f..06e40f5 100644 --- a/mesonbuild/build.py +++ b/mesonbuild/build.py @@ -2601,6 +2601,9 @@ class CustomTargetIndex: def extract_all_objects_recurse(self): return self.target.extract_all_objects_recurse() + def get_custom_install_dir(self): + return self.target.get_custom_install_dir() + class ConfigurationData: def __init__(self) -> None: super().__init__() diff --git a/mesonbuild/modules/pkgconfig.py b/mesonbuild/modules/pkgconfig.py index 3f06ed0..18815f6 100644 --- a/mesonbuild/modules/pkgconfig.py +++ b/mesonbuild/modules/pkgconfig.py @@ -153,6 +153,11 @@ class DependenciesHelper: obj.link_whole_targets, obj.external_deps, isinstance(obj, build.StaticLibrary) and public) + elif isinstance(obj, (build.CustomTarget, build.CustomTargetIndex)): + if not obj.is_linkable_target(): + raise mesonlib.MesonException('library argument contains a not linkable custom_target.') + FeatureNew.single_use('custom_target in pkgconfig.generate libraries', '0.58.0', self.state.subproject) + processed_libs.append(obj) elif isinstance(obj, str): processed_libs.append(obj) else: @@ -276,7 +281,13 @@ class DependenciesHelper: class PkgConfigModule(ExtensionModule): - def _get_lname(self, l, msg, pcfile): + def _get_lname(self, l, msg, pcfile, is_custom_target): + if is_custom_target: + basename = os.path.basename(l.get_filename()) + name = os.path.splitext(basename)[0] + if name.startswith('lib'): + name = name[3:] + return name # Nothing special if not l.name_prefix_set: return l.name @@ -373,7 +384,8 @@ class PkgConfigModule(ExtensionModule): install_dir = l.get_custom_install_dir()[0] if install_dir is False: continue - if 'cs' in l.compilers: + is_custom_target = isinstance(l, (build.CustomTarget, build.CustomTargetIndex)) + if not is_custom_target and 'cs' in l.compilers: if isinstance(install_dir, str): Lflag = '-r${{prefix}}/{}/{}'.format(self._escape(self._make_relative(prefix, install_dir)), l.filename) else: # install_dir is True @@ -386,18 +398,18 @@ class PkgConfigModule(ExtensionModule): if Lflag not in Lflags: Lflags.append(Lflag) yield Lflag - lname = self._get_lname(l, msg, pcfile) + lname = self._get_lname(l, msg, pcfile, is_custom_target) # If using a custom suffix, the compiler may not be able to # find the library - if l.name_suffix_set: + if not is_custom_target and l.name_suffix_set: mlog.warning(msg.format(l.name, 'name_suffix', lname, pcfile)) - if 'cs' not in l.compilers: + if is_custom_target or 'cs' not in l.compilers: yield '-l%s' % lname def get_uninstalled_include_dirs(libs): result = [] for l in libs: - if isinstance(l, str): + if isinstance(l, (str, build.CustomTarget, build.CustomTargetIndex)): continue if l.get_subdir() not in result: result.append(l.get_subdir()) |