OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2013 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 import json | 6 import json |
7 import os | 7 import os |
8 import subprocess | 8 import subprocess |
9 import sys | 9 import sys |
10 import re | 10 import re |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 parser.add_option('-p', action='store', dest='pkg_config', type='string', | 116 parser.add_option('-p', action='store', dest='pkg_config', type='string', |
117 default='pkg-config') | 117 default='pkg-config') |
118 parser.add_option('-v', action='append', dest='strip_out', type='string') | 118 parser.add_option('-v', action='append', dest='strip_out', type='string') |
119 parser.add_option('-s', action='store', dest='sysroot', type='string') | 119 parser.add_option('-s', action='store', dest='sysroot', type='string') |
120 parser.add_option('-a', action='store', dest='arch', type='string') | 120 parser.add_option('-a', action='store', dest='arch', type='string') |
121 parser.add_option('--system_libdir', action='store', dest='system_libdir', | 121 parser.add_option('--system_libdir', action='store', dest='system_libdir', |
122 type='string', default='lib') | 122 type='string', default='lib') |
123 parser.add_option('--atleast-version', action='store', | 123 parser.add_option('--atleast-version', action='store', |
124 dest='atleast_version', type='string') | 124 dest='atleast_version', type='string') |
125 parser.add_option('--libdir', action='store_true', dest='libdir') | 125 parser.add_option('--libdir', action='store_true', dest='libdir') |
| 126 parser.add_option('--dridriverdir', action='store_true', dest='dridriverdir') |
126 (options, args) = parser.parse_args() | 127 (options, args) = parser.parse_args() |
127 | 128 |
128 # Make a list of regular expressions to strip out. | 129 # Make a list of regular expressions to strip out. |
129 strip_out = [] | 130 strip_out = [] |
130 if options.strip_out != None: | 131 if options.strip_out != None: |
131 for regexp in options.strip_out: | 132 for regexp in options.strip_out: |
132 strip_out.append(re.compile(regexp)) | 133 strip_out.append(re.compile(regexp)) |
133 | 134 |
134 if options.sysroot: | 135 if options.sysroot: |
135 libdir = SetConfigPath(options) | 136 libdir = SetConfigPath(options) |
(...skipping 19 matching lines...) Expand all Loading... |
155 if options.debug: | 156 if options.debug: |
156 sys.stderr.write('Running: %s\n' % cmd) | 157 sys.stderr.write('Running: %s\n' % cmd) |
157 try: | 158 try: |
158 libdir = subprocess.check_output(cmd) | 159 libdir = subprocess.check_output(cmd) |
159 except: | 160 except: |
160 print "Error from pkg-config." | 161 print "Error from pkg-config." |
161 return 1 | 162 return 1 |
162 sys.stdout.write(libdir.strip()) | 163 sys.stdout.write(libdir.strip()) |
163 return 0 | 164 return 0 |
164 | 165 |
| 166 if options.dridriverdir: |
| 167 cmd = [options.pkg_config, "--variable=dridriverdir"] + args |
| 168 if options.debug: |
| 169 sys.stderr.write('Running: %s\n' % cmd) |
| 170 try: |
| 171 dridriverdir = subprocess.check_output(cmd) |
| 172 except: |
| 173 print "Error from pkg-config." |
| 174 return 1 |
| 175 sys.stdout.write(dridriverdir.strip()) |
| 176 return 0 |
| 177 |
165 cmd = [options.pkg_config, "--cflags", "--libs"] + args | 178 cmd = [options.pkg_config, "--cflags", "--libs"] + args |
166 if options.debug: | 179 if options.debug: |
167 sys.stderr.write('Running: %s\n' % ' '.join(cmd)) | 180 sys.stderr.write('Running: %s\n' % ' '.join(cmd)) |
168 | 181 |
169 try: | 182 try: |
170 flag_string = subprocess.check_output(cmd) | 183 flag_string = subprocess.check_output(cmd) |
171 except: | 184 except: |
172 sys.stderr.write('Could not run pkg-config.\n') | 185 sys.stderr.write('Could not run pkg-config.\n') |
173 return 1 | 186 return 1 |
174 | 187 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 | 223 |
211 # Output a GN array, the first one is the cflags, the second are the libs. The | 224 # Output a GN array, the first one is the cflags, the second are the libs. The |
212 # JSON formatter prints GN compatible lists when everything is a list of | 225 # JSON formatter prints GN compatible lists when everything is a list of |
213 # strings. | 226 # strings. |
214 print json.dumps([includes, cflags, libs, lib_dirs, ldflags]) | 227 print json.dumps([includes, cflags, libs, lib_dirs, ldflags]) |
215 return 0 | 228 return 0 |
216 | 229 |
217 | 230 |
218 if __name__ == '__main__': | 231 if __name__ == '__main__': |
219 sys.exit(main()) | 232 sys.exit(main()) |
OLD | NEW |