diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..3498d5b --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,96 @@ +name: build + +on: [push] + +jobs: + build-ubuntu-20-04: + name: ubuntu-20.04 + runs-on: ubuntu-latest + container: + image: ubuntu:20.04 + env: + TZ: America/New_York + DEBIAN_FRONTEND: noninteractive + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: apt + run: | + apt-get update + apt-get -y upgrade + apt install -y build-essential software-properties-common + add-apt-repository ppa:ubuntu-toolchain-r/test + apt-get install -y \ + cmake \ + git \ + ninja-build \ + g++-10 + - name: build-release-g++ + run: | + mkdir build-release-g++ + cd build-release-g++ + cmake \ + -GNinja \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_C_COMPILER=gcc-10 \ + -DCMAKE_CXX_COMPILER=g++-10 \ + .. + ninja + - name: test-release-g++ + run: | + cd build-release-g++ + ctest -VV + build-fedora-31: + name: fedora-32 + runs-on: ubuntu-latest + container: + image: fedora:32 + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: dnf + run: | + sudo dnf install -y \ + cmake \ + git \ + ninja-build \ + gcc-c++-10.2.1 \ + lcov + - name: build-debug-g++ + run: | + mkdir build-debug-g++ + cd build-debug-g++ + cmake \ + -GNinja \ + -DCORO_CODE_COVERAGE=ON \ + -DCMAKE_BUILD_TYPE=Debug \ + -DCMAKE_C_COMPILER=gcc \ + -DCMAKE_CXX_COMPILER=g++ \ + .. + ninja + - name: build-release-g++ + run: | + mkdir build-release-g++ + cd build-release-g++ + cmake \ + -GNinja \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_C_COMPILER=gcc \ + -DCMAKE_CXX_COMPILER=g++ \ + .. + ninja + - name: test-release-g++ + run: | + cd build-release-g++ + ctest -VV + - name: Build coverage info + run: | + cd build-debug-g++ + ctest -VV + gcov -o ./test/CMakeFiles/libcoro_tests.dir/main.cpp.o ./test/libcoro_tests + lcov --include "*/inc/coro/*" --include "*/src/*" --exclude "test/*" -o libcoro_tests.info -c -d . + - name: Coveralls GitHub Action + uses: coverallsapp/github-action@v1.0.1 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + path-to-lcov: build-debug-g++/libcoro_tests.info diff --git a/CMakeLists.txt b/CMakeLists.txt index e4ff0ce..10f3c21 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,20 +8,20 @@ message("${PROJECT_NAME} CORO_BUILD_TESTS = ${CORO_BUILD_TESTS}") message("${PROJECT_NAME} CORO_CODE_COVERAGE = ${CORO_CODE_COVERAGE}") set(LIBCORO_SOURCE_FILES - src/coro/coro.hpp - src/coro/event.hpp - src/coro/generator.hpp - src/coro/latch.hpp - src/coro/scheduler.hpp - src/coro/sync_wait.hpp - src/coro/task.hpp + inc/coro/coro.hpp + inc/coro/event.hpp + inc/coro/generator.hpp + inc/coro/latch.hpp + inc/coro/scheduler.hpp + inc/coro/sync_wait.hpp + inc/coro/task.hpp ) add_library(${PROJECT_NAME} STATIC ${LIBCORO_SOURCE_FILES}) set_target_properties(${PROJECT_NAME} PROPERTIES LINKER_LANGUAGE CXX) target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_20) -target_include_directories(${PROJECT_NAME} PUBLIC src) -target_link_libraries(${PROJECT_NAME} PUBLIC zmq pthread) +target_include_directories(${PROJECT_NAME} PUBLIC inc) +target_link_libraries(${PROJECT_NAME} PUBLIC pthread) if(${CMAKE_CXX_COMPILER_ID} MATCHES "GNU") if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "10.2.0") diff --git a/README.md b/README.md index b120cd3..0f85ae1 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,21 @@ -# libcoro +libcoro C++20 Coroutines +======================== -This library is meant for learning the new C++20 coroutines. +[![CI](https://github.com/jbaldwin/libcoro/workflows/build/badge.svg)](https://github.com/jbaldwin/libcoro/workflows/build/badge.svg) +[![Coverage Status](https://coveralls.io/repos/github/jbaldwin/libcoro/badge.svg?branch=master)](https://coveralls.io/github/jbaldwin/libcoro?branch=master) +[![language][badge.language]][language] +[![license][badge.license]][license] + +[badge.language]: https://img.shields.io/badge/language-C%2B%2B17-yellow.svg +[badge.license]: https://img.shields.io/badge/license-Apache--2.0-blue + +[language]: https://en.wikipedia.org/wiki/C%2B%2B17 +[license]: https://en.wikipedia.org/wiki/Apache_License + +**libcoro** is licensed under the Apache 2.0 license. + +# Background +Libcoro is a C++20 coroutine library. So far most inspiration has been gleaned from [libcppcoro](https://github.com/lewissbaker/cppcoro) an amazing C++ coroutine library as well as Lewis Baker's great coroutine blog entries [https://lewissbaker.github.io/](Blog). I would highly recommend anyone who is trying to learn the internals of C++20's coroutine implementation to read all of his blog entries, they are extremely insightful and well written. + +# Goal +Libcoro is currently more of a learning experience for myself but ultimately I'd like to turn this into a great linux coroutine base library with an easy to use HTTP scheduler/server. diff --git a/src/coro/coro.hpp b/inc/coro/coro.hpp similarity index 100% rename from src/coro/coro.hpp rename to inc/coro/coro.hpp diff --git a/src/coro/event.hpp b/inc/coro/event.hpp similarity index 100% rename from src/coro/event.hpp rename to inc/coro/event.hpp diff --git a/src/coro/generator.hpp b/inc/coro/generator.hpp similarity index 100% rename from src/coro/generator.hpp rename to inc/coro/generator.hpp diff --git a/src/coro/latch.hpp b/inc/coro/latch.hpp similarity index 100% rename from src/coro/latch.hpp rename to inc/coro/latch.hpp diff --git a/src/coro/scheduler.hpp b/inc/coro/scheduler.hpp similarity index 100% rename from src/coro/scheduler.hpp rename to inc/coro/scheduler.hpp diff --git a/src/coro/sync_wait.hpp b/inc/coro/sync_wait.hpp similarity index 100% rename from src/coro/sync_wait.hpp rename to inc/coro/sync_wait.hpp diff --git a/src/coro/task.hpp b/inc/coro/task.hpp similarity index 100% rename from src/coro/task.hpp rename to inc/coro/task.hpp diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 9fade7d..1f89be8 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -22,20 +22,9 @@ if(CORO_CODE_COVERAGE) endif() if(${CMAKE_CXX_COMPILER_ID} MATCHES "GNU") - target_compile_options( - ${PROJECT_NAME} PRIVATE - -Wno-unknown-pragmas - ) -endif() -if(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang") - target_compile_options(${PROJECT_NAME} PRIVATE - -Wall - -Wextra - -Weffc++ - -Werror - -Wpedantic - -pedantic-errors - ) + target_compile_options(${PROJECT_NAME} PUBLIC -fcoroutines -Wall -Wextra -pipe) +elseif(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang") + message(FATAL_ERROR "Clang is currently not supported.") endif() add_test(NAME corohttp_test COMMAND ${PROJECT_NAME}) \ No newline at end of file diff --git a/test/test_generator.cpp b/test/test_generator.cpp index 0cd285c..1d799f3 100644 --- a/test/test_generator.cpp +++ b/test/test_generator.cpp @@ -41,4 +41,4 @@ TEST_CASE("generator infinite incrementing integer yield") break; } } -} \ No newline at end of file +}