(cc, lang)
| 1324 | |
| 1325 | |
| 1326 | def try_check_compiler(cc, lang): |
| 1327 | try: |
| 1328 | proc = subprocess.Popen(shlex.split(cc) + ['-E', '-P', '-x', lang, '-'], |
| 1329 | stdin=subprocess.PIPE, stdout=subprocess.PIPE) |
| 1330 | except OSError: |
| 1331 | return (False, False, '', '', False) |
| 1332 | |
| 1333 | with proc: |
| 1334 | proc.stdin.write(b'__clang__ __GNUC__ __GNUC_MINOR__ __GNUC_PATCHLEVEL__ ' |
| 1335 | b'__clang_major__ __clang_minor__ __clang_patchlevel__ ' |
| 1336 | b'__APPLE__') |
| 1337 | |
| 1338 | cc_out = proc.communicate() |
| 1339 | cc_stdout = to_utf8(cc_out[0]) |
| 1340 | if sys.platform == 'zos': |
| 1341 | values = (cc_stdout.split('\n')[-2].split() + ['0'] * 7)[0:8] |
| 1342 | else: |
| 1343 | values = (cc_stdout.split() + ['0'] * 7)[0:8] |
| 1344 | |
| 1345 | if len(values) < 8: |
| 1346 | cc_stderr = to_utf8(cc_out[1]) if cc_out[1] else '' |
| 1347 | raise Exception(f'Could not determine compiler version info. \nstdout:\n{cc_stdout}\nstderr:\n{cc_stderr}') |
| 1348 | |
| 1349 | is_clang = values[0] == '1' |
| 1350 | gcc_version = tuple(map(int, values[1:1+3])) |
| 1351 | clang_version = tuple(map(int, values[4:4+3])) if is_clang else None |
| 1352 | is_apple = values[7] == '1' |
| 1353 | |
| 1354 | return (True, is_clang, clang_version, gcc_version, is_apple) |
| 1355 | |
| 1356 | |
| 1357 | # |
no test coverage detected
searching dependent graphs…