Add LibWmf as a specified dependency, and associated tests.

This commit is contained in:
Félix Piédallu 2017-10-30 11:44:34 +01:00 committed by Jussi Pakkanen
parent 02bea7d5bf
commit bb84c1d109
6 changed files with 69 additions and 1 deletions

View File

@ -153,6 +153,16 @@ automatically:
cups_dep = dependency('cups', version : '>=1.4')
```
## LibWMF
The libwmf library does not ship with pkg-config at the time or writing
but instead it has its own `libwmf-config` util. Meson will use it
automatically:
```meson
libwmf_dep = dependency('libwmf', version : '>=0.2.8')
```
## Declaring your own
You can declare your own dependency objects that can be used

View File

@ -17,7 +17,7 @@ from .base import ( # noqa: F401
ExternalDependency, ExternalLibrary, ExtraFrameworkDependency, InternalDependency,
PkgConfigDependency, find_external_dependency, get_dep_identifier, packages, _packages_accept_language)
from .dev import GMockDependency, GTestDependency, LLVMDependency, ValgrindDependency
from .misc import (BoostDependency, MPIDependency, Python3Dependency, ThreadDependency, PcapDependency, CupsDependency)
from .misc import (BoostDependency, MPIDependency, Python3Dependency, ThreadDependency, PcapDependency, CupsDependency, LibWmfDependency)
from .platform import AppleFrameworks
from .ui import GLDependency, GnuStepDependency, Qt4Dependency, Qt5Dependency, SDL2Dependency, WxDependency, VulkanDependency
@ -36,6 +36,7 @@ packages.update({
'threads': ThreadDependency,
'pcap': PcapDependency,
'cups': CupsDependency,
'libwmf': LibWmfDependency,
# From platform:
'appleframeworks': AppleFrameworks,

View File

@ -48,6 +48,8 @@ class DependencyMethods(Enum):
PCAPCONFIG = 'pcap-config'
# Detect using cups-config
CUPSCONFIG = 'cups-config'
# Detect using libwmf-config
LIBWMFCONFIG = 'libwmf-config'
# This is only supported on OSX - search the frameworks directory by name.
EXTRAFRAMEWORK = 'extraframework'
# Detect using the sysconfig module.

View File

@ -761,6 +761,44 @@ class CupsDependency(ExternalDependency):
else:
return [DependencyMethods.PKGCONFIG, DependencyMethods.CUPSCONFIG]
class LibWmfDependency(ExternalDependency):
def __init__(self, environment, kwargs):
super().__init__('libwmf', environment, None, kwargs)
if DependencyMethods.PKGCONFIG in self.methods:
try:
kwargs['required'] = False
pcdep = PkgConfigDependency('libwmf', environment, kwargs)
if pcdep.found():
self.type_name = 'pkgconfig'
self.is_found = True
self.compile_args = pcdep.get_compile_args()
self.link_args = pcdep.get_link_args()
self.version = pcdep.get_version()
return
except Exception as e:
mlog.debug('LibWmf not found via pkgconfig. Trying next, error was:', str(e))
if DependencyMethods.LIBWMFCONFIG in self.methods:
libwmfconf = shutil.which('libwmf-config')
if libwmfconf:
stdo = Popen_safe(['libwmf-config', '--cflags'])[1]
self.compile_args = stdo.strip().split()
stdo = Popen_safe(['libwmf-config', '--libs'])[1]
self.link_args = stdo.strip().split()
stdo = Popen_safe(['libwmf-config', '--version'])[1]
self.version = stdo.strip()
self.is_found = True
mlog.log('Dependency', mlog.bold('libwmf'), 'found:',
mlog.green('YES'), '(%s)' % libwmfconf)
return
mlog.debug('Could not find libwmf-config binary, trying next.')
def get_methods(self):
if mesonlib.is_osx():
return [DependencyMethods.PKGCONFIG, DependencyMethods.LIBWMFCONFIG, DependencyMethods.EXTRAFRAMEWORK]
else:
return [DependencyMethods.PKGCONFIG, DependencyMethods.LIBWMFCONFIG]
# Generated with boost_names.py
BOOST_LIBS = [
'boost_atomic',

View File

@ -0,0 +1,8 @@
#include <libwmf/api.h>
int
main()
{
wmf_help();
return 0;
}

View File

@ -0,0 +1,9 @@
project('libwmf test', 'c')
libwmf_dep = dependency('libwmf', version : '>=3.0')
libwmf_ver = libwmf_dep.version()
assert(libwmf_ver.split('.').length() > 1, 'libwmf version is "@0@"'.format(libwmf_ver))
message('libwmf version is "@0@"'.format(libwmf_ver))
e = executable('libwmf_prog', 'libwmf_prog.c', dependencies : libwmf_dep)
test('libwmftest', e)