diff --git a/ciimage/Dockerfile b/ciimage/Dockerfile index 2691900f5..1c9e8d8c5 100644 --- a/ciimage/Dockerfile +++ b/ciimage/Dockerfile @@ -10,7 +10,7 @@ RUN apt-get -y update && apt-get -y upgrade \ && apt-get -y install python3-pip libxml2-dev libxslt1-dev cmake libyaml-dev \ && apt-get -y install openmpi-bin libopenmpi-dev \ && apt-get -y install libboost-log-dev \ -&& apt-get -y install libvulkan-dev libpcap-dev \ +&& apt-get -y install libvulkan-dev libpcap-dev libcups2-dev \ && apt-get -y install gcovr lcov \ && apt-get -y install gtk-sharp2 gtk-sharp2-gapi libglib2.0-cil-dev \ && python3 -m pip install hotdoc codecov diff --git a/docs/markdown/Dependencies.md b/docs/markdown/Dependencies.md index 9050696be..187c4fe4b 100644 --- a/docs/markdown/Dependencies.md +++ b/docs/markdown/Dependencies.md @@ -132,6 +132,16 @@ automatically: pcap_dep = dependency('pcap', version : '>=1.0') ``` +## CUPS + +The cups library does not ship with pkg-config at the time or writing +but instead it has its own `cups-config` util. Meson will use it +automatically: + +```meson +cups_dep = dependency('cups', version : '>=1.4') +``` + ## Declaring your own You can declare your own dependency objects that can be used diff --git a/mesonbuild/dependencies/__init__.py b/mesonbuild/dependencies/__init__.py index 61e108020..aa291901d 100644 --- a/mesonbuild/dependencies/__init__.py +++ b/mesonbuild/dependencies/__init__.py @@ -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) +from .misc import (BoostDependency, MPIDependency, Python3Dependency, ThreadDependency, PcapDependency, CupsDependency) from .platform import AppleFrameworks from .ui import GLDependency, GnuStepDependency, Qt4Dependency, Qt5Dependency, SDL2Dependency, WxDependency, VulkanDependency @@ -35,6 +35,7 @@ packages.update({ 'python3': Python3Dependency, 'threads': ThreadDependency, 'pcap': PcapDependency, + 'cups': CupsDependency, # From platform: 'appleframeworks': AppleFrameworks, diff --git a/mesonbuild/dependencies/base.py b/mesonbuild/dependencies/base.py index 26fc76eef..cc4837ad7 100644 --- a/mesonbuild/dependencies/base.py +++ b/mesonbuild/dependencies/base.py @@ -46,6 +46,8 @@ class DependencyMethods(Enum): SDLCONFIG = 'sdlconfig' # Detect using pcap-config PCAPCONFIG = 'pcap-config' + # Detect using cups-config + CUPSCONFIG = 'cups-config' # This is only supported on OSX - search the frameworks directory by name. EXTRAFRAMEWORK = 'extraframework' # Detect using the sysconfig module. diff --git a/mesonbuild/dependencies/misc.py b/mesonbuild/dependencies/misc.py index 0112fd3cf..12e0239dc 100644 --- a/mesonbuild/dependencies/misc.py +++ b/mesonbuild/dependencies/misc.py @@ -623,3 +623,51 @@ class PcapDependency(ExternalDependency): return [DependencyMethods.PKGCONFIG, DependencyMethods.PCAPCONFIG, DependencyMethods.EXTRAFRAMEWORK] else: return [DependencyMethods.PKGCONFIG, DependencyMethods.PCAPCONFIG] + +class CupsDependency(ExternalDependency): + def __init__(self, environment, kwargs): + super().__init__('cups', environment, None, kwargs) + if DependencyMethods.PKGCONFIG in self.methods: + try: + kwargs['required'] = False + pcdep = PkgConfigDependency('cups', 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('cups not found via pkgconfig. Trying next, error was:', str(e)) + if DependencyMethods.CUPSCONFIG in self.methods: + cupsconf = shutil.which('cups-config') + if cupsconf: + stdo = Popen_safe(['cups-config', '--cflags'])[1] + self.compile_args = stdo.strip().split() + stdo = Popen_safe(['cups-config', '--libs'])[1] + self.link_args = stdo.strip().split() + stdo = Popen_safe(['cups-config', '--version'])[1] + self.version = stdo.strip().split() + self.is_found = True + mlog.log('Dependency', mlog.bold('cups'), 'found:', + mlog.green('YES'), '(%s)' % cupsconf) + return + mlog.debug('Could not find cups-config binary, trying next.') + if DependencyMethods.EXTRAFRAMEWORK in self.methods: + if mesonlib.is_osx(): + fwdep = ExtraFrameworkDependency('cups', False, None, self.env, + self.language, kwargs) + if fwdep.found(): + self.is_found = True + self.compile_args = fwdep.get_compile_args() + self.link_args = fwdep.get_link_args() + self.version = fwdep.get_version() + return + mlog.log('Dependency', mlog.bold('cups'), 'found:', mlog.red('NO')) + + def get_methods(self): + if mesonlib.is_osx(): + return [DependencyMethods.PKGCONFIG, DependencyMethods.CUPSCONFIG, DependencyMethods.EXTRAFRAMEWORK] + else: + return [DependencyMethods.PKGCONFIG, DependencyMethods.CUPSCONFIG] diff --git a/test cases/frameworks/20 cups/cups_prog.c b/test cases/frameworks/20 cups/cups_prog.c new file mode 100644 index 000000000..d6b6dcc3f --- /dev/null +++ b/test cases/frameworks/20 cups/cups_prog.c @@ -0,0 +1,8 @@ +#include + +int +main() +{ + cupsGetDefault(); + return 0; +} diff --git a/test cases/frameworks/20 cups/meson.build b/test cases/frameworks/20 cups/meson.build new file mode 100644 index 000000000..6c9b6fefa --- /dev/null +++ b/test cases/frameworks/20 cups/meson.build @@ -0,0 +1,7 @@ +project('cups test', 'c') + +cups_dep = dependency('cups', version : '>=1.4') + +e = executable('cups_prog', 'cups_prog.c', dependencies : cups_dep) + +test('cupstest', e)