aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/project/configuration.py
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2020-03-28 19:19:22 +0000
committerEgor Tensin <Egor.Tensin@gmail.com>2020-03-28 23:54:28 +0000
commit8a408b4c95a5e6be2808ef9516bcbebddf8b09a6 (patch)
tree611639829cb54daabb7d536e5c11ffaadf5a03d5 /project/configuration.py
parentWIP: restructure (diff)
downloadcmake-common-8a408b4c95a5e6be2808ef9516bcbebddf8b09a6.tar.gz
cmake-common-8a408b4c95a5e6be2808ef9516bcbebddf8b09a6.zip
project.boost: factor out Configuration/Platform/Linkage
Diffstat (limited to 'project/configuration.py')
-rw-r--r--project/configuration.py42
1 files changed, 42 insertions, 0 deletions
diff --git a/project/configuration.py b/project/configuration.py
new file mode 100644
index 0000000..50489fa
--- /dev/null
+++ b/project/configuration.py
@@ -0,0 +1,42 @@
+# 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 Configuration(Enum):
+ '''Correspond to CMake's default CMAKE_BUILD_TYPE values.'''
+
+ DEBUG = 'Debug'
+ MINSIZEREL = 'MinSizeRel'
+ RELWITHDEBINFO = 'RelWithDebInfo'
+ RELEASE = 'Release'
+
+ def __str__(self):
+ return self.value
+
+ @staticmethod
+ def all():
+ return tuple(Configuration)
+
+ @staticmethod
+ def parse(s):
+ try:
+ return Configuration(s)
+ except ValueError:
+ raise argparse.ArgumentTypeError(f'invalid configuration: {s}')
+
+ def to_boost_variant(self):
+ '''Roughly maps CMake's CMAKE_BUILD_TYPE to Boost's variant.
+
+ AFAIK, Boost only supports debug/release, MinSizeRel and RelWithDebInfo
+ are hence mapped to "release". The libraries will still reside in
+ stage/PLATFORM/CONFIGURATION/lib, if CONFIGURATION is
+ MinSizeRel/RelWithDebInfo.
+ '''
+ if self in (Configuration.MINSIZEREL, Configuration.RELWITHDEBINFO):
+ return Configuration.RELEASE.to_boost_variant()
+ return str(self).lower()