From 79943e051631ec1602c3d2636de37dc7716257fd Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Sun, 24 Dec 2023 11:59:22 +0800 Subject: [PATCH 1/2] build: cmake: define scylla_build_mode scylla uses build modes like "debug" and "release" to differentiate different build modes. while we intend to use the typical build configurations / build types used by CMake like "Debug" and "RelWithDebInfo" for naming CMAKE_CONFIGURATION_TYPES and CMAKE_BUILD_TYPE. the former is used for naming the build directory and for the preprocess macro named "SCYLLA_BUILD_MODE". `test.py` and scylladb's CI are designed based on the naming of build directory. in which, `test.py` lists the build modes using the dedicated build target named "list_modes", which is added by `configure.py`. so, in this change, to prepare for adding the target, "scylla_build_mode" is defined, so we can reuse it in a following-up change. Signed-off-by: Kefu Chai --- cmake/mode.Coverage.cmake | 3 ++- cmake/mode.Debug.cmake | 3 ++- cmake/mode.Dev.cmake | 3 ++- cmake/mode.RelWithDebInfo.cmake | 3 ++- cmake/mode.Sanitize.cmake | 3 ++- 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/cmake/mode.Coverage.cmake b/cmake/mode.Coverage.cmake index b8431a0e28..d4f09c5a88 100644 --- a/cmake/mode.Coverage.cmake +++ b/cmake/mode.Coverage.cmake @@ -7,8 +7,9 @@ update_cxx_flags(CMAKE_CXX_FLAGS_COVERAGE WITH_DEBUG_INFO OPTIMIZATION_LEVEL "g") +set(scylla_build_mode "coverage") set(Seastar_DEFINITIONS_COVERAGE - SCYLLA_BUILD_MODE=coverage + SCYLLA_BUILD_MODE=${scylla_build_mode} DEBUG SANITIZE DEBUG_LSA_SANITIZER diff --git a/cmake/mode.Debug.cmake b/cmake/mode.Debug.cmake index cba6258dbb..8221e9a0f4 100644 --- a/cmake/mode.Debug.cmake +++ b/cmake/mode.Debug.cmake @@ -9,8 +9,9 @@ update_cxx_flags(CMAKE_CXX_FLAGS_DEBUG WITH_DEBUG_INFO OPTIMIZATION_LEVEL ${OptimizationLevel}) +set(scylla_build_mode "debug") set(Seastar_DEFINITIONS_DEBUG - SCYLLA_BUILD_MODE=debug + SCYLLA_BUILD_MODE=${scylla_build_mode} DEBUG SANITIZE DEBUG_LSA_SANITIZER diff --git a/cmake/mode.Dev.cmake b/cmake/mode.Dev.cmake index 80c8d099fe..13cdba4826 100644 --- a/cmake/mode.Dev.cmake +++ b/cmake/mode.Dev.cmake @@ -6,8 +6,9 @@ set(CMAKE_CXX_FLAGS_DEV update_cxx_flags(CMAKE_CXX_FLAGS_DEV OPTIMIZATION_LEVEL "2") +set(scylla_build_mode "dev") set(Seastar_DEFINITIONS_DEV - SCYLLA_BUILD_MODE=dev + SCYLLA_BUILD_MODE=${scylla_build_mode} DEVEL SEASTAR_ENABLE_ALLOC_FAILURE_INJECTION SCYLLA_ENABLE_ERROR_INJECTION) diff --git a/cmake/mode.RelWithDebInfo.cmake b/cmake/mode.RelWithDebInfo.cmake index d4a3a5c63e..4d22233618 100644 --- a/cmake/mode.RelWithDebInfo.cmake +++ b/cmake/mode.RelWithDebInfo.cmake @@ -7,8 +7,9 @@ update_cxx_flags(CMAKE_CXX_FLAGS_RELWITHDEBINFO WITH_DEBUG_INFO OPTIMIZATION_LEVEL "3") +set(scylla_build_mode "release") add_compile_definitions( - $<$:SCYLLA_BUILD_MODE=release>) + $<$:SCYLLA_BUILD_MODE=${scylla_build_mode}>) if(CMAKE_SYSTEM_PROCESSOR MATCHES "arm64|aarch64") set(clang_inline_threshold 300) diff --git a/cmake/mode.Sanitize.cmake b/cmake/mode.Sanitize.cmake index e3c64b1863..9b6f9da606 100644 --- a/cmake/mode.Sanitize.cmake +++ b/cmake/mode.Sanitize.cmake @@ -7,8 +7,9 @@ update_cxx_flags(CMAKE_CXX_FLAGS_SANITIZE WITH_DEBUG_INFO OPTIMIZATION_LEVEL "s") +set(scylla_build_mode "sanitize") set(Seastar_DEFINITIONS_SANITIZE - SCYLLA_BUILD_MODE=sanitize + SCYLLA_BUILD_MODE=${scylla_build_mode} DEBUG SANITIZE DEBUG_LSA_SANITIZER From 2bec6751d3884b0ad7ddc58a9a123cdbd12efa95 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Sun, 24 Dec 2023 00:46:42 +0800 Subject: [PATCH 2/2] build: cmake: add "mode_list" target scylla uses build modes like "debug" and "release" to differentiate different build modes. while we intend to use the typical build configurations / build types used by CMake like "Debug" and "RelWithDebInfo" for naming CMAKE_CONFIGURATION_TYPES and CMAKE_BUILD_TYPE. the former is used for naming the build directory and for the preprocess macro named "SCYLLA_BUILD_MODE". `test.py` and scylladb's CI are designed based on the naming of build directory. in which, `test.py` lists the build modes using the dedicated build target named `list_modes`, which is added by `configure.py`. so, in this change, the target is added to CMake as well. the variables of "scylla_build_mode" defined by the per-mode configuration are collected and printed by the `list_modes`. because, by default, CMake generates a target for each build configuration when a multi-config generator is used. but we only want to print the build mode for a single time when "list_modes" is built. so a "BYPRODUCTS" is deliberately added for the target, and the patch of this "BYPRODUCTS" is named without the "$" it its path. Signed-off-by: Kefu Chai --- CMakeLists.txt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1adae8016c..05aab03a55 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,9 +28,18 @@ include(mode.common) if(CMAKE_CONFIGURATION_TYPES) foreach(config ${CMAKE_CONFIGURATION_TYPES}) include(mode.${config}) + list(APPEND scylla_build_modes ${scylla_build_mode}) endforeach() + add_custom_target(mode_list + COMMAND ${CMAKE_COMMAND} -E echo "$" + COMMENT "List configured modes" + BYPRODUCTS mode-list.phony.stamp + COMMAND_EXPAND_LISTS) else() include(mode.${CMAKE_BUILD_TYPE}) + add_custom_target(mode_list + ${CMAKE_COMMAND} -E echo "${scylla_build_mode}" + COMMENT "List configured modes") endif() add_compile_definitions(