mirror of
https://github.com/BlackMATov/meta.hpp.git
synced 2025-12-16 22:17:02 +07:00
initial commit
This commit is contained in:
19
.ci/build_coverage.sh
Executable file
19
.ci/build_coverage.sh
Executable file
@@ -0,0 +1,19 @@
|
|||||||
|
#!/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"
|
||||||
11
.ci/build_darwin.sh
Executable file
11
.ci/build_darwin.sh
Executable file
@@ -0,0 +1,11 @@
|
|||||||
|
#!/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)
|
||||||
11
.ci/build_linux.sh
Executable file
11
.ci/build_linux.sh
Executable file
@@ -0,0 +1,11 @@
|
|||||||
|
#!/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)
|
||||||
19
.ci/build_windows_x64.bat
Normal file
19
.ci/build_windows_x64.bat
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
@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%
|
||||||
19
.ci/build_windows_x86.bat
Normal file
19
.ci/build_windows_x86.bat
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
@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%
|
||||||
14
.github/workflows/coverage.yml
vendored
Normal file
14
.github/workflows/coverage.yml
vendored
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
name: coverage
|
||||||
|
|
||||||
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: macos-10.15
|
||||||
|
name: "coverage"
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Install lcov by Homebrew
|
||||||
|
run: brew install lcov
|
||||||
|
- name: Build && Test && Upload
|
||||||
|
run: .ci/build_coverage.sh
|
||||||
22
.github/workflows/darwin.yml
vendored
Normal file
22
.github/workflows/darwin.yml
vendored
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
name: darwin
|
||||||
|
|
||||||
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ${{matrix.config.os}}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
config:
|
||||||
|
# https://github.com/actions/virtual-environments/tree/main/images/macos
|
||||||
|
- { os: "macos-10.15", xcode: "10.3" }
|
||||||
|
- { os: "macos-10.15", xcode: "11.7" }
|
||||||
|
- { os: "macos-10.15", xcode: "12.4" }
|
||||||
|
name: "xcode-${{matrix.config.xcode}}"
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Select Xcode
|
||||||
|
run: sudo xcode-select --switch "/Applications/Xcode_${{matrix.config.xcode}}.app"
|
||||||
|
- name: Build && Test
|
||||||
|
run: .ci/build_darwin.sh
|
||||||
25
.github/workflows/linux.yml
vendored
Normal file
25
.github/workflows/linux.yml
vendored
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
name: linux
|
||||||
|
|
||||||
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ${{matrix.config.os}}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
config:
|
||||||
|
# https://github.com/actions/virtual-environments/tree/main/images/linux
|
||||||
|
- { os: "ubuntu-20.04", cc: "gcc-7", cxx: "g++-7" }
|
||||||
|
- { os: "ubuntu-20.04", cc: "gcc-8", cxx: "g++-8" }
|
||||||
|
- { os: "ubuntu-20.04", cc: "gcc-9", cxx: "g++-9" }
|
||||||
|
- { os: "ubuntu-20.04", cc: "gcc-10", cxx: "g++-10" }
|
||||||
|
- { os: "ubuntu-20.04", cc: "clang-8", cxx: "clang++-8" }
|
||||||
|
- { os: "ubuntu-20.04", cc: "clang-9", cxx: "clang++-9" }
|
||||||
|
- { os: "ubuntu-20.04", cc: "clang-10", cxx: "clang++-10" }
|
||||||
|
name: "${{matrix.config.cxx}}"
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Build && Test
|
||||||
|
run: .ci/build_linux.sh
|
||||||
|
env: { CC: "${{matrix.config.cc}}", CXX: "${{matrix.config.cxx}}" }
|
||||||
21
.github/workflows/windows.yml
vendored
Normal file
21
.github/workflows/windows.yml
vendored
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
name: windows
|
||||||
|
|
||||||
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ${{matrix.config.os}}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
config:
|
||||||
|
# https://github.com/actions/virtual-environments/tree/main/images/win
|
||||||
|
- { os: "windows-2016", vs: "Visual Studio 2017", arch: "x86" }
|
||||||
|
- { os: "windows-2016", vs: "Visual Studio 2017", arch: "x64" }
|
||||||
|
- { os: "windows-2019", vs: "Visual Studio 2019", arch: "x86" }
|
||||||
|
- { os: "windows-2019", vs: "Visual Studio 2019", arch: "x64" }
|
||||||
|
name: "${{matrix.config.vs}} ${{matrix.config.arch}}"
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Build && Test
|
||||||
|
run: .ci\build_windows_${{matrix.config.arch}}.bat
|
||||||
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
build/*
|
||||||
|
.vscode/*
|
||||||
|
CMakeLists.txt.user
|
||||||
20
CMakeLists.txt
Normal file
20
CMakeLists.txt
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
# 3.8 version is required for `cxx_std_17`
|
||||||
|
cmake_minimum_required(VERSION 3.8 FATAL_ERROR)
|
||||||
|
|
||||||
|
if(NOT DEFINED PROJECT_NAME)
|
||||||
|
set(BUILD_AS_STANDALONE ON)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
project(meta.hpp)
|
||||||
|
|
||||||
|
add_library(${PROJECT_NAME} INTERFACE)
|
||||||
|
target_compile_features(${PROJECT_NAME} INTERFACE cxx_std_17)
|
||||||
|
target_include_directories(${PROJECT_NAME} INTERFACE headers)
|
||||||
|
|
||||||
|
if(BUILD_AS_STANDALONE)
|
||||||
|
option(BUILD_WITH_UNTESTS "Build with unit tests" ON)
|
||||||
|
if(BUILD_WITH_UNTESTS)
|
||||||
|
enable_testing()
|
||||||
|
add_subdirectory(untests)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
21
LICENSE.md
Normal file
21
LICENSE.md
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (C) 2021, by Matvey Cherevko (blackmatov@gmail.com)
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
57
README.md
Normal file
57
README.md
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
# meta.hpp
|
||||||
|
|
||||||
|
> C++17 tiny reflection library
|
||||||
|
|
||||||
|
[![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%2B17-yellow
|
||||||
|
[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%2B17
|
||||||
|
[license]: https://en.wikipedia.org/wiki/MIT_License
|
||||||
|
|
||||||
|
[meta]: https://github.com/BlackMATov/meta.hpp
|
||||||
|
|
||||||
|
## Requirements
|
||||||
|
|
||||||
|
- [gcc](https://www.gnu.org/software/gcc/) **>= 7**
|
||||||
|
- [clang](https://clang.llvm.org/) **>= 5.0**
|
||||||
|
- [msvc](https://visualstudio.microsoft.com/) **>= 2017**
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
[meta.hpp][meta] is a header-only library. All you need to do is copy the headers files from `headers` directory into your project and include them:
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
#include "meta.hpp/meta.hpp"
|
||||||
|
```
|
||||||
|
|
||||||
|
Also, you can add the root repository directory to your [cmake](https://cmake.org) project:
|
||||||
|
|
||||||
|
```cmake
|
||||||
|
add_subdirectory(external/meta.hpp)
|
||||||
|
target_link_libraries(your_project_target meta.hpp)
|
||||||
|
```
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
> coming soon
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
> coming soon
|
||||||
|
|
||||||
|
## [License (MIT)](./LICENSE.md)
|
||||||
11
headers/meta.hpp/meta.hpp
Normal file
11
headers/meta.hpp/meta.hpp
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* This file is part of the "https://github.com/blackmatov/meta.hpp"
|
||||||
|
* For conditions of distribution and use, see copyright notice in LICENSE.md
|
||||||
|
* Copyright (C) 2021, by Matvey Cherevko (blackmatov@gmail.com)
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace meta_hpp
|
||||||
|
{
|
||||||
|
}
|
||||||
37
untests/CMakeLists.txt
Normal file
37
untests/CMakeLists.txt
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
project(meta.hpp.untests)
|
||||||
|
|
||||||
|
#
|
||||||
|
# coverage
|
||||||
|
#
|
||||||
|
|
||||||
|
option(BUILD_WITH_COVERAGE "Build with coverage" OFF)
|
||||||
|
if(BUILD_WITH_COVERAGE AND (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang"))
|
||||||
|
set(COVERAGE_FLAGS "--coverage")
|
||||||
|
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${COVERAGE_FLAGS}")
|
||||||
|
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${COVERAGE_FLAGS}")
|
||||||
|
set(CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} ${COVERAGE_FLAGS}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
#
|
||||||
|
# executable
|
||||||
|
#
|
||||||
|
|
||||||
|
file(GLOB_RECURSE UNTESTS_SOURCES "*.cpp" "*.hpp")
|
||||||
|
add_executable(${PROJECT_NAME} ${UNTESTS_SOURCES})
|
||||||
|
target_link_libraries(${PROJECT_NAME} meta.hpp)
|
||||||
|
|
||||||
|
target_compile_options(${PROJECT_NAME}
|
||||||
|
PRIVATE
|
||||||
|
$<$<CXX_COMPILER_ID:MSVC>:
|
||||||
|
/W4>
|
||||||
|
PRIVATE
|
||||||
|
$<$<CXX_COMPILER_ID:GNU>:
|
||||||
|
-Wall -Wextra -Wpedantic>
|
||||||
|
PRIVATE
|
||||||
|
$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>>:
|
||||||
|
-Weverything -Wno-unknown-warning-option
|
||||||
|
-Wconversion -Wimplicit-int-float-conversion
|
||||||
|
-Wno-c++98-compat-pedantic -Wno-ctad-maybe-unsupported
|
||||||
|
-Wno-float-equal -Wno-double-promotion -Wno-shadow-field-in-constructor>)
|
||||||
|
|
||||||
|
add_test(${PROJECT_NAME} ${PROJECT_NAME})
|
||||||
2
untests/doctest/doctest.cpp
Normal file
2
untests/doctest/doctest.cpp
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
|
||||||
|
#include "doctest.h"
|
||||||
6260
untests/doctest/doctest.h
Normal file
6260
untests/doctest/doctest.h
Normal file
File diff suppressed because it is too large
Load Diff
11
untests/doctest/doctest.hpp
Normal file
11
untests/doctest/doctest.hpp
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "doctest.h"
|
||||||
|
|
||||||
|
#define STATIC_CHECK(...)\
|
||||||
|
static_assert(__VA_ARGS__, #__VA_ARGS__);\
|
||||||
|
CHECK(__VA_ARGS__)
|
||||||
|
|
||||||
|
#define STATIC_CHECK_FALSE(...)\
|
||||||
|
static_assert(!(__VA_ARGS__), "!(" #__VA_ARGS__ ")");\
|
||||||
|
CHECK(!(__VA_ARGS__))
|
||||||
16
untests/meta_tests.cpp
Normal file
16
untests/meta_tests.cpp
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* This file is part of the "https://github.com/blackmatov/meta.hpp"
|
||||||
|
* For conditions of distribution and use, see copyright notice in LICENSE.md
|
||||||
|
* Copyright (C) 2021, by Matvey Cherevko (blackmatov@gmail.com)
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#include "meta_tests.hpp"
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
using namespace meta_hpp;
|
||||||
|
using namespace meta_tests;
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("meta") {
|
||||||
|
}
|
||||||
13
untests/meta_tests.hpp
Normal file
13
untests/meta_tests.hpp
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* This file is part of the "https://github.com/blackmatov/meta.hpp"
|
||||||
|
* For conditions of distribution and use, see copyright notice in LICENSE.md
|
||||||
|
* Copyright (C) 2021, by Matvey Cherevko (blackmatov@gmail.com)
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#include <meta.hpp/meta.hpp>
|
||||||
|
#include "doctest/doctest.hpp"
|
||||||
|
|
||||||
|
namespace meta_tests
|
||||||
|
{
|
||||||
|
using namespace meta_hpp;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user