From 0b47a487731e7878959df6ef29d8ba6ad9c9adef Mon Sep 17 00:00:00 2001 From: Daniel Date: Sat, 7 Sep 2024 17:44:49 +0200 Subject: [PATCH 01/11] Create cmake-multi-platform.yml --- .github/workflows/cmake-multi-platform.yml | 75 ++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 .github/workflows/cmake-multi-platform.yml diff --git a/.github/workflows/cmake-multi-platform.yml b/.github/workflows/cmake-multi-platform.yml new file mode 100644 index 0000000..ec13000 --- /dev/null +++ b/.github/workflows/cmake-multi-platform.yml @@ -0,0 +1,75 @@ +# This starter workflow is for a CMake project running on multiple platforms. There is a different starter workflow if you just want a single platform. +# See: https://github.com/actions/starter-workflows/blob/main/ci/cmake-single-platform.yml +name: CMake on multiple platforms + +on: + push: + branches: [ "**" ] + pull_request: + branches: [ "**" ] + +jobs: + build: + runs-on: ${{ matrix.os }} + + strategy: + # Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable. + fail-fast: false + + # Set up a matrix to run the following 3 configurations: + # 1. + # 2. + # 3. + # + # To add more build types (Release, Debug, RelWithDebInfo, etc.) customize the build_type list. + matrix: + os: [ubuntu-latest, windows-latest] + build_type: [Release] + c_compiler: [gcc, clang, cl] + include: + - os: windows-latest + c_compiler: cl + cpp_compiler: cl + - os: ubuntu-latest + c_compiler: gcc + cpp_compiler: g++ + - os: ubuntu-latest + c_compiler: clang + cpp_compiler: clang++ + exclude: + - os: windows-latest + c_compiler: gcc + - os: windows-latest + c_compiler: clang + - os: ubuntu-latest + c_compiler: cl + + steps: + - uses: actions/checkout@v4 + + - name: Set reusable strings + # Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file. + id: strings + shell: bash + run: | + echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT" + + - name: Configure CMake + # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. + # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type + run: > + cmake -B ${{ steps.strings.outputs.build-output-dir }} + -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} + -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} + -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} + -S ${{ github.workspace }}/tests + + - name: Build + # Build your program with the given configuration. Note that --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator). + run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }} + + - name: Test + working-directory: ${{ steps.strings.outputs.build-output-dir }} + # Execute tests defined by the CMake configuration. Note that --build-config is needed because the default Windows generator is a multi-config generator (Visual Studio generator). + # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail + run: ctest --build-config ${{ matrix.build_type }} From 1017017e3b881cf3fb171d1155b6ce7618e59a60 Mon Sep 17 00:00:00 2001 From: Daniel Date: Sat, 7 Sep 2024 17:50:09 +0200 Subject: [PATCH 02/11] Do not use experimental C++17 `erase_if` --- src/observer/routing/SubjectRouter.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/observer/routing/SubjectRouter.cpp b/src/observer/routing/SubjectRouter.cpp index 4f3b831..c7f3eed 100644 --- a/src/observer/routing/SubjectRouter.cpp +++ b/src/observer/routing/SubjectRouter.cpp @@ -1,6 +1,5 @@ #include -#include #include #include @@ -43,8 +42,7 @@ void SubjectRouter::Node::shrink(RoutingLevelView levelView) { } // erase empty children - // C++20: std::erase_if - std::experimental::erase_if(m_children, [](auto &p) { + std::erase_if(m_children, [](auto &p) { return p.second.isEmpty(); }); } From 885980a230e8a303ebe6079ddb99a67d56278d8a Mon Sep 17 00:00:00 2001 From: Daniel Date: Sat, 7 Sep 2024 17:55:57 +0200 Subject: [PATCH 03/11] Update clang version --- .github/workflows/cmake-multi-platform.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cmake-multi-platform.yml b/.github/workflows/cmake-multi-platform.yml index ec13000..c8b825a 100644 --- a/.github/workflows/cmake-multi-platform.yml +++ b/.github/workflows/cmake-multi-platform.yml @@ -34,8 +34,8 @@ jobs: c_compiler: gcc cpp_compiler: g++ - os: ubuntu-latest - c_compiler: clang - cpp_compiler: clang++ + c_compiler: clang-18 + cpp_compiler: clang++-18 exclude: - os: windows-latest c_compiler: gcc From 001d3462d7ae7745611eb092a70a9013f8e41b85 Mon Sep 17 00:00:00 2001 From: Daniel Date: Sat, 7 Sep 2024 18:03:52 +0200 Subject: [PATCH 04/11] Use `ubuntu-24.04` instead of `ubuntu-latest` See more: https://github.com/actions/runner-images --- .github/workflows/cmake-multi-platform.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/cmake-multi-platform.yml b/.github/workflows/cmake-multi-platform.yml index c8b825a..380fc2c 100644 --- a/.github/workflows/cmake-multi-platform.yml +++ b/.github/workflows/cmake-multi-platform.yml @@ -23,25 +23,25 @@ jobs: # # To add more build types (Release, Debug, RelWithDebInfo, etc.) customize the build_type list. matrix: - os: [ubuntu-latest, windows-latest] + os: [ubuntu-24.04, windows-latest] build_type: [Release] c_compiler: [gcc, clang, cl] include: - os: windows-latest c_compiler: cl cpp_compiler: cl - - os: ubuntu-latest + - os: ubuntu-24.04 c_compiler: gcc cpp_compiler: g++ - - os: ubuntu-latest - c_compiler: clang-18 - cpp_compiler: clang++-18 + - os: ubuntu-24.04 + c_compiler: clang + cpp_compiler: clang++ exclude: - os: windows-latest c_compiler: gcc - os: windows-latest c_compiler: clang - - os: ubuntu-latest + - os: ubuntu-24.04 c_compiler: cl steps: From 84364ca0c152e35f0e5bedd624c1d89cb9a7c236 Mon Sep 17 00:00:00 2001 From: Daniel Date: Sat, 7 Sep 2024 18:09:30 +0200 Subject: [PATCH 05/11] Add `windows-2019` os --- .github/workflows/cmake-multi-platform.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cmake-multi-platform.yml b/.github/workflows/cmake-multi-platform.yml index 380fc2c..983be2e 100644 --- a/.github/workflows/cmake-multi-platform.yml +++ b/.github/workflows/cmake-multi-platform.yml @@ -23,13 +23,16 @@ jobs: # # To add more build types (Release, Debug, RelWithDebInfo, etc.) customize the build_type list. matrix: - os: [ubuntu-24.04, windows-latest] + os: [ubuntu-24.04, windows-latest, windows-2019] build_type: [Release] c_compiler: [gcc, clang, cl] include: - os: windows-latest c_compiler: cl cpp_compiler: cl + - os: windows-2019 + c_compiler: cl + cpp_compiler: cl - os: ubuntu-24.04 c_compiler: gcc cpp_compiler: g++ @@ -41,6 +44,10 @@ jobs: c_compiler: gcc - os: windows-latest c_compiler: clang + - os: windows-2019 + c_compiler: gcc + - os: windows-2019 + c_compiler: clang - os: ubuntu-24.04 c_compiler: cl From c9f8b10f0ea14332e130e5978c09632ba90ebc64 Mon Sep 17 00:00:00 2001 From: Daniel Date: Sat, 7 Sep 2024 18:20:27 +0200 Subject: [PATCH 06/11] [windows-19] Add `typename` keyword Fixes error C7510: use of dependent type name must be prefixed with 'typename' --- include/tulz/observer/EternalObserverFactory.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/tulz/observer/EternalObserverFactory.h b/include/tulz/observer/EternalObserverFactory.h index 65c519e..321e29b 100644 --- a/include/tulz/observer/EternalObserverFactory.h +++ b/include/tulz/observer/EternalObserverFactory.h @@ -6,7 +6,7 @@ namespace tulz { namespace detail { -using EternalObserverFactory_t = decltype([](EternalObserver::Func f = {}) { +using EternalObserverFactory_t = decltype([](typename EternalObserver::Func f = {}) { return std::make_unique>(std::move(f)); }); } From 5976ebf8ef2a08bece7ad27b2040b4e900961c97 Mon Sep 17 00:00:00 2001 From: Daniel Date: Sun, 8 Sep 2024 13:41:34 +0200 Subject: [PATCH 07/11] Remove useless comment & set `pull_request` trigger to default See: https://stackoverflow.com/a/65096459/9200394 --- .github/workflows/cmake-multi-platform.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/cmake-multi-platform.yml b/.github/workflows/cmake-multi-platform.yml index 983be2e..67c2978 100644 --- a/.github/workflows/cmake-multi-platform.yml +++ b/.github/workflows/cmake-multi-platform.yml @@ -1,12 +1,9 @@ -# This starter workflow is for a CMake project running on multiple platforms. There is a different starter workflow if you just want a single platform. -# See: https://github.com/actions/starter-workflows/blob/main/ci/cmake-single-platform.yml name: CMake on multiple platforms on: push: branches: [ "**" ] pull_request: - branches: [ "**" ] jobs: build: From 70c2a6ff1bf845aa27505b6b8631853d41f9a9c4 Mon Sep 17 00:00:00 2001 From: Daniel Date: Sun, 8 Sep 2024 13:45:37 +0200 Subject: [PATCH 08/11] Remove `pull_request` trigger --- .github/workflows/cmake-multi-platform.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/cmake-multi-platform.yml b/.github/workflows/cmake-multi-platform.yml index 67c2978..783c54c 100644 --- a/.github/workflows/cmake-multi-platform.yml +++ b/.github/workflows/cmake-multi-platform.yml @@ -3,7 +3,6 @@ name: CMake on multiple platforms on: push: branches: [ "**" ] - pull_request: jobs: build: From 44f540c62728e47a111d60e919e8de71ebda5813 Mon Sep 17 00:00:00 2001 From: Daniel Date: Sun, 8 Sep 2024 13:50:55 +0200 Subject: [PATCH 09/11] Trigger `push` event only for the `master` branch, `pull_request` for all branches & cleanup comments --- .github/workflows/cmake-multi-platform.yml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/cmake-multi-platform.yml b/.github/workflows/cmake-multi-platform.yml index 783c54c..313f526 100644 --- a/.github/workflows/cmake-multi-platform.yml +++ b/.github/workflows/cmake-multi-platform.yml @@ -2,6 +2,8 @@ name: CMake on multiple platforms on: push: + branches: [ "master" ] + pull_request: branches: [ "**" ] jobs: @@ -12,12 +14,6 @@ jobs: # Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable. fail-fast: false - # Set up a matrix to run the following 3 configurations: - # 1. - # 2. - # 3. - # - # To add more build types (Release, Debug, RelWithDebInfo, etc.) customize the build_type list. matrix: os: [ubuntu-24.04, windows-latest, windows-2019] build_type: [Release] From d9133e05c6e1d92ee466877458d1f510d74280a9 Mon Sep 17 00:00:00 2001 From: Daniel Date: Sun, 8 Sep 2024 18:48:48 +0200 Subject: [PATCH 10/11] Change project structure: tests as subdirectory, not as a separate project Also: - Set `FETCHCONTENT_BASE_DIR` to default --- .github/workflows/cmake-multi-platform.yml | 2 +- CMakeLists.txt | 7 +++++++ tests/CMakeLists.txt | 14 -------------- 3 files changed, 8 insertions(+), 15 deletions(-) diff --git a/.github/workflows/cmake-multi-platform.yml b/.github/workflows/cmake-multi-platform.yml index 313f526..7dfe648 100644 --- a/.github/workflows/cmake-multi-platform.yml +++ b/.github/workflows/cmake-multi-platform.yml @@ -61,7 +61,7 @@ jobs: -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} - -S ${{ github.workspace }}/tests + -S ${{ github.workspace }} - name: Build # Build your program with the given configuration. Note that --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator). diff --git a/CMakeLists.txt b/CMakeLists.txt index fcccb13..fa14c5e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,6 +3,8 @@ project(tulz) set(CMAKE_CXX_STANDARD 20) +option(TULZ_ENABLE_TESTS "Turn it off in order to disable tests" ON) + set(TULZ_OBSERVER_SOURCES include/tulz/observer/Observer.h include/tulz/observer/Subject.h @@ -96,4 +98,9 @@ target_include_directories(tulz PUBLIC include) if (ANDROID) target_include_directories(tulz PUBLIC android/include) +endif() + +if (TULZ_ENABLE_TESTS) + enable_testing() + add_subdirectory(tests) endif() \ No newline at end of file diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index ea6a1b1..32c69d9 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,23 +1,11 @@ cmake_minimum_required(VERSION 3.14) project(tulz-tests) -enable_testing() - set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) include(FetchContent) -if (UNIX) - set(DEPS_DIR "deps") -elseif (WIN32) - set(DEPS_DIR "deps-win") -else() - message(FATAL_ERROR "Unsupported OS") -endif() - -get_filename_component(FETCHCONTENT_BASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/${DEPS_DIR}" REALPATH) - FetchContent_Declare(googletest GIT_REPOSITORY https://github.com/google/googletest.git GIT_TAG v1.14.0) @@ -27,8 +15,6 @@ set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) FetchContent_MakeAvailable(googletest) -add_subdirectory(../ tulz) - include_directories(${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR}) function(add_gtest name src) From 826881e5fffd46ab773ea1859f662dc9feedf402 Mon Sep 17 00:00:00 2001 From: Daniel Date: Sun, 8 Sep 2024 18:50:29 +0200 Subject: [PATCH 11/11] Cleanup README.md --- README.md | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/README.md b/README.md index 250ba9f..2b7f52e 100644 --- a/README.md +++ b/README.md @@ -3,15 +3,6 @@ Tulz is a light-weight cross-platform C++20 tools library for C++ development. It contains reusable classes that I use in my projects. -## Compilers support - -Tested under: - -| Linux | Windows | Android | -|--------------|----------------------|------------------| -| GCC 13.3.1 | MSVC 19.37.32824 x64 | NDK 22.0.7026061 | -| Clang 17.0.6 | Clang 16.0.0 | | - ## Installation 1. Put sources in your libs folder @@ -30,14 +21,4 @@ Tested under: | Flag | Description | Mandatory | Default | Platform | |----------------------------------------|------------------------------------------|-----------|---------|----------| -| `TULZ_DEMANGLER_DISABLE_THREAD_SAFETY` | Controls `tulz::demangler` thread safety | No | OFF | Windows | - -## Examples - -You can find example in [examples/example.cpp](examples/example.cpp) - -Note that you must clone this repository to `tulz` directory to be able to run example, not `tulz-master` etc - -## Donate - -Payeer: P36281059 +| `TULZ_DEMANGLER_DISABLE_THREAD_SAFETY` | Controls `tulz::demangler` thread safety | No | OFF | Windows | \ No newline at end of file