Skip to content

Commit

Permalink
Merge pull request #16 from jhrutgers/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
jhrutgers authored Oct 18, 2022
2 parents 0921c4b + c62b901 commit 85363e0
Show file tree
Hide file tree
Showing 94 changed files with 1,706 additions and 1,977 deletions.
43 changes: 30 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,20 @@ jobs:
build-ubuntu:
strategy:
matrix:
os: [ubuntu-latest, ubuntu-18.04]
gcc: [7, 9, 10]
os: [ubuntu-22.04, ubuntu-20.04]
gcc: [9, 10, 11]
cxx: [C++03, C++11, C++14, C++17]
zmq: [zmq, nozmq]
exclude:
- os: ubuntu-latest
gcc: 7
- gcc: 7
cxx: C++17
- os: ubuntu-20.04
gcc: 11
runs-on: ${{matrix.os}}
env:
CC: gcc-${{matrix.gcc}}
CXX: g++-${{matrix.gcc}}
steps:
- name: checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: bootstrap
run: |
dist/ubuntu/bootstrap.sh
Expand All @@ -47,7 +45,7 @@ jobs:
zmq: [ON, OFF]
steps:
- name: checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: bootstrap
run: dist\win32\bootstrap.cmd
- name: build Debug
Expand All @@ -67,7 +65,7 @@ jobs:
runs-on: macos-latest
steps:
- name: checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: bootstrap
run: dist/macos/bootstrap.sh
- name: build Debug
Expand All @@ -81,7 +79,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: bootstrap
run: dist/qemu-arm-a15/bootstrap.sh
- name: build Debug
Expand All @@ -95,7 +93,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: bootstrap
run: dist/qemu-arm-m3/bootstrap.sh
- name: build Debug
Expand All @@ -109,7 +107,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: bootstrap
run: dist/mingw/bootstrap.sh
- name: build Debug
Expand All @@ -125,7 +123,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: bootstrap
run: dist/ubuntu/bootstrap.sh
- name: build
Expand All @@ -135,3 +133,22 @@ jobs:
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./doxygen/html

test-documentation:
if: github.ref != 'refs/heads/master'
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v3
- name: bootstrap
run: dist/ubuntu/bootstrap.sh
- name: build
run: dist/ubuntu/build.sh -DZTH_DOCUMENTATION=ON

merge-status-check:
if: github.ref != 'refs/heads/master'
needs: [build-ubuntu, build-windows, build-mac, build-arm-a15, build-arm-m3, build-mingw, test-documentation]
runs-on: ubuntu-latest
steps:
- name: accept
run: echo OK
10 changes: 8 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,22 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased](https://github.com/jhrutgers/zth/compare/v1.0.0...HEAD)
## [Unreleased](https://github.com/jhrutgers/zth/compare/v1.1.0...HEAD)

## [1.1.0] - xxxx-xx-xx
## [1.1.0] - 2022-10-18

### Added

- `zth::fiber()` as alternative to `zth_fiber()` and friends with `async`.
- Defining `async` can be prevented by defining `ZTH_NO_ASYNC_KEYWORD` before
including `<zth>`. `zth_async` is always defined, with the original behavior
of `async`.
- Make split `zth::fsm::Fsm` into a `BasicFsm` and `Fsm`, of which the former
does not need fiber and timestamps to run. As a result, the `BasicFsm` can
be executed in an interrupt routine.
- Fix support for builds without exceptions and environmental variables to
reduce library size.
- Change license to MPLv2.

[1.1.0]: https://github.com/jhrutgers/zth/releases/tag/v1.1.0

Expand Down
89 changes: 66 additions & 23 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,25 +1,18 @@
# Zth (libzth), a cooperative userspace multitasking library.
# Copyright (C) 2019-2021 Jochem Rutgers
# Copyright (C) 2019-2022 Jochem Rutgers
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at https://mozilla.org/MPL/2.0/.

cmake_minimum_required(VERSION 3.3)
project(Zth)

cmake_policy(SET CMP0057 NEW)

include(CheckIncludeFileCXX)
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)

if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type" FORCE)
Expand Down Expand Up @@ -98,6 +91,8 @@ if(${CMAKE_VERSION} VERSION_GREATER "3.6.0" AND NOT CMAKE_CROSSCOMPILING)

string(CONCAT CLANG_TIDY_CHECKS "-checks="
"bugprone-*,"
"-bugprone-easily-swappable-parameters,"

"clang-analyzer-*,"
"concurrency-*,"

Expand Down Expand Up @@ -139,6 +134,7 @@ if(${CMAKE_VERSION} VERSION_GREATER "3.6.0" AND NOT CMAKE_CROSSCOMPILING)
"-readability-convert-member-functions-to-static,"
"-readability-else-after-return,"
"-readability-function-cognitive-complexity,"
"-readability-identifier-length,"
"-readability-implicit-bool-conversion,"
"-readability-magic-numbers,"
"-readability-make-member-function-const,"
Expand All @@ -165,6 +161,7 @@ if(${CMAKE_VERSION} VERSION_GREATER "3.6.0" AND NOT CMAKE_CROSSCOMPILING)
endif()

add_library(libzth
src/assert.cpp
src/config.cpp
src/context.cpp
src/fiber.cpp
Expand All @@ -181,7 +178,35 @@ add_library(libzth
src/zmq.cpp
src/zth_logv.cpp
)
set_target_properties(libzth PROPERTIES OUTPUT_NAME "zth")

set(ZTH_HEADERS
include/libzth/allocator.h
include/libzth/async.h
include/libzth/config.h
include/libzth/context.h
include/libzth/fiber.h
include/libzth/fsm.h
include/libzth/fsm14.h
include/libzth/init.h
include/libzth/io.h
include/libzth/list.h
include/libzth/macros.h
include/libzth/perf.h
include/libzth/poller.h
include/libzth/regs.h
include/libzth/sync.h
include/libzth/time.h
include/libzth/util.h
include/libzth/version.h
include/libzth/waiter.h
include/libzth/worker.h
include/libzth/zmq.h
)

set_target_properties(libzth PROPERTIES
OUTPUT_NAME "zth"
PUBLIC_HEADER "${ZTH_HEADERS}"
)

if(ZTH_DRAFT_API)
target_compile_definitions(libzth PUBLIC -DZTH_DRAFT_API)
Expand Down Expand Up @@ -212,15 +237,29 @@ if(ZTH_CONFIG_ENABLE_DEBUG_PRINT)
endif()

install(TARGETS libzth EXPORT libzth
ARCHIVE DESTINATION lib
PUBLIC_HEADER DESTINATION include
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/libzth
)

configure_file(cmake/libzth.cmake.in ${CMAKE_BINARY_DIR}/libzth.cmake)
install(DIRECTORY include/ DESTINATION include FILES_MATCHING PATTERN "*.h")
install(FILES include/zth DESTINATION include)
install(EXPORT libzth DESTINATION share/libzth/cmake)
install(FILES ${CMAKE_BINARY_DIR}/libzth.cmake DESTINATION share/cmake/libzth)
install(FILES include/zth include/zth.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
set(ZTH_CONFIG_FILE ${CMAKE_CURRENT_SOURCE_DIR}/include/zth_config.h)
foreach(d IN LISTS ZTH_PREPEND_INCLUDE_DIRECTORIES)
if(EXISTS ${d}/zth_config.h)
set(ZTH_CONFIG_FILE ${d}/zth_config.h)
break()
endif()
endforeach()
install(FILES ${ZTH_CONFIG_FILE} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})

install(EXPORT libzth DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/libzth/cmake)

configure_package_config_file(
cmake/ZthConfig.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/ZthConfig.cmake"
INSTALL_DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/cmake/Zth
)

install(FILES ${CMAKE_CURRENT_BINARY_DIR}/ZthConfig.cmake DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/cmake/Zth)

if(ZTH_HAVE_LIBZMQ)
target_compile_definitions(libzth PUBLIC -DZTH_HAVE_LIBZMQ)
Expand All @@ -230,7 +269,7 @@ endif()
if(NOT APPLE)
CHECK_INCLUDE_FILE_CXX("libunwind.h" ZTH_HAVE_LIBUNWIND)
if(ZTH_HAVE_LIBUNWIND)
target_compile_definitions(libzth PUBLIC -DZTH_HAVE_LIBUNWIND)
target_compile_definitions(libzth PRIVATE -DZTH_HAVE_LIBUNWIND)
target_link_libraries(libzth INTERFACE unwind)
endif()
endif()
Expand All @@ -253,8 +292,12 @@ if(UNIX OR MINGW)
if(MINGW)
set(THREADS_HAVE_PTHREAD_ARG 1)
endif()

find_package(Threads REQUIRED)
target_link_libraries(libzth PUBLIC Threads::Threads)

if(CMAKE_THREAD_LIBS_INIT)
target_link_libraries(libzth PUBLIC ${CMAKE_THREAD_LIBS_INIT})
endif()
endif()

if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
Expand Down
Loading

0 comments on commit 85363e0

Please sign in to comment.