Handle required flag in pkg-config deps.

pull/15/head
Jussi Pakkanen 12 years ago
parent 325cd7a75b
commit d74a216d9f
  1. 11
      environment.py

@ -411,17 +411,18 @@ class Dependency():
class PkgConfigDependency(Dependency): class PkgConfigDependency(Dependency):
pkgconfig_found = False pkgconfig_found = False
def __init__(self, name): def __init__(self, name, required):
Dependency.__init__(self) Dependency.__init__(self)
self.is_found = False
if not PkgConfigDependency.pkgconfig_found: if not PkgConfigDependency.pkgconfig_found:
self.check_pkgconfig() self.check_pkgconfig()
self.is_found = False
p = subprocess.Popen(['pkg-config', '--modversion', name], stdout=subprocess.PIPE, p = subprocess.Popen(['pkg-config', '--modversion', name], stdout=subprocess.PIPE,
stderr=subprocess.PIPE) stderr=subprocess.PIPE)
out = p.communicate()[0] out = p.communicate()[0]
if p.returncode != 0: if p.returncode != 0:
print('Dependency %s not known to pkg-config.' % name) if required:
raise EnvironmentException('Required dependency %s not found.' % name)
self.modversion = 'none' self.modversion = 'none'
self.cflags = [] self.cflags = []
self.libs = [] self.libs = []
@ -465,8 +466,8 @@ class PkgConfigDependency(Dependency):
# Fixme, move to environment. # Fixme, move to environment.
def find_external_dependency(name, kwargs): def find_external_dependency(name, kwargs):
# Add detectors for non-pkg-config deps (e.g. Boost) etc here. required = kwargs.get('required', False)
return PkgConfigDependency(name) return PkgConfigDependency(name, required)
def test_pkg_config(): def test_pkg_config():
name = 'gtk+-3.0' name = 'gtk+-3.0'

Loading…
Cancel
Save