| 1 |
|
| 2 |
""" Detect bitness (32 or 64) of Mingw-w64 gcc build target on Windows. |
| 3 |
""" |
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
import re |
| 8 |
from subprocess import run |
| 9 |
|
| 10 |
|
| 11 |
def main(): |
| 12 |
res = run( |
| 13 |
['gcc', '-v'], |
| 14 |
check=True, |
| 15 |
text=True, |
| 16 |
capture_output=True |
| 17 |
) |
| 18 |
target = re.search( |
| 19 |
r'^Target: (.*)$', |
| 20 |
res.stderr, |
| 21 |
flags=re.M |
| 22 |
).groups()[0] |
| 23 |
|
| 24 |
if target.startswith('i686'): |
| 25 |
print('32') |
| 26 |
elif target.startswith('x86_64'): |
| 27 |
print('64') |
| 28 |
else: |
| 29 |
raise RuntimeError("Could not detect Mingw-w64 bitness") |
| 30 |
|
| 31 |
|
| 32 |
if __name__ == "__main__": |
| 33 |
main() |