blob: 249238eccb9c8eaea3db2fe91fea0fc4413e1f5f (
plain) (
blame)
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
36
37
38
39
40
41
42
43
44
45
46
47
|
# Copyright (c) 2020 Egor Tensin <Egor.Tensin@gmail.com>
# This file is part of the "cmake-common" project.
# For details, see https://github.com/egor-tensin/cmake-common.
# Distributed under the MIT License.
import argparse
from enum import Enum
import platform
class Platform(Enum):
'''I only build for x86(-64), so here it goes.'''
X86 = 'x86'
X64 = 'x64'
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 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
raise NotImplementedError(f'unsupported platform: {self}')
|