From a19a0a7342485080ca1ead005d3f054a0225bbb4 Mon Sep 17 00:00:00 2001 From: Ben Deane Date: Sun, 8 Dec 2024 20:39:48 -0700 Subject: [PATCH 1/4] :art: Split `sc` into a separate library --- CMakeLists.txt | 42 ++++++++++++++++++++++------------- test/CMakeLists.txt | 7 ++++-- test/cib/CMakeLists.txt | 9 +++++++- test/flow/CMakeLists.txt | 11 ++++++++- test/interrupt/CMakeLists.txt | 5 ++++- test/log/CMakeLists.txt | 10 ++++++++- test/lookup/CMakeLists.txt | 9 +++++++- test/match/CMakeLists.txt | 5 ++++- test/msg/CMakeLists.txt | 5 ++++- test/sc/CMakeLists.txt | 2 +- test/seq/CMakeLists.txt | 2 +- 11 files changed, 80 insertions(+), 27 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7e9a4fec..5c42bdd0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,10 +28,34 @@ add_versioned_package("gh:intel/cpp-baremetal-concurrency#7c5b26c") add_versioned_package("gh:intel/cpp-std-extensions#2512bcf") add_versioned_package("gh:intel/cpp-baremetal-senders-and-receivers#73d95bc") +add_library(cib_sc INTERFACE) +target_compile_features(cib_sc INTERFACE cxx_std_20) +target_link_libraries_system(cib_sc INTERFACE fmt::fmt-header-only stdx) + +target_sources( + cib_sc + INTERFACE FILE_SET + sc + TYPE + HEADERS + BASE_DIRS + include + FILES + include/sc/format.hpp + include/sc/fwd.hpp + include/sc/lazy_string_format.hpp + include/sc/string_constant.hpp) + add_library(cib INTERFACE) target_compile_features(cib INTERFACE cxx_std_20) -target_link_libraries_system(cib INTERFACE async concurrency - fmt::fmt-header-only stdx) +target_link_libraries_system( + cib + INTERFACE + async + cib_sc + concurrency + fmt::fmt-header-only + stdx) target_sources( cib @@ -179,20 +203,6 @@ target_sources( include/msg/send.hpp include/msg/service.hpp) -target_sources( - cib - INTERFACE FILE_SET - sc - TYPE - HEADERS - BASE_DIRS - include - FILES - include/sc/format.hpp - include/sc/fwd.hpp - include/sc/lazy_string_format.hpp - include/sc/string_constant.hpp) - target_sources( cib INTERFACE FILE_SET diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 7d61e8d4..d741c2d4 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,6 +1,9 @@ function(add_tests) + set(multiValueArgs FILES LIBRARIES) + cmake_parse_arguments(AT "" "" "${multiValueArgs}" ${ARGN}) + get_filename_component(prefix ${CMAKE_CURRENT_SOURCE_DIR} NAME) - foreach(name ${ARGN}) + foreach(name ${AT_FILES}) string(REPLACE "/" "_" test ${name}) add_unit_test( "${prefix}_${test}_test" @@ -9,7 +12,7 @@ function(add_tests) "${name}.cpp" LIBRARIES warnings - cib) + ${AT_LIBRARIES}) endforeach() endfunction() diff --git a/test/cib/CMakeLists.txt b/test/cib/CMakeLists.txt index 9a17476c..4bbbde99 100644 --- a/test/cib/CMakeLists.txt +++ b/test/cib/CMakeLists.txt @@ -1 +1,8 @@ -add_tests(builder_meta callback nexus readme_hello_world) +add_tests( + FILES + builder_meta + callback + nexus + readme_hello_world + LIBRARIES + cib) diff --git a/test/flow/CMakeLists.txt b/test/flow/CMakeLists.txt index 03066925..40da6706 100644 --- a/test/flow/CMakeLists.txt +++ b/test/flow/CMakeLists.txt @@ -8,6 +8,15 @@ add_unit_test( warnings cib) -add_tests(flow graph graph_builder logging log_levels custom_log_levels) +add_tests( + FILES + flow + graph + graph_builder + logging + log_levels + custom_log_levels + LIBRARIES + cib) add_subdirectory(fail) diff --git a/test/interrupt/CMakeLists.txt b/test/interrupt/CMakeLists.txt index 9c7c5552..c2056445 100644 --- a/test/interrupt/CMakeLists.txt +++ b/test/interrupt/CMakeLists.txt @@ -1,8 +1,11 @@ add_tests( + FILES dynamic_controller irq_impl manager shared_irq_impl shared_sub_irq_impl sub_irq_impl - policies) + policies + LIBRARIES + cib) diff --git a/test/log/CMakeLists.txt b/test/log/CMakeLists.txt index f7ede76d..df8a11aa 100644 --- a/test/log/CMakeLists.txt +++ b/test/log/CMakeLists.txt @@ -1,4 +1,12 @@ -add_tests(fmt_logger log mipi_encoder mipi_logger module_id) +add_tests( + FILES + fmt_logger + log + mipi_encoder + mipi_logger + module_id + LIBRARIES + cib) add_library(catalog1_lib STATIC catalog1_lib.cpp) add_library(catalog2_lib OBJECT catalog2a_lib.cpp catalog2b_lib.cpp) diff --git a/test/lookup/CMakeLists.txt b/test/lookup/CMakeLists.txt index c24f1db1..611d808f 100644 --- a/test/lookup/CMakeLists.txt +++ b/test/lookup/CMakeLists.txt @@ -1,4 +1,11 @@ -add_tests(input linear_search pseudo_pext_lookup lookup) +add_tests( + FILES + input + linear_search + pseudo_pext_lookup + lookup + LIBRARIES + cib) add_versioned_package("gh:boost-ext/mph#v1.0.8") add_versioned_package("gh:serge-sans-paille/frozen#292a811") diff --git a/test/match/CMakeLists.txt b/test/match/CMakeLists.txt index 0adfcb23..97008e22 100644 --- a/test/match/CMakeLists.txt +++ b/test/match/CMakeLists.txt @@ -1,4 +1,5 @@ add_tests( + FILES and constant equivalence @@ -10,4 +11,6 @@ add_tests( simplify_custom simplify_not simplify_or - sum_of_products) + sum_of_products + LIBRARIES + cib) diff --git a/test/msg/CMakeLists.txt b/test/msg/CMakeLists.txt index ae4e1d33..e8b28249 100644 --- a/test/msg/CMakeLists.txt +++ b/test/msg/CMakeLists.txt @@ -1,4 +1,5 @@ add_tests( + FILES callback field_extract field_insert @@ -9,7 +10,9 @@ add_tests( indexed_callback indexed_handler message - send) + send + LIBRARIES + cib) add_subdirectory(fail) diff --git a/test/sc/CMakeLists.txt b/test/sc/CMakeLists.txt index 8b7236f2..aefed6a0 100644 --- a/test/sc/CMakeLists.txt +++ b/test/sc/CMakeLists.txt @@ -1 +1 @@ -add_tests(format string_constant) +add_tests(FILES format string_constant LIBRARIES cib_sc) diff --git a/test/seq/CMakeLists.txt b/test/seq/CMakeLists.txt index 370f4e26..a40433d1 100644 --- a/test/seq/CMakeLists.txt +++ b/test/seq/CMakeLists.txt @@ -1 +1 @@ -add_tests(sequencer) +add_tests(FILES sequencer LIBRARIES cib) From 0b6450cd9463bffaeeb999de22b4c0e07d20a4e5 Mon Sep 17 00:00:00 2001 From: Ben Deane Date: Sun, 8 Dec 2024 20:49:00 -0700 Subject: [PATCH 2/4] :art: Move `loggable` concept to `sc_like` --- include/log/log.hpp | 5 ----- include/match/concepts.hpp | 6 +++--- include/sc/fwd.hpp | 5 +++++ test/sc/format.cpp | 6 ++++++ test/sc/string_constant.cpp | 5 +++++ 5 files changed, 19 insertions(+), 8 deletions(-) diff --git a/include/log/log.hpp b/include/log/log.hpp index 3933d063..4c736e03 100644 --- a/include/log/log.hpp +++ b/include/log/log.hpp @@ -32,11 +32,6 @@ struct config { template inline auto config = null::config{}; -template -concept loggable = requires(T const &t) { - t.apply([](StringType, auto const &...) {}); -}; - struct default_flavor_t; template diff --git a/include/match/concepts.hpp b/include/match/concepts.hpp index 3ad8dfad..250f2e76 100644 --- a/include/match/concepts.hpp +++ b/include/match/concepts.hpp @@ -1,6 +1,6 @@ #pragma once -#include +#include #include #include @@ -12,7 +12,7 @@ concept matcher = requires { typename std::remove_cvref_t::is_matcher; }; template concept matcher_for = matcher and requires(T const &t, Event const &e) { { t(e) } -> std::convertible_to; - { t.describe() } -> logging::loggable; - { t.describe_match(e) } -> logging::loggable; + { t.describe() } -> sc::sc_like; + { t.describe_match(e) } -> sc::sc_like; }; } // namespace match diff --git a/include/sc/fwd.hpp b/include/sc/fwd.hpp index 94546c22..5d0b3d6e 100644 --- a/include/sc/fwd.hpp +++ b/include/sc/fwd.hpp @@ -37,5 +37,10 @@ template CONSTEVAL auto operator""_sc() { return stdx::ct_string_to_type(); } } // namespace literals + +template +concept sc_like = requires(T const &t) { + t.apply([](StringType, auto const &...) {}); +}; } // namespace sc using sc::literals::operator""_sc; diff --git a/test/sc/format.cpp b/test/sc/format.cpp index 9d5ac9cd..f0381ece 100644 --- a/test/sc/format.cpp +++ b/test/sc/format.cpp @@ -120,3 +120,9 @@ TEST_CASE("format a formatted string", "[sc::format]") { (sc::lazy_string_format{"a1{}2{}3b4{}5{}6c"_sc, stdx::make_tuple(10, 20, 30, 40)})); } + +TEST_CASE("lazy_string_format is sc_like", "[sc::format]") { + [[maybe_unused]] auto lsf = + sc::lazy_string_format{"{}"_sc, stdx::make_tuple(0)}; + static_assert(sc::sc_like); +} diff --git a/test/sc/string_constant.cpp b/test/sc/string_constant.cpp index 2f8b892e..24555d76 100644 --- a/test/sc/string_constant.cpp +++ b/test/sc/string_constant.cpp @@ -33,3 +33,8 @@ TEST_CASE("join", "[sc::string_constant]") { static_assert(""_sc + "Luke"_sc == "Luke"_sc); static_assert("Computer"_sc + ""_sc == "Computer"_sc); } + +TEST_CASE("string_constant is sc_like", "[sc::string_constant]") { + [[maybe_unused]] auto hi = "Hello, cruel world!"_sc; + static_assert(sc::sc_like); +} From 15738051fae66c7bded266cbedb1227c510853a2 Mon Sep 17 00:00:00 2001 From: Ben Deane Date: Sun, 8 Dec 2024 20:51:42 -0700 Subject: [PATCH 3/4] :art: Split `match` into a separate library --- CMakeLists.txt | 51 +++++++++++++---------- include/msg/detail/separate_sum_terms.hpp | 1 + test/match/CMakeLists.txt | 2 +- 3 files changed, 30 insertions(+), 24 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5c42bdd0..c2c89ca8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,12 +46,40 @@ target_sources( include/sc/lazy_string_format.hpp include/sc/string_constant.hpp) +add_library(cib_match INTERFACE) +target_compile_features(cib_match INTERFACE cxx_std_20) +target_link_libraries_system(cib_match INTERFACE cib_sc stdx) + +target_sources( + cib_match + INTERFACE FILE_SET + match + TYPE + HEADERS + BASE_DIRS + include + FILES + include/match/and.hpp + include/match/bin_op.hpp + include/match/concepts.hpp + include/match/constant.hpp + include/match/cost.hpp + include/match/implies.hpp + include/match/negate.hpp + include/match/not.hpp + include/match/ops.hpp + include/match/or.hpp + include/match/predicate.hpp + include/match/simplify.hpp + include/match/sum_of_products.hpp) + add_library(cib INTERFACE) target_compile_features(cib INTERFACE cxx_std_20) target_link_libraries_system( cib INTERFACE async + cib_match cib_sc concurrency fmt::fmt-header-only @@ -155,29 +183,6 @@ target_sources( include/lookup/strategies.hpp include/lookup/strategy_failed.hpp) -target_sources( - cib - INTERFACE FILE_SET - match - TYPE - HEADERS - BASE_DIRS - include - FILES - include/match/and.hpp - include/match/bin_op.hpp - include/match/concepts.hpp - include/match/constant.hpp - include/match/cost.hpp - include/match/implies.hpp - include/match/negate.hpp - include/match/not.hpp - include/match/ops.hpp - include/match/or.hpp - include/match/predicate.hpp - include/match/simplify.hpp - include/match/sum_of_products.hpp) - target_sources( cib INTERFACE FILE_SET diff --git a/include/msg/detail/separate_sum_terms.hpp b/include/msg/detail/separate_sum_terms.hpp index 850401b3..87fcff7d 100644 --- a/include/msg/detail/separate_sum_terms.hpp +++ b/include/msg/detail/separate_sum_terms.hpp @@ -7,6 +7,7 @@ #include #include +#include #include #include diff --git a/test/match/CMakeLists.txt b/test/match/CMakeLists.txt index 97008e22..ada4b108 100644 --- a/test/match/CMakeLists.txt +++ b/test/match/CMakeLists.txt @@ -13,4 +13,4 @@ add_tests( simplify_or sum_of_products LIBRARIES - cib) + cib_match) From 448122d47b4698cb8ac3348dae486a81dde0ea3c Mon Sep 17 00:00:00 2001 From: Ben Deane Date: Sun, 8 Dec 2024 20:58:25 -0700 Subject: [PATCH 4/4] :art: Split `interrupt` into a separate library --- CMakeLists.txt | 44 +++++++++++++++++++++-------------- test/interrupt/CMakeLists.txt | 2 +- 2 files changed, 27 insertions(+), 19 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c2c89ca8..5a9c7a30 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -73,12 +73,35 @@ target_sources( include/match/simplify.hpp include/match/sum_of_products.hpp) +add_library(cib_interrupt INTERFACE) +target_compile_features(cib_interrupt INTERFACE cxx_std_20) +target_link_libraries_system(cib_interrupt INTERFACE cib_sc concurrency stdx) + +target_sources( + cib_interrupt + INTERFACE FILE_SET + interrupt + TYPE + HEADERS + BASE_DIRS + include + FILES + include/interrupt/concepts.hpp + include/interrupt/config.hpp + include/interrupt/dynamic_controller.hpp + include/interrupt/fwd.hpp + include/interrupt/hal.hpp + include/interrupt/impl.hpp + include/interrupt/manager.hpp + include/interrupt/policies.hpp) + add_library(cib INTERFACE) target_compile_features(cib INTERFACE cxx_std_20) target_link_libraries_system( cib INTERFACE async + cib_interrupt cib_match cib_sc concurrency @@ -132,24 +155,6 @@ target_sources( include/flow/run.hpp include/flow/step.hpp) -target_sources( - cib - INTERFACE FILE_SET - interrupt - TYPE - HEADERS - BASE_DIRS - include - FILES - include/interrupt/concepts.hpp - include/interrupt/config.hpp - include/interrupt/dynamic_controller.hpp - include/interrupt/fwd.hpp - include/interrupt/hal.hpp - include/interrupt/impl.hpp - include/interrupt/manager.hpp - include/interrupt/policies.hpp) - target_sources( cib INTERFACE FILE_SET @@ -224,6 +229,9 @@ target_sources( if(PROJECT_IS_TOP_LEVEL) add_docs(docs) clang_tidy_interface(cib) + clang_tidy_interface(cib_interrupt) + clang_tidy_interface(cib_match) + clang_tidy_interface(cib_sc) # Enable functional and performance test suites. add_subdirectory(test) diff --git a/test/interrupt/CMakeLists.txt b/test/interrupt/CMakeLists.txt index c2056445..e7862ebd 100644 --- a/test/interrupt/CMakeLists.txt +++ b/test/interrupt/CMakeLists.txt @@ -8,4 +8,4 @@ add_tests( sub_irq_impl policies LIBRARIES - cib) + cib_interrupt)