build: define BuildType for enclosing build_by_default

in existing `modes` defined in `configure.py`, "release" is mapped to
"RelWithDebInfo". this behavior matches that of seastar's
`configure.py`, where we also map "release" build mode to
"RelWithDebInfo" CMAKE_BUILD_TYPE.

but in scylladb's existing cmake settings, it maps "release" to
"Release", despite "Release" is listed as one of the typical
CMAKE_BUILD_TYPE values.

so, in this change, to prepare for the mapping, `BuildType` is
introduced to map a build mode to its related settings. the
building settings are still kept in `cmake.${CMAKE_BUILD_TYPE}.cmake`,
but the other settings, like if a build type should be enabled or
its mappings, are stored in `BuildType` in `configure.py`.

Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
This commit is contained in:
Kefu Chai
2023-12-20 12:42:45 +08:00
parent 15acceb69f
commit 72dcb2466d

View File

@@ -18,6 +18,7 @@ import sys
import tempfile
import textwrap
from distutils.spawn import find_executable
from typing import NamedTuple
outdir = 'build'
@@ -2412,17 +2413,21 @@ def create_build_system(args):
generate_compdb('compile_commands.json', ninja, args.buildfile, selected_modes)
class BuildType(NamedTuple):
build_by_default: bool
def configure_using_cmake(args):
# all supported build modes, and if they are built by default if selected
build_by_default = {'debug': True,
'release': True,
'dev': True,
'sanitize': False,
'coverage': False}
selected_modes = args.selected_modes or build_by_default.keys()
build_modes = {'debug': BuildType(True),
'release': BuildType(True),
'dev': BuildType(True),
'sanitize': BuildType(False),
'coverage': BuildType(False)}
selected_modes = args.selected_modes or build_modes.keys()
selected_configs = ';'.join(mode.capitalize() for mode in selected_modes)
default_configs = ';'.join(mode.capitalize() for mode in selected_modes
if build_by_default[mode])
if build_modes[mode].build_by_default)
settings = {
'CMAKE_CONFIGURATION_TYPES': selected_configs,