Merge pull request #31 from BlackMATov/feature/presets-for-ci

Feature/presets-for-ci
This commit is contained in:
2022-11-07 03:19:04 +07:00
committed by GitHub
14 changed files with 166 additions and 162 deletions

View File

@@ -1,19 +0,0 @@
#!/bin/bash
set -e
DIR="$( cd "$( dirname "${BASH_SOURCE}" )" && pwd )"
ROOT_DIR="${DIR}/.."
BUILD_DIR="${ROOT_DIR}/build/coverage"
mkdir -p "${BUILD_DIR}"
(cd "${BUILD_DIR}" && cmake "${ROOT_DIR}" -DCMAKE_BUILD_TYPE=Debug -DBUILD_WITH_COVERAGE=ON)
(cd "${BUILD_DIR}" && cmake --build .)
(cd "${BUILD_DIR}" && lcov -d . -z)
(cd "${BUILD_DIR}" && ctest --verbose)
(cd "${BUILD_DIR}" && lcov -d . -c -o "coverage.info")
(cd "${BUILD_DIR}" && lcov -r "coverage.info" "*/usr/*" "*/untests/*" -o "coverage.info")
(cd "${BUILD_DIR}" && lcov -l "coverage.info")
bash <(curl -s https://codecov.io/bash) -f "${BUILD_DIR}/coverage.info" || echo "Codecov did not collect coverage reports"

View File

@@ -1,11 +0,0 @@
#!/bin/bash
set -e
DIR="$( cd "$( dirname "${BASH_SOURCE}" )" && pwd )"
ROOT_DIR="${DIR}/.."
BUILD_DIR="${ROOT_DIR}/build/darwin_release"
mkdir -p "${BUILD_DIR}"
(cd "${BUILD_DIR}" && cmake "${ROOT_DIR}" -DCMAKE_BUILD_TYPE=Release)
(cd "${BUILD_DIR}" && cmake --build .)
(cd "${BUILD_DIR}" && ctest --verbose)

View File

@@ -1,11 +0,0 @@
#!/bin/bash
set -e
DIR="$( cd "$( dirname "${BASH_SOURCE}" )" && pwd )"
ROOT_DIR="${DIR}/.."
BUILD_DIR="${ROOT_DIR}/build/linux_release"
mkdir -p "${BUILD_DIR}"
(cd "${BUILD_DIR}" && cmake "${ROOT_DIR}" -DCMAKE_BUILD_TYPE=Release)
(cd "${BUILD_DIR}" && cmake --build .)
(cd "${BUILD_DIR}" && ctest --verbose)

View File

@@ -1,19 +0,0 @@
@echo off
set DIR=%~dp0
set ROOT_DIR=%DIR%..\
set BUILD_DIR=%ROOT_DIR%build\windows_release_x64\
if not exist %BUILD_DIR% mkdir %BUILD_DIR% || goto :error
pushd %BUILD_DIR% || goto :error
cmake %ROOT_DIR% -A x64 || goto :error
cmake --build . --config Release || goto :error
ctest --verbose || goto :error
popd || goto :error
goto :EOF
:error
echo Failed with error #%errorlevel%.
exit /b %errorlevel%

View File

@@ -1,19 +0,0 @@
@echo off
set DIR=%~dp0
set ROOT_DIR=%DIR%..\
set BUILD_DIR=%ROOT_DIR%build\windows_release_x86\
if not exist %BUILD_DIR% mkdir %BUILD_DIR% || goto :error
pushd %BUILD_DIR% || goto :error
cmake %ROOT_DIR% -A Win32 || goto :error
cmake --build . --config Release || goto :error
ctest --verbose || goto :error
popd || goto :error
goto :EOF
:error
echo Failed with error #%errorlevel%.
exit /b %errorlevel%

View File

@@ -1,16 +0,0 @@
name: coverage
on: [push, pull_request]
jobs:
build:
runs-on: macos-11
name: "coverage"
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Install lcov by Homebrew
run: brew install lcov
- name: Build && Test && Upload
run: .ci/build_coverage.sh

View File

@@ -10,15 +10,22 @@ jobs:
matrix:
config:
# https://github.com/actions/virtual-environments/tree/main/images/macos
- { os: "macos-11", xcode: "13.0" }
- { os: "macos-11", xcode: "13.1" }
- { os: "macos-11", xcode: "13.2" }
- { os: "macos-11", xcode: "13.0", arch: "x64" }
- { os: "macos-12", xcode: "14.0", arch: "x64" }
name: "xcode-${{matrix.config.xcode}}"
steps:
- uses: actions/checkout@v2
- name: Setup
run: brew install cmake ninja
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive
submodules: true
- name: Select Xcode
run: sudo xcode-select --switch "/Applications/Xcode_${{matrix.config.xcode}}.app"
- name: Build && Test
run: .ci/build_darwin.sh
- name: Build
run: |
cmake --preset macos-${{matrix.config.arch}}
cmake --build --preset macos-${{matrix.config.arch}}-release
- name: Test
run: |
ctest --preset macos-${{matrix.config.arch}}-release

View File

@@ -15,11 +15,15 @@ jobs:
name: "${{matrix.config.cxx}}"
steps:
- name: Setup
run: sudo apt-get -y install "${{matrix.config.cc}}" "${{matrix.config.cxx}}"
run: sudo apt-get -y install cmake ninja-build ${{matrix.config.cc}} ${{matrix.config.cxx}}
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
submodules: recursive
- name: Build && Test
run: .ci/build_linux.sh
env: { CC: "${{matrix.config.cc}}", CXX: "${{matrix.config.cxx}}" }
submodules: true
- name: Build
run: |
cmake --preset linux-${{matrix.config.cc}}
cmake --build --preset linux-${{matrix.config.cc}}-release
- name: Test
run: |
ctest --preset linux-${{matrix.config.cc}}-release

View File

@@ -10,14 +10,24 @@ jobs:
matrix:
config:
# https://github.com/actions/virtual-environments/tree/main/images/win
- { os: "windows-2019", vs: "Visual Studio 2019", arch: "x86" }
- { os: "windows-2019", vs: "Visual Studio 2019", arch: "x64" }
- { os: "windows-2022", vs: "Visual Studio 2022", arch: "x86" }
- { os: "windows-2022", vs: "Visual Studio 2022", arch: "x64" }
name: "${{matrix.config.vs}} ${{matrix.config.arch}}"
- { os: "windows-2019", vc: "msvc2019", arch: "x86" }
- { os: "windows-2019", vc: "msvc2019", arch: "x64" }
- { os: "windows-2022", vc: "msvc2022", arch: "x86" }
- { os: "windows-2022", vc: "msvc2022", arch: "x64" }
name: "${{matrix.config.vc}} ${{matrix.config.arch}}"
steps:
- uses: actions/checkout@v2
- name: Setup
run: choco install cmake ninja
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive
- name: Build && Test
run: .ci\build_windows_${{matrix.config.arch}}.bat
submodules: true
- name: Select MSVC
uses: ilammy/msvc-dev-cmd@v1
- name: Build
run: |
cmake --preset windows-${{matrix.config.arch}}-${{matrix.config.vc}}
cmake --build --preset windows-${{matrix.config.arch}}-${{matrix.config.vc}}-release
- name: Test
run: |
ctest --preset windows-${{matrix.config.arch}}-${{matrix.config.vc}}-release

View File

@@ -29,7 +29,7 @@
}
},
{
"name": "linux-clang10",
"name": "linux-clang-10",
"inherits": "linux-base",
"cacheVariables": {
"CMAKE_C_COMPILER": "clang-10",
@@ -37,7 +37,7 @@
}
},
{
"name": "linux-gcc10",
"name": "linux-gcc-10",
"inherits": "linux-base",
"cacheVariables": {
"CMAKE_C_COMPILER": "gcc-10",
@@ -162,24 +162,24 @@
"buildPresets": [
{
"name": "linux-clang10-debug",
"name": "linux-clang-10-debug",
"configuration": "Debug",
"configurePreset": "linux-clang10"
"configurePreset": "linux-clang-10"
},
{
"name": "linux-clang10-release",
"name": "linux-clang-10-release",
"configuration": "Release",
"configurePreset": "linux-clang10"
"configurePreset": "linux-clang-10"
},
{
"name": "linux-gcc10-debug",
"name": "linux-gcc-10-debug",
"configuration": "Debug",
"configurePreset": "linux-gcc10"
"configurePreset": "linux-gcc-10"
},
{
"name": "linux-gcc10-release",
"name": "linux-gcc-10-release",
"configuration": "Release",
"configurePreset": "linux-gcc10"
"configurePreset": "linux-gcc-10"
},
{
"name": "macos-arm64-debug",
@@ -241,5 +241,48 @@
"configuration": "Release",
"configurePreset": "windows-x64-msvc2022"
}
],
"testPresets": [
{
"name": "linux-gcc-10-release",
"configuration": "Release",
"configurePreset": "linux-gcc-10"
},
{
"name": "linux-clang-10-release",
"configuration": "Release",
"configurePreset": "linux-clang-10"
},
{
"name": "macos-arm64-release",
"configuration": "Release",
"configurePreset": "macos-arm64"
},
{
"name": "macos-x64-release",
"configuration": "Release",
"configurePreset": "macos-x64"
},
{
"name": "windows-x86-msvc2019-release",
"configuration": "Release",
"configurePreset": "windows-x86-msvc2019"
},
{
"name": "windows-x64-msvc2019-release",
"configuration": "Release",
"configurePreset": "windows-x64-msvc2019"
},
{
"name": "windows-x86-msvc2022-release",
"configuration": "Release",
"configurePreset": "windows-x86-msvc2022"
},
{
"name": "windows-x64-msvc2022-release",
"configuration": "Release",
"configurePreset": "windows-x64-msvc2022"
}
]
}

View File

@@ -5,21 +5,18 @@
[![linux][badge.linux]][linux]
[![darwin][badge.darwin]][darwin]
[![windows][badge.windows]][windows]
[![codecov][badge.codecov]][codecov]
[![language][badge.language]][language]
[![license][badge.license]][license]
[badge.darwin]: https://img.shields.io/github/workflow/status/BlackMATov/meta.hpp/darwin/main?label=Xcode&logo=xcode
[badge.linux]: https://img.shields.io/github/workflow/status/BlackMATov/meta.hpp/linux/main?label=GCC%2FClang&logo=linux
[badge.windows]: https://img.shields.io/github/workflow/status/BlackMATov/meta.hpp/windows/main?label=Visual%20Studio&logo=visual-studio
[badge.codecov]: https://img.shields.io/codecov/c/github/BlackMATov/meta.hpp/main?logo=codecov
[badge.language]: https://img.shields.io/badge/language-C%2B%2B20-orange
[badge.license]: https://img.shields.io/badge/license-MIT-blue
[darwin]: https://github.com/BlackMATov/meta.hpp/actions?query=workflow%3Adarwin
[linux]: https://github.com/BlackMATov/meta.hpp/actions?query=workflow%3Alinux
[windows]: https://github.com/BlackMATov/meta.hpp/actions?query=workflow%3Awindows
[codecov]: https://codecov.io/gh/BlackMATov/meta.hpp
[language]: https://en.wikipedia.org/wiki/C%2B%2B20
[license]: https://en.wikipedia.org/wiki/MIT_License

View File

@@ -4,17 +4,49 @@ file(GLOB_RECURSE MANUALS_SOURCES "*.cpp" "*.hpp")
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${MANUALS_SOURCES})
add_executable(${PROJECT_NAME} ${MANUALS_SOURCES})
target_link_libraries(${PROJECT_NAME} PRIVATE meta.hpp doctest_with_main fmt)
target_link_libraries(${PROJECT_NAME} PRIVATE meta.hpp)
add_executable(${PROJECT_NAME}.singles ${MANUALS_SOURCES})
target_link_libraries(${PROJECT_NAME}.singles PRIVATE meta.hpp.singles)
#
# setup defines
#
function(setup_defines_for_target TARGET)
target_compile_definitions(${TARGET} PRIVATE
DOCTEST_CONFIG_INCLUDE_TYPE_TRAITS
DOCTEST_CONFIG_USE_STD_HEADERS)
endfunction()
setup_defines_for_target(${PROJECT_NAME})
setup_defines_for_target(${PROJECT_NAME}.singles)
#
# setup libraries
#
function(setup_libraries_for_target TARGET)
target_link_libraries(${TARGET} PRIVATE doctest_with_main fmt)
if(${BUILD_WITH_COVERAGE})
target_link_libraries(${PROJECT_NAME} PRIVATE enable_gcov)
target_link_libraries(${TARGET} PRIVATE enable_gcov)
endif()
if(${BUILD_WITH_SANITIZERS})
target_link_libraries(${PROJECT_NAME} PRIVATE enable_asan enable_ubsan)
target_link_libraries(${TARGET} PRIVATE enable_asan enable_ubsan)
endif()
endfunction()
target_compile_options(${PROJECT_NAME}
setup_libraries_for_target(${PROJECT_NAME})
setup_libraries_for_target(${PROJECT_NAME}.singles)
#
# setup warnings
#
function(setup_warnings_for_target TARGET)
target_compile_options(${TARGET}
PRIVATE
$<$<CXX_COMPILER_ID:MSVC>:
/WX /W4>
@@ -27,6 +59,7 @@ target_compile_options(${PROJECT_NAME}
-Wno-c++98-compat
-Wno-c++98-compat-pedantic
-Wno-exit-time-destructors
-Wno-global-constructors
-Wno-padded
-Wno-unknown-warning-option
-Wno-unneeded-internal-declaration
@@ -34,9 +67,14 @@ target_compile_options(${PROJECT_NAME}
-Wno-unused-macros
-Wno-weak-vtables
>)
endfunction()
target_compile_definitions(${PROJECT_NAME} PRIVATE
DOCTEST_CONFIG_INCLUDE_TYPE_TRAITS
DOCTEST_CONFIG_USE_STD_HEADERS)
setup_warnings_for_target(${PROJECT_NAME})
setup_warnings_for_target(${PROJECT_NAME}.singles)
#
# add tests
#
add_test(${PROJECT_NAME} ${PROJECT_NAME})
add_test(${PROJECT_NAME} ${PROJECT_NAME}.singles)

View File

@@ -4,7 +4,7 @@ project(meta.hpp.singles)
# generate
#
find_package(PythonInterp REQUIRED)
find_package(Python3 REQUIRED COMPONENTS Interpreter)
set(META_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/..")
set(META_SINGLES_INPUT "${META_ROOT_DIR}/headers/meta.hpp/meta_all.hpp")
@@ -12,7 +12,7 @@ set(META_SINGLES_OUTPUT "${META_ROOT_DIR}/singles/headers/meta.hpp/meta_all.hpp"
file(GLOB_RECURSE META_SINGLES_DEPENDS "${META_ROOT_DIR}/headers/*.hpp")
add_custom_command(OUTPUT "${META_SINGLES_OUTPUT}"
COMMAND "${PYTHON_EXECUTABLE}" ".ci/build_singles.py" "${META_SINGLES_INPUT}" "${META_SINGLES_OUTPUT}"
COMMAND "${Python3_EXECUTABLE}" "singles/scripts/build_singles.py" "${META_SINGLES_INPUT}" "${META_SINGLES_OUTPUT}"
DEPENDS ${META_SINGLES_DEPENDS}
WORKING_DIRECTORY "${META_ROOT_DIR}")