Commit cf2215de authored by Tomasz Figa's avatar Tomasz Figa Committed by Commit Bot

Always honor pkg-config command coming from the user

When building from within a ChromiumOS chroot (and any other
Gentoo-base system), the right command to call pkg-config is specified
up front and needs to be honored. However currently Chromium build
system always calls 'pkg-config' directly if --sysroot is given to the
build. This ignores any necessary setup done by the board sysroot
pkg-config wrapper used on ChromiumOS and causes host's paths being
pulled into the build. Precisely, PKG_CONFIG_PATH is not being unset and
PKG_CONFIG_SYSROOT_DIR is not being set to the sysroot path.

Fix this by always using the specified pkg-config binary, even if
sysroot is given. Even though, the problem could be fixed up by adding
necessary setup to Chromium's pkg-config wrapper, it is not the right
solution, as the setup is inherently sysroot specific and only the
external build system is aware of necessary configuration to be done.

Bug: 743366
Test: Build chromeos-chrome with host's /usr/lib64/pkgconfig/dbus-1.pc chmodded to a-r.
Change-Id: I6e80dbaa94510e31aa5000c6cc31ca32b5e5cbe4
Reviewed-on: https://chromium-review.googlesource.com/572666Reviewed-by: default avatarDirk Pranke <dpranke@chromium.org>
Commit-Queue: Tomasz Figa <tfiga@chromium.org>
Cr-Commit-Position: refs/heads/master@{#487005}
parent 6b30abd0
...@@ -63,7 +63,7 @@ def SetConfigPath(options): ...@@ -63,7 +63,7 @@ def SetConfigPath(options):
return libdir return libdir
def GetPkgConfigPrefixToStrip(args): def GetPkgConfigPrefixToStrip(options, args):
"""Returns the prefix from pkg-config where packages are installed. """Returns the prefix from pkg-config where packages are installed.
This returned prefix is the one that should be stripped from the beginning of This returned prefix is the one that should be stripped from the beginning of
...@@ -76,8 +76,8 @@ def GetPkgConfigPrefixToStrip(args): ...@@ -76,8 +76,8 @@ def GetPkgConfigPrefixToStrip(args):
# instead of relative to /path/to/chroot/build/x86-generic (i.e prefix=/usr). # instead of 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 # To support this correctly, it's necessary to extract the prefix to strip
# from pkg-config's |prefix| variable. # from pkg-config's |prefix| variable.
prefix = subprocess.check_output(["pkg-config", "--variable=prefix"] + args, prefix = subprocess.check_output([options.pkg_config,
env=os.environ) "--variable=prefix"] + args, env=os.environ)
if prefix[-4] == '/usr': if prefix[-4] == '/usr':
return prefix[4:] return prefix[4:]
return prefix return prefix
...@@ -135,7 +135,7 @@ def main(): ...@@ -135,7 +135,7 @@ def main():
libdir = SetConfigPath(options) libdir = SetConfigPath(options)
if options.debug: if options.debug:
sys.stderr.write('PKG_CONFIG_LIBDIR=%s\n' % libdir) sys.stderr.write('PKG_CONFIG_LIBDIR=%s\n' % libdir)
prefix = GetPkgConfigPrefixToStrip(args) prefix = GetPkgConfigPrefixToStrip(options, args)
else: else:
prefix = '' prefix = ''
......
...@@ -51,21 +51,23 @@ pkg_config_script = "//build/config/linux/pkg-config.py" ...@@ -51,21 +51,23 @@ pkg_config_script = "//build/config/linux/pkg-config.py"
# Define the args we pass to the pkg-config script for other build files that # Define the args we pass to the pkg-config script for other build files that
# need to invoke it manually. # need to invoke it manually.
pkg_config_args = []
if (sysroot != "") { if (sysroot != "") {
# Pass the sysroot if we're using one (it requires the CPU arch also). # Pass the sysroot if we're using one (it requires the CPU arch also).
pkg_config_args = [ pkg_config_args += [
"-s", "-s",
rebase_path(sysroot), rebase_path(sysroot),
"-a", "-a",
current_cpu, current_cpu,
] ]
} else if (pkg_config != "") { }
pkg_config_args = [
if (pkg_config != "") {
pkg_config_args += [
"-p", "-p",
pkg_config, pkg_config,
] ]
} else {
pkg_config_args = []
} }
# Only use the custom libdir when building with the target sysroot. # Only use the custom libdir when building with the target sysroot.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment