PkgConfigDependency: Add a get_variable method.

pull/140/head
Mathieu Duponchelle 10 years ago
parent a08374b9a9
commit 9c9e94d531
  1. 16
      dependencies.py

@ -90,6 +90,8 @@ class PkgConfigDependency(Dependency):
else:
pkgbin = 'pkg-config'
type_string = 'Native'
self.pkgbin = pkgbin
p = subprocess.Popen([pkgbin, '--modversion', name], stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
out = p.communicate()[0]
@ -142,6 +144,20 @@ class PkgConfigDependency(Dependency):
self.libs.append(lib)
def get_variable(self, variable_name):
p = subprocess.Popen([self.pkgbin, '--variable=%s' %
variable_name, self.name], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out = p.communicate()[0]
if p.returncode != 0:
if required:
raise DependencyException('%s dependency %s not found.' %
(type_string, self.name))
else:
variable = out.decode().strip()
mlog.debug ("return of subprocess : ", variable)
return variable
def get_modversion(self):
return self.modversion

Loading…
Cancel
Save