summaryrefslogtreecommitdiffstats
path: root/build/config
diff options
context:
space:
mode:
authorsbc <sbc@chromium.org>2016-01-13 10:40:17 -0800
committerCommit bot <commit-bot@chromium.org>2016-01-13 18:41:25 +0000
commit4d4a9acde47d5e955c12eb0bf3feaa800c2a6f55 (patch)
tree69b7bbc013d6a11fbc6b0b7d2cf63ac7ef3b9f66 /build/config
parent3fcc48429ef391a40cd5e88f4022ec6e83dd5b92 (diff)
downloadchromium_src-4d4a9acde47d5e955c12eb0bf3feaa800c2a6f55.zip
chromium_src-4d4a9acde47d5e955c12eb0bf3feaa800c2a6f55.tar.gz
chromium_src-4d4a9acde47d5e955c12eb0bf3feaa800c2a6f55.tar.bz2
Use PKG_CONFIG_LIBDIR to force pkg-config to use sysroot only
Previously we were using PKG_CONFIG_PATH to tell pkg-config to search the sysroot directories. However the default libpath is always added to this path, so pkg-config would fall back to looking in the system directories. Using PKG_CONFIG_LIBDIR instead overrides the default libdir which makes the build more hermetic and forces the sysroot to provide all the required .pc files. Review URL: https://codereview.chromium.org/1580643002 Cr-Commit-Position: refs/heads/master@{#369224}
Diffstat (limited to 'build/config')
-rwxr-xr-xbuild/config/linux/pkg-config.py51
1 files changed, 28 insertions, 23 deletions
diff --git a/build/config/linux/pkg-config.py b/build/config/linux/pkg-config.py
index d707c5f..d63b2d6 100755
--- a/build/config/linux/pkg-config.py
+++ b/build/config/linux/pkg-config.py
@@ -42,9 +42,11 @@ from optparse import OptionParser
def SetConfigPath(options):
- """Set the PKG_CONFIG_PATH environment variable.
+ """Set the PKG_CONFIG_LIBDIR environment variable.
+
This takes into account any sysroot and architecture specification from the
- options on the given command line."""
+ options on the given command line.
+ """
sysroot = options.sysroot
assert sysroot
@@ -55,19 +57,18 @@ def SetConfigPath(options):
print "You must specify an architecture via -a if using a sysroot."
sys.exit(1)
- # Add the sysroot path to the environment's PKG_CONFIG_PATH
- config_path = sysroot + '/usr/' + options.system_libdir + '/pkgconfig'
- config_path += ':' + sysroot + '/usr/share/pkgconfig'
- if 'PKG_CONFIG_PATH' in os.environ:
- os.environ['PKG_CONFIG_PATH'] += ':' + config_path
- else:
- os.environ['PKG_CONFIG_PATH'] = config_path
+ libdir = sysroot + '/usr/' + options.system_libdir + '/pkgconfig'
+ libdir += ':' + sysroot + '/usr/share/pkgconfig'
+ os.environ['PKG_CONFIG_LIBDIR'] = libdir
+ return libdir
def GetPkgConfigPrefixToStrip(args):
"""Returns the prefix from pkg-config where packages are installed.
+
This returned prefix is the one that should be stripped from the beginning of
- directory names to take into account sysroots."""
+ directory names to take into account sysroots.
+ """
# Some sysroots, like the Chromium OS ones, may generate paths that are not
# relative to the sysroot. For example,
# /path/to/chroot/build/x86-generic/usr/lib/pkgconfig/pkg.pc may have all
@@ -131,9 +132,9 @@ def main():
strip_out.append(re.compile(regexp))
if options.sysroot:
- SetConfigPath(options)
+ libdir = SetConfigPath(options)
if options.debug:
- sys.stderr.write('PKG_CONFIG_PATH=%s\n' % os.environ['PKG_CONFIG_PATH'])
+ sys.stderr.write('PKG_CONFIG_LIBDIR=%s\n' % libdir)
prefix = GetPkgConfigPrefixToStrip(args)
else:
prefix = ''
@@ -150,28 +151,32 @@ def main():
return 0
if options.libdir:
+ cmd = [options.pkg_config, "--variable=libdir"] + args
+ if options.debug:
+ sys.stderr.write('Running: %s\n' % cmd)
try:
- libdir = subprocess.check_output([options.pkg_config,
- "--variable=libdir"] +
- args)
+ libdir = subprocess.check_output(cmd)
except:
print "Error from pkg-config."
return 1
sys.stdout.write(libdir.strip())
return 0
+ cmd = [options.pkg_config, "--cflags", "--libs"] + args
+ if options.debug:
+ sys.stderr.write('Running: %s\n' % ' '.join(cmd))
+
try:
- flag_string = subprocess.check_output(
- [ options.pkg_config, "--cflags", "--libs" ] +
- args)
- # For now just split on spaces to get the args out. This will break if
- # pkgconfig returns quoted things with spaces in them, but that doesn't seem
- # to happen in practice.
- all_flags = flag_string.strip().split(' ')
+ flag_string = subprocess.check_output(cmd)
except:
- print "Could not run pkg-config."
+ sys.stderr.write('Could not run pkg-config.\n')
return 1
+ # For now just split on spaces to get the args out. This will break if
+ # pkgconfig returns quoted things with spaces in them, but that doesn't seem
+ # to happen in practice.
+ all_flags = flag_string.strip().split(' ')
+
sysroot = options.sysroot
if not sysroot: