summaryrefslogtreecommitdiffstats
path: root/build
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
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')
-rwxr-xr-xbuild/config/linux/pkg-config.py51
-rwxr-xr-xbuild/linux/pkg-config-wrapper15
-rw-r--r--build/linux/sysroot_scripts/sysroot-creator.sh8
3 files changed, 38 insertions, 36 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:
diff --git a/build/linux/pkg-config-wrapper b/build/linux/pkg-config-wrapper
index 2afb22b..2512b38 100755
--- a/build/linux/pkg-config-wrapper
+++ b/build/linux/pkg-config-wrapper
@@ -15,6 +15,9 @@
# the PKG_CONFIG_PATH environment variable- these will be prepended to the
# generated paths.
+set -o nounset
+set -o errexit
+
root="$1"
shift
target_arch="$1"
@@ -31,13 +34,7 @@ fi
rewrite=`dirname $0`/rewrite_dirs.py
package=${!#}
-config_path=$root/usr/$libpath/pkgconfig:$root/usr/share/pkgconfig
-
-# prepend any paths specified by the environment
-if [ -n "$PKG_CONFIG_PATH" ]
-then
- config_path="$PKG_CONFIG_PATH:$config_path"
-fi
+libdir=$root/usr/$libpath/pkgconfig:$root/usr/share/pkgconfig
set -e
# Some sysroots, like the Chromium OS ones, may generate paths that are not
@@ -47,6 +44,6 @@ set -e
# relative to /path/to/chroot/build/x86-generic (i.e prefix=/usr).
# To support this correctly, it's necessary to extract the prefix to strip from
# pkg-config's |prefix| variable.
-prefix=`PKG_CONFIG_PATH=$config_path pkg-config --variable=prefix "$package" | sed -e 's|/usr$||'`
-result=`PKG_CONFIG_PATH=$config_path pkg-config "$@"`
+prefix=`PKG_CONFIG_LIBDIR=$libdir pkg-config --variable=prefix "$package" | sed -e 's|/usr$||'`
+result=`PKG_CONFIG_LIBDIR=$libdir pkg-config "$@"`
echo "$result"| $rewrite --sysroot "$root" --strip-prefix "$prefix"
diff --git a/build/linux/sysroot_scripts/sysroot-creator.sh b/build/linux/sysroot_scripts/sysroot-creator.sh
index 39c787f..e05cf25 100644
--- a/build/linux/sysroot_scripts/sysroot-creator.sh
+++ b/build/linux/sysroot_scripts/sysroot-creator.sh
@@ -261,7 +261,7 @@ HacksAndPatchesAmd64() {
sed -i -e 's|/lib/x86_64-linux-gnu/||g' ${lscripts}
# This is for chrome's ./build/linux/pkg-config-wrapper
- # which overwrites PKG_CONFIG_PATH internally
+ # which overwrites PKG_CONFIG_LIBDIR internally
SubBanner "Move pkgconfig scripts"
mv ${INSTALL_ROOT}/usr/lib/x86_64-linux-gnu/pkgconfig ${INSTALL_ROOT}/usr/lib/
@@ -284,7 +284,7 @@ HacksAndPatchesI386() {
sed -i -e 's|/lib/i386-linux-gnu/||g' ${lscripts}
# This is for chrome's ./build/linux/pkg-config-wrapper
- # which overwrites PKG_CONFIG_PATH internally
+ # which overwrites PKG_CONFIG_LIBDIR internally
SubBanner "Move pkgconfig scripts"
mv ${INSTALL_ROOT}/usr/lib/i386-linux-gnu/pkgconfig ${INSTALL_ROOT}/usr/lib/
@@ -307,7 +307,7 @@ HacksAndPatchesARM() {
sed -i -e 's|/lib/arm-linux-gnueabihf/||g' ${lscripts}
# This is for chrome's ./build/linux/pkg-config-wrapper
- # which overwrites PKG_CONFIG_PATH internally
+ # which overwrites PKG_CONFIG_LIBDIR internally
SubBanner "Move pkgconfig files"
mv ${INSTALL_ROOT}/usr/lib/arm-linux-gnueabihf/pkgconfig \
${INSTALL_ROOT}/usr/lib/
@@ -326,7 +326,7 @@ HacksAndPatchesMips() {
sed -i -e 's|/lib/mipsel-linux-gnu/||g' ${lscripts}
# This is for chrome's ./build/linux/pkg-config-wrapper
- # which overwrites PKG_CONFIG_PATH internally
+ # which overwrites PKG_CONFIG_LIBDIR internally
SubBanner "Move pkgconfig files"
mv ${INSTALL_ROOT}/usr/lib/mipsel-linux-gnu/pkgconfig \
${INSTALL_ROOT}/usr/lib/