Return true if the architecture supports the -arch flag
(cmd, arch)
| 524 | |
| 525 | |
| 526 | def _can_target(cmd, arch): |
| 527 | """Return true if the architecture supports the -arch flag""" |
| 528 | newcmd = cmd[:] |
| 529 | fid, filename = tempfile.mkstemp(suffix=".f") |
| 530 | os.close(fid) |
| 531 | try: |
| 532 | d = os.path.dirname(filename) |
| 533 | output = os.path.splitext(filename)[0] + ".o" |
| 534 | try: |
| 535 | newcmd.extend(["-arch", arch, "-c", filename]) |
| 536 | p = Popen(newcmd, stderr=STDOUT, stdout=PIPE, cwd=d) |
| 537 | p.communicate() |
| 538 | return p.returncode == 0 |
| 539 | finally: |
| 540 | if os.path.exists(output): |
| 541 | os.remove(output) |
| 542 | finally: |
| 543 | os.remove(filename) |
| 544 | |
| 545 | |
| 546 | if __name__ == '__main__': |
no test coverage detected