Chromium Code Reviews| Index: build/config/linux/pkg-config.py |
| diff --git a/build/config/linux/pkg-config.py b/build/config/linux/pkg-config.py |
| index d707c5f1e32c8fdb08a5cec59df1484cf66986c2..3374046029ff41474da3ff65cb4900a29331c533 100755 |
| --- a/build/config/linux/pkg-config.py |
| +++ b/build/config/linux/pkg-config.py |
| @@ -42,7 +42,7 @@ 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.""" |
| @@ -55,13 +55,11 @@ 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 |
| + # Add the sysroot path to the environment's PKG_CONFIG_LIBDIR |
|
Lei Zhang
2016/01/12 23:01:50
More like overwrite than add.
Sam Clegg
2016/01/12 23:25:12
Done
|
| 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 |
| + os.environ['PKG_CONFIG_LIBDIR'] = config_path |
| + return config_path |
| def GetPkgConfigPrefixToStrip(args): |
| @@ -131,9 +129,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 +148,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: |