1
# Copyright 2010 Google Inc.
3
# Author: thaloun@google.com (Tim Haloun)
5
"""Tools that we need to include with libjingle."""
10
# We need this in libjingle because main.scons depends on it and
11
# libjingle depends on main.scons.
12
def EnableFeatureWherePackagePresent(env, bit, cpp_flag, package):
13
"""Enable a feature if a required pkg-config package is present.
16
env: The current SCons environment.
17
bit: The name of the Bit to enable when the package is present.
18
cpp_flag: The CPP flag to enable when the package is present.
19
package: The name of the package.
21
if not env.Bit('host_linux'):
23
if _HavePackage(package):
25
env.Append(CPPDEFINES = [cpp_flag])
27
print ('Warning: Package \"%s\" not found. Feature \"%s\" will not be '
28
'built. To build with this feature, install the package that '
29
'provides the \"%s.pc\" file.') % (package, bit, package)
32
def _HavePackage(package):
33
"""Whether the given pkg-config package name is present on the build system.
36
package: The name of the package.
39
True if the package is present, else False
41
return subprocess.call(['pkg-config', '--exists', package]) == 0
44
def generate(env): # pylint: disable-msg=C6409
45
env.AddMethod(EnableFeatureWherePackagePresent)
48
def exists(env): # pylint: disable-msg=C6409,W0613