add support for cups dependencies (#2255)

* add support for cups dependencies

libcups has its own cups-config tool rather than using pkg-config.
This adds support for cups-config, based on pcap-config and
sdl2-config implementations.

This change also includes the unit test case and documentation for
cups dependency object implementation, and libcups2 dep to CI image.
pull/2220/head
Iñigo Martínez 7 years ago committed by Jussi Pakkanen
parent 5f0a91baa5
commit 35ef236c43
  1. 2
      ciimage/Dockerfile
  2. 10
      docs/markdown/Dependencies.md
  3. 3
      mesonbuild/dependencies/__init__.py
  4. 2
      mesonbuild/dependencies/base.py
  5. 48
      mesonbuild/dependencies/misc.py
  6. 8
      test cases/frameworks/20 cups/cups_prog.c
  7. 7
      test cases/frameworks/20 cups/meson.build

@ -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

@ -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

@ -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,

@ -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.

@ -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]

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

@ -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)
Loading…
Cancel
Save