-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcompiler_arch_option.py
More file actions
35 lines (28 loc) · 852 Bytes
/
compiler_arch_option.py
File metadata and controls
35 lines (28 loc) · 852 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from subprocess import check_output, CalledProcessError
from enum import Enum
class CompilerArchOption(Enum):
MIPSBE = "mipsbe"
MIPSLE = "mipsle"
ARMLE = "armle"
X86 = "x86"
X86_64 = "x86_64"
POWERPCLE = "powerpcle"
def get_current_platform():
try:
machine_bytes = check_output(["gcc", "-dumpmachine"])
except FileNotFoundError:
return None
except CalledProcessError:
return None
machine = machine_bytes.decode()
if "mips-" in machine:
return CompilerArchOption.MIPSBE
if "mipsel-" in machine:
return CompilerArchOption.MIPSLE
if "arm-" in machine:
return CompilerArchOption.ARMLE
if "x86_64-" in machine:
return CompilerArchOption.X86_64
if "powerpc64le-" in machine:
return CompilerArchOption.POWERPCLE
return None