Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✅ test single-header cib.hpp in addition to multi-header #24

Merged
merged 4 commits into from
Apr 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
114 changes: 59 additions & 55 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,71 +15,73 @@ jobs:
strategy:
fail-fast: false
matrix:
include:
- compiler: clang-14
install: wget https://apt.llvm.org/llvm.sh && chmod +x llvm.sh && sudo ./llvm.sh 14
cc: " /usr/lib/llvm-14/bin/clang"
cxx: "/usr/lib/llvm-14/bin/clang++"
- compiler: clang-13
install: wget https://apt.llvm.org/llvm.sh && chmod +x llvm.sh && sudo ./llvm.sh 13
cc: " /usr/lib/llvm-13/bin/clang"
cxx: "/usr/lib/llvm-13/bin/clang++"
- compiler: clang-12
install: sudo apt update && sudo apt-get install -y clang-12
cc: " /usr/lib/llvm-12/bin/clang"
cxx: "/usr/lib/llvm-12/bin/clang++"
- compiler: clang-11
install: sudo apt update && sudo apt-get install -y clang-11
cc: " /usr/lib/llvm-11/bin/clang"
cxx: "/usr/lib/llvm-11/bin/clang++"
- compiler: clang-10
install: sudo apt update && sudo apt-get install -y clang-10
cc: " /usr/lib/llvm-10/bin/clang"
cxx: "/usr/lib/llvm-10/bin/clang++"
- compiler: clang-9
install: sudo apt update && sudo apt-get install -y clang-9
cc: " /usr/lib/llvm-9/bin/clang"
cxx: "/usr/lib/llvm-9/bin/clang++"
- compiler: clang-8
install: sudo apt update && sudo apt-get install -y clang-8
cc: " /usr/lib/llvm-8/bin/clang"
cxx: "/usr/lib/llvm-8/bin/clang++"
- compiler: clang-7
install: sudo apt update && sudo apt-get install -y clang-7
cc: " /usr/lib/llvm-7/bin/clang"
cxx: "/usr/lib/llvm-7/bin/clang++"
- compiler: gcc-11
install: sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test && sudo apt update && sudo apt-get install -y gcc-11 g++-11
cc: "/usr/bin/gcc-11"
cxx: "/usr/bin/g++-11"
- compiler: gcc-10
install: sudo apt update && sudo apt-get install -y gcc-10
cc: "/usr/bin/gcc-10"
cxx: "/usr/bin/g++-10"
- compiler: gcc-9
install: sudo apt update && sudo apt-get install -y gcc-9
cc: "/usr/bin/gcc-9"
cxx: "/usr/bin/g++-9"
- compiler: gcc-8
install: sudo apt update && sudo apt-get install -y gcc-8 g++-8
cc: "/usr/bin/gcc-8"
cxx: "/usr/bin/g++-8"
single_header: [0, 1]
compiler:
- name: clang-14
install: wget https://apt.llvm.org/llvm.sh && chmod +x llvm.sh && sudo ./llvm.sh 14
cc: " /usr/lib/llvm-14/bin/clang"
cxx: "/usr/lib/llvm-14/bin/clang++"
- name: clang-13
install: wget https://apt.llvm.org/llvm.sh && chmod +x llvm.sh && sudo ./llvm.sh 13
cc: " /usr/lib/llvm-13/bin/clang"
cxx: "/usr/lib/llvm-13/bin/clang++"
- name: clang-12
install: sudo apt update && sudo apt-get install -y clang-12
cc: " /usr/lib/llvm-12/bin/clang"
cxx: "/usr/lib/llvm-12/bin/clang++"
- name: clang-11
install: sudo apt update && sudo apt-get install -y clang-11
cc: " /usr/lib/llvm-11/bin/clang"
cxx: "/usr/lib/llvm-11/bin/clang++"
- name: clang-10
install: sudo apt update && sudo apt-get install -y clang-10
cc: " /usr/lib/llvm-10/bin/clang"
cxx: "/usr/lib/llvm-10/bin/clang++"
- name: clang-9
install: sudo apt update && sudo apt-get install -y clang-9
cc: " /usr/lib/llvm-9/bin/clang"
cxx: "/usr/lib/llvm-9/bin/clang++"
- name: clang-8
install: sudo apt update && sudo apt-get install -y clang-8
cc: " /usr/lib/llvm-8/bin/clang"
cxx: "/usr/lib/llvm-8/bin/clang++"
- name: clang-7
install: sudo apt update && sudo apt-get install -y clang-7
cc: " /usr/lib/llvm-7/bin/clang"
cxx: "/usr/lib/llvm-7/bin/clang++"
- name: gcc-11
install: sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test && sudo apt update && sudo apt-get install -y gcc-11 g++-11
cc: "/usr/bin/gcc-11"
cxx: "/usr/bin/g++-11"
- name: gcc-10
install: sudo apt update && sudo apt-get install -y gcc-10
cc: "/usr/bin/gcc-10"
cxx: "/usr/bin/g++-10"
- name: gcc-9
install: sudo apt update && sudo apt-get install -y gcc-9
cc: "/usr/bin/gcc-9"
cxx: "/usr/bin/g++-9"
- name: gcc-8
install: sudo apt update && sudo apt-get install -y gcc-8 g++-8
cc: "/usr/bin/gcc-8"
cxx: "/usr/bin/g++-8"

steps:
- uses: actions/checkout@v3
with:
submodules: recursive

- name: install compiler
run: ${{ matrix.install }}
run: ${{ matrix.compiler.install }}

- name: Configure CMake
env:
CC: ${{ matrix.cc }}
CXX: ${{ matrix.cxx }}
CC: ${{ matrix.compiler.cc }}
CXX: ${{ matrix.compiler.cxx }}
SINGLE_HEADER: ${{ matrix.single_header }}
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}

- name: Build
- name: Build Unit Tests
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -t tests

- name: Test
Expand All @@ -99,13 +101,15 @@ jobs:

- name: Build
# Build your program with the given configuration
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --target release
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --target release_header

- name: 'Upload Artifact'
uses: actions/upload-artifact@v3
with:
name: cib.hpp
path: build/cib.hpp
path: ${{github.workspace}}/build/include/cib/cib.hpp



performance_test:
runs-on: ubuntu-latest
Expand Down
48 changes: 33 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,46 @@ add_subdirectory(lib/Catch2)
add_subdirectory(test)
add_subdirectory(benchmark)

add_library(Cib INTERFACE)

target_include_directories(Cib
INTERFACE
${CMAKE_CURRENT_SOURCE_DIR}/include)

target_sources(Cib
INTERFACE
${CMAKE_CURRENT_SOURCE_DIR}/include/cib/cib.hpp)


add_custom_command(
DEPENDS
${CMAKE_SOURCE_DIR}/tools/gen_release_header.py
${CMAKE_SOURCE_DIR}/include/cib/*
${CMAKE_SOURCE_DIR}/include/cib/detail/*
COMMAND
python3 ${CMAKE_SOURCE_DIR}/tools/gen_release_header.py ${CMAKE_SOURCE_DIR}/include/cib/cib.hpp > ${CMAKE_BINARY_DIR}/cib.hpp
mkdir ${CMAKE_BINARY_DIR}/include/
COMMAND
mkdir ${CMAKE_BINARY_DIR}/include/cib/
COMMAND
python3 ${CMAKE_SOURCE_DIR}/tools/gen_release_header.py ${CMAKE_SOURCE_DIR}/include/cib/cib.hpp > ${CMAKE_BINARY_DIR}/include/cib/cib.hpp
OUTPUT
${CMAKE_BINARY_DIR}/cib.hpp
${CMAKE_BINARY_DIR}/include/cib/cib.hpp
)

add_custom_target(release
add_custom_target(release_header
DEPENDS
${CMAKE_BINARY_DIR}/cib.hpp)
${CMAKE_BINARY_DIR}/include/cib/cib.hpp)



add_library(Cib INTERFACE)

if ($ENV{SINGLE_HEADER})
message("Using single-header version of cib.hpp.")

add_dependencies(Cib release_header)

target_include_directories(Cib
INTERFACE
${CMAKE_BINARY_DIR}/include/)

else()
message("Using multi-header version of cib.hpp.")

target_include_directories(Cib
INTERFACE
${CMAKE_CURRENT_SOURCE_DIR}/include)

target_sources(Cib
INTERFACE
${CMAKE_CURRENT_SOURCE_DIR}/include/cib/cib.hpp)
endif()
3 changes: 2 additions & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ add_executable(tests
builder_meta.cpp
callback.cpp
nexus.cpp
detail/ordered_set.cpp)
detail/ordered_set.cpp
)

if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
target_compile_options(tests
Expand Down