OLD | NEW |
1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import json | 5 import json |
6 import os | 6 import os |
7 import subprocess | 7 import subprocess |
8 import sys | 8 import sys |
9 import re | 9 import re |
10 from optparse import OptionParser | 10 from optparse import OptionParser |
(...skipping 26 matching lines...) Expand all Loading... |
37 print "[[],[],[],[],[]]" | 37 print "[[],[],[],[],[]]" |
38 sys.exit(0) | 38 sys.exit(0) |
39 | 39 |
40 | 40 |
41 def SetConfigPath(options): | 41 def SetConfigPath(options): |
42 """Set the PKG_CONFIG_PATH environment variable. | 42 """Set the PKG_CONFIG_PATH environment variable. |
43 This takes into account any sysroot and architecture specification from the | 43 This takes into account any sysroot and architecture specification from the |
44 options on the given command line.""" | 44 options on the given command line.""" |
45 | 45 |
46 sysroot = options.sysroot | 46 sysroot = options.sysroot |
47 if not sysroot: | 47 assert sysroot |
48 sysroot = "" | |
49 | 48 |
50 # Compute the library path name based on the architecture. | 49 # Compute the library path name based on the architecture. |
51 arch = options.arch | 50 arch = options.arch |
52 if sysroot and not arch: | 51 if sysroot and not arch: |
53 print "You must specify an architecture via -a if using a sysroot." | 52 print "You must specify an architecture via -a if using a sysroot." |
54 sys.exit(1) | 53 sys.exit(1) |
55 | 54 |
56 # In the gyp world this is configurable via the 'system_libdir' variable, | 55 # In the gyp world this is configurable via the 'system_libdir' variable, |
57 # which doesn't seem to have an equivelent in gn yet. | 56 # which doesn't seem to have an equivelent in gn yet. |
58 # TOOD(sbc): Make this configurable like it is under gyp. | 57 # TOOD(sbc): Make this configurable like it is under gyp. |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 dest='atleast_version', type='string') | 114 dest='atleast_version', type='string') |
116 parser.add_option('--libdir', action='store_true', dest='libdir') | 115 parser.add_option('--libdir', action='store_true', dest='libdir') |
117 (options, args) = parser.parse_args() | 116 (options, args) = parser.parse_args() |
118 | 117 |
119 # Make a list of regular expressions to strip out. | 118 # Make a list of regular expressions to strip out. |
120 strip_out = [] | 119 strip_out = [] |
121 if options.strip_out != None: | 120 if options.strip_out != None: |
122 for regexp in options.strip_out: | 121 for regexp in options.strip_out: |
123 strip_out.append(re.compile(regexp)) | 122 strip_out.append(re.compile(regexp)) |
124 | 123 |
125 SetConfigPath(options) | |
126 if options.sysroot: | 124 if options.sysroot: |
| 125 SetConfigPath(options) |
127 prefix = GetPkgConfigPrefixToStrip(args) | 126 prefix = GetPkgConfigPrefixToStrip(args) |
128 else: | 127 else: |
129 prefix = '' | 128 prefix = '' |
130 | 129 |
131 if options.atleast_version: | 130 if options.atleast_version: |
132 # When asking for the return value, just run pkg-config and print the return | 131 # When asking for the return value, just run pkg-config and print the return |
133 # value, no need to do other work. | 132 # value, no need to do other work. |
134 if not subprocess.call([options.pkg_config, | 133 if not subprocess.call([options.pkg_config, |
135 "--atleast-version=" + options.atleast_version] + | 134 "--atleast-version=" + options.atleast_version] + |
136 args, | 135 args, |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 # this anyway. Removing it here prevents a bunch of duplicate inclusions on | 191 # this anyway. Removing it here prevents a bunch of duplicate inclusions on |
193 # the command line. | 192 # the command line. |
194 pass | 193 pass |
195 else: | 194 else: |
196 cflags.append(flag) | 195 cflags.append(flag) |
197 | 196 |
198 # Output a GN array, the first one is the cflags, the second are the libs. The | 197 # Output a GN array, the first one is the cflags, the second are the libs. The |
199 # JSON formatter prints GN compatible lists when everything is a list of | 198 # JSON formatter prints GN compatible lists when everything is a list of |
200 # strings. | 199 # strings. |
201 print json.dumps([includes, cflags, libs, lib_dirs, ldflags]) | 200 print json.dumps([includes, cflags, libs, lib_dirs, ldflags]) |
OLD | NEW |