diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2020-03-28 19:19:22 +0000 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2020-03-28 23:54:28 +0000 |
commit | 8a408b4c95a5e6be2808ef9516bcbebddf8b09a6 (patch) | |
tree | 611639829cb54daabb7d536e5c11ffaadf5a03d5 /project/platform.py | |
parent | WIP: restructure (diff) | |
download | cmake-common-8a408b4c95a5e6be2808ef9516bcbebddf8b09a6.tar.gz cmake-common-8a408b4c95a5e6be2808ef9516bcbebddf8b09a6.zip |
project.boost: factor out Configuration/Platform/Linkage
Diffstat (limited to '')
-rw-r--r-- | project/platform.py | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/project/platform.py b/project/platform.py new file mode 100644 index 0000000..63f6231 --- /dev/null +++ b/project/platform.py @@ -0,0 +1,41 @@ +# 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 + + +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. + ''' + + X86 = 'x86' + X64 = 'x64' + WIN32 = 'Win32' + + def __str__(self): + return self.value + + @staticmethod + def all(): + return (Platform.X86, Platform.X64) + + @staticmethod + def parse(s): + try: + return Platform(s) + except ValueError: + raise argparse.ArgumentTypeError(f'invalid platform: {s}') + + def get_address_model(self): + 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}') |