Run pkg-config on the specified package Returns ("-l flags", "-I flags", "-L flags", "version") otherwise (None, None, None, None)
(pkg)
| 1296 | return s if isinstance(s, str) else s.decode("utf-8") |
| 1297 | |
| 1298 | def pkg_config(pkg): |
| 1299 | """Run pkg-config on the specified package |
| 1300 | Returns ("-l flags", "-I flags", "-L flags", "version") |
| 1301 | otherwise (None, None, None, None)""" |
| 1302 | pkg_config = os.environ.get('PKG_CONFIG', 'pkg-config') |
| 1303 | args = [] # Print pkg-config warnings on first round. |
| 1304 | retval = [] |
| 1305 | for flag in ['--libs-only-l', '--cflags-only-I', |
| 1306 | '--libs-only-L', '--modversion']: |
| 1307 | args += [flag] |
| 1308 | if isinstance(pkg, list): |
| 1309 | args += pkg |
| 1310 | else: |
| 1311 | args += [pkg] |
| 1312 | try: |
| 1313 | proc = subprocess.Popen(shlex.split(pkg_config) + args, |
| 1314 | stdout=subprocess.PIPE) |
| 1315 | with proc: |
| 1316 | val = to_utf8(proc.communicate()[0]).strip() |
| 1317 | except OSError as e: |
| 1318 | if e.errno != errno.ENOENT: |
| 1319 | raise e # Unexpected error. |
| 1320 | return (None, None, None, None) # No pkg-config/pkgconf installed. |
| 1321 | retval.append(val) |
| 1322 | args = ['--silence-errors'] |
| 1323 | return tuple(retval) |
| 1324 | |
| 1325 | |
| 1326 | def try_check_compiler(cc, lang): |
no test coverage detected
searching dependent graphs…