Skip to content

Commit

Permalink
Merge pull request #6 from congard/feature/github-actions-1
Browse files Browse the repository at this point in the history
Enable GitHub Actions
  • Loading branch information
congard authored Sep 8, 2024
2 parents 36c9f32 + 826881e commit 98add01
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 38 deletions.
74 changes: 74 additions & 0 deletions .github/workflows/cmake-multi-platform.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: CMake on multiple platforms

on:
push:
branches: [ "master" ]
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

matrix:
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++
- os: ubuntu-24.04
c_compiler: clang
cpp_compiler: clang++
exclude:
- os: windows-latest
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

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 }}
- 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 }}
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
21 changes: 1 addition & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

<b>Payeer:</b> P36281059
| `TULZ_DEMANGLER_DISABLE_THREAD_SAFETY` | Controls `tulz::demangler` thread safety | No | OFF | Windows |
2 changes: 1 addition & 1 deletion include/tulz/observer/EternalObserverFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace tulz {
namespace detail {
using EternalObserverFactory_t = decltype([]<typename ...Args>(EternalObserver<Args...>::Func f = {}) {
using EternalObserverFactory_t = decltype([]<typename ...Args>(typename EternalObserver<Args...>::Func f = {}) {
return std::make_unique<EternalObserver<Args...>>(std::move(f));
});
}
Expand Down
4 changes: 1 addition & 3 deletions src/observer/routing/SubjectRouter.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include <tulz/observer/routing/SubjectRouter.h>

#include <experimental/map>
#include <numeric>
#include <cassert>

Expand Down Expand Up @@ -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();
});
}
Expand Down
14 changes: 0 additions & 14 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit 98add01

Please sign in to comment.