From 7b431748a8df87f57e78b3fcb1d113f50209a039 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Thu, 16 Feb 2023 10:58:27 +0800 Subject: [PATCH] build: cmake: extract idl library out Signed-off-by: Kefu Chai --- CMakeLists.txt | 58 ++------------------------------ alternator/CMakeLists.txt | 1 + api/CMakeLists.txt | 70 +++++++++++++++++++++++++++++++++++++++ cql3/CMakeLists.txt | 5 +-- idl/CMakeLists.txt | 3 +- 5 files changed, 78 insertions(+), 59 deletions(-) create mode 100644 api/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 1511bcae8b..3b1984844f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -77,64 +77,8 @@ seastar_generate_ragel( IN_FILE "${CMAKE_SOURCE_DIR}/redis/protocol_parser.rl" OUT_FILE ${scylla_gen_build_dir}/redis/protocol_parser.hh) -# Generate C++ sources from Swagger definitions -set(swagger_files - api/api-doc/cache_service.json - api/api-doc/collectd.json - api/api-doc/column_family.json - api/api-doc/commitlog.json - api/api-doc/compaction_manager.json - api/api-doc/config.json - api/api-doc/endpoint_snitch_info.json - api/api-doc/error_injection.json - api/api-doc/failure_detector.json - api/api-doc/gossiper.json - api/api-doc/hinted_handoff.json - api/api-doc/lsa.json - api/api-doc/messaging_service.json - api/api-doc/storage_proxy.json - api/api-doc/storage_service.json - api/api-doc/stream_manager.json - api/api-doc/system.json - api/api-doc/task_manager.json - api/api-doc/task_manager_test.json - api/api-doc/utils.json) - -set(swagger_gen_files) - -foreach(f ${swagger_files}) - get_filename_component(fname "${f}" NAME_WE) - get_filename_component(dir "${f}" DIRECTORY) - seastar_generate_swagger( - TARGET scylla_swagger_gen_${fname} - VAR scylla_swagger_gen_${fname}_files - IN_FILE "${CMAKE_SOURCE_DIR}/${f}" - OUT_DIR "${scylla_gen_build_dir}/${dir}") - list(APPEND swagger_gen_files "${scylla_swagger_gen_${fname}_files}") -endforeach() - set(scylla_sources absl-flat_hash_map.cc - api/api.cc - api/cache_service.cc - api/collectd.cc - api/column_family.cc - api/commitlog.cc - api/compaction_manager.cc - api/config.cc - api/endpoint_snitch.cc - api/error_injection.cc - api/failure_detector.cc - api/gossiper.cc - api/hinted_handoff.cc - api/lsa.cc - api/messaging_service.cc - api/storage_proxy.cc - api/storage_service.cc - api/stream_manager.cc - api/system.cc - api/task_manager.cc - api/task_manager_test.cc auth/allow_all_authenticator.cc auth/allow_all_authorizer.cc auth/authenticated_user.cc @@ -423,6 +367,7 @@ set(scylla_gen_sources "${scylla_ragel_gen_protocol_parser_file}" "${swagger_gen_files}") +add_subdirectory(api) add_subdirectory(alternator) add_subdirectory(cql3) add_subdirectory(idl) @@ -433,6 +378,7 @@ add_executable(scylla ${scylla_gen_sources}) target_link_libraries(scylla PRIVATE + api alternator cql3 idl diff --git a/alternator/CMakeLists.txt b/alternator/CMakeLists.txt index 8a1af4a2f4..91050d4b36 100644 --- a/alternator/CMakeLists.txt +++ b/alternator/CMakeLists.txt @@ -22,5 +22,6 @@ target_include_directories(alternator ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}) target_link_libraries(alternator + idl Seastar::seastar xxHash::xxhash) diff --git a/api/CMakeLists.txt b/api/CMakeLists.txt new file mode 100644 index 0000000000..c248685bc7 --- /dev/null +++ b/api/CMakeLists.txt @@ -0,0 +1,70 @@ +# Generate C++ sources from Swagger definitions +set(swagger_files + api-doc/authorization_cache.json + api-doc/cache_service.json + api-doc/collectd.json + api-doc/column_family.json + api-doc/commitlog.json + api-doc/compaction_manager.json + api-doc/config.json + api-doc/endpoint_snitch_info.json + api-doc/error_injection.json + api-doc/failure_detector.json + api-doc/gossiper.json + api-doc/hinted_handoff.json + api-doc/lsa.json + api-doc/messaging_service.json + api-doc/storage_proxy.json + api-doc/storage_service.json + api-doc/stream_manager.json + api-doc/system.json + api-doc/task_manager.json + api-doc/task_manager_test.json + api-doc/utils.json) + +foreach(f ${swagger_files}) + get_filename_component(fname "${f}" NAME_WE) + get_filename_component(dir "${f}" DIRECTORY) + seastar_generate_swagger( + TARGET scylla_swagger_gen_${fname} + VAR scylla_swagger_gen_${fname}_files + IN_FILE "${CMAKE_CURRENT_SOURCE_DIR}/${f}" + OUT_DIR "${scylla_gen_build_dir}/api/${dir}") + list(APPEND swagger_gen_files "${scylla_swagger_gen_${fname}_files}") +endforeach() + +add_library(api) +target_sources(api + PRIVATE + api.cc + cache_service.cc + collectd.cc + column_family.cc + commitlog.cc + compaction_manager.cc + config.cc + endpoint_snitch.cc + error_injection.cc + authorization_cache.cc + failure_detector.cc + gossiper.cc + hinted_handoff.cc + lsa.cc + messaging_service.cc + storage_proxy.cc + storage_service.cc + stream_manager.cc + system.cc + task_manager.cc + task_manager_test.cc + ${swagger_gen_files}) +target_include_directories(api + PUBLIC + ${CMAKE_SOURCE_DIR} + ${scylla_gen_build_dir}) +target_link_libraries(api + idl + wasmtime_bindings + + Seastar::seastar + xxHash::xxhash) diff --git a/cql3/CMakeLists.txt b/cql3/CMakeLists.txt index f6321def86..ef16a69db5 100644 --- a/cql3/CMakeLists.txt +++ b/cql3/CMakeLists.txt @@ -109,5 +109,6 @@ target_include_directories(cql3 ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}) target_link_libraries(cql3 - Seastar::seastar - xxHash::xxhash) + idl + Seastar::seastar + xxHash::xxhash) diff --git a/idl/CMakeLists.txt b/idl/CMakeLists.txt index 5d0f38ca4b..64fff80198 100644 --- a/idl/CMakeLists.txt +++ b/idl/CMakeLists.txt @@ -62,6 +62,7 @@ set(idl_headers foreach(idl_header ${idl_headers}) compile_idl(${idl_header} + OUT_DIR "${scylla_gen_build_dir}/idl" SOURCES srcs) list(APPEND idl_sources ${srcs}) endforeach() @@ -72,4 +73,4 @@ add_library(idl INTERFACE) add_dependencies(idl idl-sources) target_include_directories(idl INTERFACE - ${CMAKE_BINARY_DIR}) + ${scylla_gen_build_dir})