From 62951dbef64e4b0cb6a4892c13c8f86ee9bbc747 Mon Sep 17 00:00:00 2001 From: ClausKlein Date: Sun, 1 Dec 2024 12:38:43 +0100 Subject: [PATCH] Fix, format, and move modules tests together --- asio/CMakeLists.txt | 2 +- asio/cmake/dev-mode.cmake | 2 +- asio/cmake/lint-targets.cmake | 2 +- asio/module/asio.cppm | 30 +++++++++++-------- .../examples => module/tests}/CMakeLists.txt | 9 +++--- asio/module/tests/main.hpp | 2 +- .../cpp20/operations/callback_wrapper.cpp | 21 ++----------- asio/src/tests/CMakeLists.txt | 4 +-- 8 files changed, 30 insertions(+), 42 deletions(-) rename asio/{src/examples => module/tests}/CMakeLists.txt (85%) diff --git a/asio/CMakeLists.txt b/asio/CMakeLists.txt index 779ea42555..42166b1150 100644 --- a/asio/CMakeLists.txt +++ b/asio/CMakeLists.txt @@ -98,7 +98,7 @@ if(NOT CMAKE_SKIP_INSTALL_RULES) include(cmake/install-rules.cmake) configure_file(asio.pc.cmake asio.pc) install(FILES ${PROJECT_BINARY_DIR}/asio.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) - install(DIRECTORY module DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/asio) + install(FILES module/asio.cppm DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/asio/module) endif() # ---- Developer mode ---- diff --git a/asio/cmake/dev-mode.cmake b/asio/cmake/dev-mode.cmake index d8e86da20a..39fed3560d 100644 --- a/asio/cmake/dev-mode.cmake +++ b/asio/cmake/dev-mode.cmake @@ -5,7 +5,7 @@ if(ASIO_BUILD_TESTING) enable_testing() add_subdirectory(src/tests) - add_subdirectory(src/examples) + add_subdirectory(module/tests) endif() option(ASIO_BUILD_MCSS_DOCS "Build documentation using Doxygen and m.css" OFF) diff --git a/asio/cmake/lint-targets.cmake b/asio/cmake/lint-targets.cmake index cf79d3b032..15270d9227 100644 --- a/asio/cmake/lint-targets.cmake +++ b/asio/cmake/lint-targets.cmake @@ -1,4 +1,4 @@ -set(ACIO_FORMAT_PATTERNS *.json # src/*.cpp src/*.hpp include/*.hpp tests/*.cpp tests/*.hpp +set(ACIO_FORMAT_PATTERNS *.json *.cppm # src/*.cpp src/*.hpp include/*.hpp tests/*.cpp tests/*.hpp CACHE STRING "; separated patterns relative to the project source dir to format" ) diff --git a/asio/module/asio.cppm b/asio/module/asio.cppm index 0a7c2ccbc4..df6d9fb1cd 100644 --- a/asio/module/asio.cppm +++ b/asio/module/asio.cppm @@ -5,7 +5,8 @@ module; export module asio; -namespace asio { +namespace asio +{ export using asio::io_context; export using asio::post; export using asio::any_completion_executor; @@ -37,31 +38,36 @@ export using asio::buffer; export using asio::socket_base; export using asio::co_spawn; -namespace error { +namespace error +{ export using asio::error::make_error_code; -} +} // namespace error -namespace this_coro { +namespace this_coro +{ export using asio::this_coro::executor; -} +} // namespace this_coro -namespace ip { +namespace ip +{ export using asio::ip::tcp; export using asio::ip::address; export using asio::ip::address_v4; -} +} // namespace ip -namespace ssl { +namespace ssl +{ export using asio::ssl::context; export using asio::ssl::context_base; export using asio::ssl::host_name_verification; export using asio::ssl::stream_base; export using asio::ssl::verify_context; export using asio::ssl::stream; -namespace error { +namespace error +{ export using asio::ssl::error::stream_errors; export using asio::ssl::error::make_error_code; -} -} +} // namespace error +} // namespace ssl -} +} // namespace asio diff --git a/asio/src/examples/CMakeLists.txt b/asio/module/tests/CMakeLists.txt similarity index 85% rename from asio/src/examples/CMakeLists.txt rename to asio/module/tests/CMakeLists.txt index 5fadf05088..fb102e6e3b 100644 --- a/asio/src/examples/CMakeLists.txt +++ b/asio/module/tests/CMakeLists.txt @@ -1,10 +1,10 @@ cmake_minimum_required(VERSION 3.25...3.31) -project(asio_examples LANGUAGES CXX) +project(asio_moddule_examples LANGUAGES CXX) if(PROJECT_IS_TOP_LEVEL) # Find the Asio package containing the function to build the module - find_package(asio 1.32.0.1 EXACT REQUIRED HINT ../stagedir/lib) + find_package(asio 1.32.0.1 EXACT REQUIRED HINT ../../stagedir/lib) enable_testing() # Use modules? @@ -35,15 +35,14 @@ if(PROJECT_IS_TOP_LEVEL) endif() -# set(ALL_EXAMPLES cpp20/operations/callback_wrapper.cpp) -# list(APPEND ALL_EXAMPLES ../../module/tests/main.cpp) +# list(APPEND ALL_EXAMPLES module/tests/main.cpp) set(ALL_EXAMPLES main) message(STATUS "Examples to be built: ${ALL_EXAMPLES}") foreach(example ${ALL_EXAMPLES}) add_executable(${example}) - target_sources(${example} PRIVATE ../../module/tests/${example}.cpp) + target_sources(${example} PRIVATE ${example}.cpp) if(USE_MODULES) target_link_libraries(${example} asio_module) target_compile_definitions(${example} PUBLIC USE_MODULES) diff --git a/asio/module/tests/main.hpp b/asio/module/tests/main.hpp index badc8a39fa..db1d26649d 100644 --- a/asio/module/tests/main.hpp +++ b/asio/module/tests/main.hpp @@ -84,7 +84,7 @@ inline net::awaitable do_listen() { tcp::socket socket{ex}; co_await acceptor.async_accept(socket, net::deferred); - net::co_spawn(ex, [s = std::move(socket)] mutable { + net::co_spawn(ex, [s = std::move(socket)]() mutable { return do_session(std::move(s)); }, net::detached); } diff --git a/asio/src/examples/cpp20/operations/callback_wrapper.cpp b/asio/src/examples/cpp20/operations/callback_wrapper.cpp index 52ca9733b2..f8f37b4894 100644 --- a/asio/src/examples/cpp20/operations/callback_wrapper.cpp +++ b/asio/src/examples/cpp20/operations/callback_wrapper.cpp @@ -8,25 +8,8 @@ // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // -#ifdef USE_MODULES -# ifdef HAS_STDLIB_MODULES -import std; -import std.compat; -# else -# include -# include -# include -# include -# include -# include -# include -# include -# endif -import asio; -# else -# include -# include -# endif +#include +#include //------------------------------------------------------------------------------ diff --git a/asio/src/tests/CMakeLists.txt b/asio/src/tests/CMakeLists.txt index 6b1aa9e0e1..cd3cc58826 100644 --- a/asio/src/tests/CMakeLists.txt +++ b/asio/src/tests/CMakeLists.txt @@ -9,7 +9,7 @@ include(../../cmake/windows-set-path.cmake OPTIONAL) # ---- Dependencies ---- if(PROJECT_IS_TOP_LEVEL) - find_package(asio 1.32.0 EXACT REQUIRED) + find_package(asio 1.32.0.1 EXACT REQUIRED) enable_testing() endif() @@ -35,7 +35,7 @@ if(NOT PROJECT_IS_TOP_LEVEL) add_test( NAME find-package-test COMMAND ${CMAKE_CTEST_COMMAND} --verbose --output-on-failure -C Debug --build-and-test - "${CMAKE_SOURCE_DIR}/src/examples" "${CMAKE_CURRENT_BINARY_DIR}/find-package-test" --build-generator + "${CMAKE_SOURCE_DIR}/module/tests" "${CMAKE_CURRENT_BINARY_DIR}/find-package-test" --build-generator ${CMAKE_GENERATOR} --build-makeprogram ${CMAKE_MAKE_PROGRAM} --build-options "-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}" "-DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}" "-DCMAKE_BUILD_TYPE=Debug" "-DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}"