aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/project/platform.py
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2020-03-30 00:13:20 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2020-03-30 00:53:14 +0300
commit8a8941b853ba5ccecc65cf55222c6c129e92d675 (patch)
treed3a251cdfe4be68914f43103876d908930314bb4 /project/platform.py
parentproject.boost: first-class MinGW-w64 support (diff)
downloadcmake-common-8a8941b853ba5ccecc65cf55222c6c129e92d675.tar.gz
cmake-common-8a8941b853ba5ccecc65cf55222c6c129e92d675.zip
project: minor-ish refactoring
Diffstat (limited to '')
-rw-r--r--project/platform.py22
1 files changed, 14 insertions, 8 deletions
diff --git a/project/platform.py b/project/platform.py
index 63f6231..249238e 100644
--- a/project/platform.py
+++ b/project/platform.py
@@ -5,37 +5,43 @@
import argparse
from enum import Enum
+import platform
class Platform(Enum):
- '''I only build for x86(-64), so here it goes.
-
- Win32 is just Visual Studio convention, it's effectively an alias for x86.
- '''
+ '''I only build for x86(-64), so here it goes.'''
X86 = 'x86'
X64 = 'x64'
- WIN32 = 'Win32'
def __str__(self):
return self.value
@staticmethod
+ def native():
+ # Source: https://stackoverflow.com/a/12578715/514684
+ if platform.machine().endswith('64'):
+ return Platform.X64
+ return Platform.X86
+
+ @staticmethod
def all():
- return (Platform.X86, Platform.X64)
+ return tuple(Platform)
@staticmethod
def parse(s):
try:
+ if s == 'Win32':
+ # AppVeyor convention:
+ return Platform.X86
return Platform(s)
except ValueError:
raise argparse.ArgumentTypeError(f'invalid platform: {s}')
def get_address_model(self):
+ '''Maps to Boost's address-model.'''
if self is Platform.X86:
return 32
if self is Platform.X64:
return 64
- if self is Platform.WIN32:
- return 32
raise NotImplementedError(f'unsupported platform: {self}')