mirror of
https://codeberg.org/DawnMagnet/reflect-cpp
synced 2026-12-06 18:56:19 +08:00
ci
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
name: test
|
||||
|
||||
on: [ push, pull_request ]
|
||||
|
||||
jobs:
|
||||
linux-gcc:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: true
|
||||
- name: Run vcpkg
|
||||
uses: lukka/run-vcpkg@v11
|
||||
- name: install dependencies
|
||||
run: |
|
||||
sudo apt update
|
||||
sudo apt install -y g++
|
||||
- name: Run test
|
||||
run: |
|
||||
g++ --version
|
||||
cmake -S . -B build -DREFLECTCPP_BUILD_TESTS=ON -DREFLECTCPP_JSON=ON -DREFLECTCPP_FLATBUFFERS=ON
|
||||
cmake --build build -j 4
|
||||
./build/tests/flatbuffers/reflect-cpp-flatbuffers-tests
|
||||
./build/tests/json/reflect-cpp-json-tests
|
||||
|
||||
linux-clang:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: true
|
||||
- name: Run vcpkg
|
||||
uses: lukka/run-vcpkg@v11
|
||||
- name: install dependencies
|
||||
run: |
|
||||
sudo apt update
|
||||
sudo apt install -y clang
|
||||
- name: Run test
|
||||
run: |
|
||||
clang --version
|
||||
cmake -S . -B build -DREFLECTCPP_BUILD_TESTS=ON -DREFLECTCPP_JSON=ON -DREFLECTCPP_FLATBUFFERS=ON
|
||||
cmake --build build -j 4
|
||||
./build/tests/flatbuffers/reflect-cpp-flatbuffers-tests
|
||||
./build/tests/json/reflect-cpp-json-tests
|
||||
|
||||
windows-msvc:
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: true
|
||||
- name: Run vcpkg
|
||||
uses: lukka/run-vcpkg@v11
|
||||
- uses: ilammy/msvc-dev-cmd@v1
|
||||
with:
|
||||
vsversion: '2022'
|
||||
- name: Run test
|
||||
run: |
|
||||
cl
|
||||
cmake -S . -B build -DREFLECTCPP_BUILD_TESTS=ON -DREFLECTCPP_JSON=ON -DREFLECTCPP_FLATBUFFERS=ON
|
||||
cmake --build build --config Release
|
||||
.\build\tests\flatbuffers\Release\reflect-cpp-flatbuffers-tests.exe
|
||||
.\build\tests\json\Release\reflect-cpp-json-tests.exe
|
||||
@@ -43,3 +43,4 @@
|
||||
# Output files
|
||||
*.json
|
||||
*.fb
|
||||
!vcpkg.json
|
||||
@@ -0,0 +1,3 @@
|
||||
[submodule "vcpkg"]
|
||||
path = vcpkg
|
||||
url = https://github.com/microsoft/vcpkg.git
|
||||
+26
-6
@@ -1,12 +1,32 @@
|
||||
cmake_minimum_required(VERSION 3.4)
|
||||
cmake_minimum_required(VERSION 3.15)
|
||||
|
||||
set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_SOURCE_DIR}/vcpkg/scripts/buildsystems/vcpkg.cmake CACHE STRING "Vcpkg toolchain file")
|
||||
|
||||
project(reflectcpp)
|
||||
|
||||
include_directories(
|
||||
"include"
|
||||
)
|
||||
option(REFLECTCPP_JSON "Enable JSON support" OFF)
|
||||
option(REFLECTCPP_FLATBUFFERS "Enable FlatBuffers support" OFF)
|
||||
|
||||
add_library(reflectcpp INTERFACE)
|
||||
|
||||
target_include_directories(reflectcpp INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
||||
|
||||
if (REFLECTCPP_JSON)
|
||||
find_package(yyjson CONFIG REQUIRED)
|
||||
target_link_libraries(reflectcpp INTERFACE yyjson::yyjson)
|
||||
endif ()
|
||||
|
||||
if (REFLECTCPP_FLATBUFFERS)
|
||||
find_package(flatbuffers CONFIG REQUIRED)
|
||||
target_link_libraries(reflectcpp INTERFACE flatbuffers::flatbuffers)
|
||||
endif ()
|
||||
|
||||
add_library(reflectcpp SHARED "src/yyjson.c")
|
||||
add_library(reflectcpp_static STATIC "src/yyjson.c")
|
||||
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -O2")
|
||||
|
||||
|
||||
option(REFLECTCPP_BUILD_TESTS "Build tests" OFF)
|
||||
|
||||
if (REFLECTCPP_BUILD_TESTS)
|
||||
add_subdirectory(tests)
|
||||
endif ()
|
||||
@@ -363,48 +363,32 @@ The following compilers are supported:
|
||||
|
||||
If you **do not** need JSON support or you want to link YYJSON yourself, then reflect-cpp is header-only. Simply copy the contents of the folder `include` into your source repository or add it to your include path.
|
||||
|
||||
### Option 2: Include source files into your own build
|
||||
### Option 2 Compilation using cmake
|
||||
|
||||
Simply copy the contents of the folder `include` into your source repository or add it to your include path and also add `src/yyjson.c` to your source files for compilation.
|
||||
Boostrap vcpkg:
|
||||
|
||||
If you need support for other serialization formats like flexbuffers, you should also include and link the respective libraries, as listed in the previous section.
|
||||
|
||||
### Option 3: Compilation using cmake
|
||||
|
||||
For clang and GCC:
|
||||
|
||||
```
|
||||
mkdir build
|
||||
cd build
|
||||
cmake ..
|
||||
make -j4
|
||||
```bash
|
||||
git submodule update --init
|
||||
./vcpkg/bootstrap-vcpkg.sh # Linux
|
||||
./vcpkg/bootstrap-vcpkg.bat # Windows
|
||||
```
|
||||
|
||||
For MSVC replace `make -j4` with:
|
||||
Build:
|
||||
|
||||
```bash
|
||||
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DREFLECTCPP_JSON=ON -DREFLECTCPP_FLATBUFFERS=ON
|
||||
cmake --build build -j 4 # Linux
|
||||
cmake --build build --config Release # Windows
|
||||
```
|
||||
cmake --build . --config Release
|
||||
```
|
||||
|
||||
|
||||
## Compiling the tests
|
||||
|
||||
To compile the tests, do the following:
|
||||
|
||||
For clang and GCC:
|
||||
|
||||
```
|
||||
cd tests/json
|
||||
mkdir build
|
||||
cd build
|
||||
cmake ..
|
||||
make -j4
|
||||
```
|
||||
|
||||
For MSVC replace `make -j4` with:
|
||||
|
||||
```
|
||||
cmake --build . --config Release
|
||||
cmake -S . -B build -DREFLECTCPP_BUILD_TESTS=ON -DREFLECTCPP_JSON=ON -DREFLECTCPP_FLATBUFFERS=ON
|
||||
cmake --build build -j 4 # Linux
|
||||
cmake --build build --config Release # Windows
|
||||
```
|
||||
|
||||
|
||||
|
||||
-7690
File diff suppressed because it is too large
Load Diff
-9201
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,16 @@
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -O2")
|
||||
|
||||
if (MSVC)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std:c++20")
|
||||
else()
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++20 -Wall -Wno-sign-compare -Wno-missing-braces -Wno-psabi -pthread -fno-strict-aliasing -fwrapv -O2 -ftemplate-backtrace-limit=0 -fsanitize=undefined")
|
||||
endif()
|
||||
|
||||
|
||||
if (REFLECTCPP_JSON)
|
||||
add_subdirectory(json)
|
||||
endif ()
|
||||
|
||||
if (REFLECTCPP_FLATBUFFERS)
|
||||
add_subdirectory(flatbuffers)
|
||||
endif ()
|
||||
@@ -0,0 +1,7 @@
|
||||
project(reflect-cpp-json-tests)
|
||||
|
||||
file(GLOB_RECURSE SOURCES "*.cpp")
|
||||
|
||||
add_executable(reflect-cpp-flatbuffers-tests ${SOURCES})
|
||||
|
||||
target_link_libraries(reflect-cpp-flatbuffers-tests PRIVATE reflectcpp)
|
||||
@@ -17,7 +17,7 @@ Compile the tests:
|
||||
Run the tests:
|
||||
|
||||
```
|
||||
./build/reflect-cpp-tests
|
||||
./build/reflect-cpp-flatbuffers-tests
|
||||
```
|
||||
|
||||
To run the scripts, you may have to run `chmod +x build_docker.sh` and `chmod +x compile.sh` first.
|
||||
@@ -1,56 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.4)
|
||||
|
||||
project(reflect-cpp-tests)
|
||||
|
||||
include_directories(
|
||||
"../../include"
|
||||
"../../../flatbuffers/include"
|
||||
)
|
||||
|
||||
add_executable(
|
||||
reflect-cpp-tests
|
||||
"tests.cpp"
|
||||
"test_all_of.cpp"
|
||||
"test_anonymous_fields.cpp"
|
||||
"test_box.cpp"
|
||||
"test_custom_class1.cpp"
|
||||
"test_custom_class2.cpp"
|
||||
"test_custom_class3.cpp"
|
||||
"test_custom_constructor.cpp"
|
||||
"test_deque.cpp"
|
||||
"test_field_variant.cpp"
|
||||
"test_flatten_anonymous.cpp"
|
||||
"test_forward_list.cpp"
|
||||
"test_list.cpp"
|
||||
"test_literal.cpp"
|
||||
"test_map.cpp"
|
||||
"test_monster_example1.cpp"
|
||||
"test_monster_example2.cpp"
|
||||
"test_multimap.cpp"
|
||||
"test_multiset.cpp"
|
||||
"test_optional_fields.cpp"
|
||||
"test_readme_example.cpp"
|
||||
"test_ref.cpp"
|
||||
"test_save_load.cpp"
|
||||
"test_set.cpp"
|
||||
"test_string_map.cpp"
|
||||
"test_string_unordered_map.cpp"
|
||||
"test_tagged_union.cpp"
|
||||
"test_unique_ptr.cpp"
|
||||
"test_unique_ptr2.cpp"
|
||||
"test_unordered_map.cpp"
|
||||
"test_unordered_multimap.cpp"
|
||||
"test_unordered_multiset.cpp"
|
||||
"test_unordered_set.cpp"
|
||||
"test_variant.cpp"
|
||||
"../../src/yyjson.c"
|
||||
)
|
||||
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -O2")
|
||||
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++20 -Wall -Wno-sign-compare -Wno-missing-braces -Wno-psabi -pthread -fno-strict-aliasing -fwrapv -O2 -ftemplate-backtrace-limit=0 -fsanitize=undefined")
|
||||
|
||||
target_link_libraries(
|
||||
reflect-cpp-tests
|
||||
/home/reflectcpp/flatbuffers/build/libflatbuffers.a
|
||||
)
|
||||
@@ -1,25 +0,0 @@
|
||||
FROM ubuntu:22.04
|
||||
|
||||
ENV TZ=Europe/Berlin
|
||||
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
|
||||
|
||||
RUN useradd reflectcpp
|
||||
|
||||
RUN apt-get update
|
||||
RUN apt-get install -y git cmake
|
||||
RUN apt install gcc-11 g++-11
|
||||
|
||||
WORKDIR /home/reflectcpp
|
||||
|
||||
RUN git clone https://github.com/google/flatbuffers.git
|
||||
WORKDIR /home/reflectcpp/flatbuffers
|
||||
RUN git checkout v23.5.26
|
||||
RUN mkdir build
|
||||
WORKDIR /home/reflectcpp/flatbuffers/build
|
||||
RUN cmake .. -DCMAKE_C_COMPILER=gcc-11 -DCMAKE_CXX_COMPILER=g++-11
|
||||
RUN make
|
||||
|
||||
WORKDIR /home/reflectcpp
|
||||
COPY compile_on_docker.sh .
|
||||
|
||||
USER reflectcpp
|
||||
@@ -1,3 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
docker build --tag=reflectcpp_test_flexbuffers .
|
||||
@@ -1,3 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
docker run -v $PWD/../../:"/home/reflectcpp/reflect-cpp" --rm -it -t reflectcpp_test_flexbuffers bash compile_on_docker.sh
|
||||
@@ -1,5 +0,0 @@
|
||||
cd reflect-cpp/tests/flexbuffers
|
||||
mkdir build
|
||||
cd build
|
||||
cmake .. -DCMAKE_C_COMPILER=gcc-11 -DCMAKE_CXX_COMPILER=g++-11
|
||||
make -j4
|
||||
@@ -1,85 +1,7 @@
|
||||
cmake_minimum_required(VERSION 3.4)
|
||||
project(reflect-cpp-json-tests)
|
||||
|
||||
project(reflect-cpp-tests)
|
||||
file(GLOB_RECURSE SOURCES "*.cpp")
|
||||
|
||||
include_directories(
|
||||
"../../include"
|
||||
)
|
||||
|
||||
add_executable(
|
||||
reflect-cpp-tests
|
||||
"tests.cpp"
|
||||
"test_all_of.cpp"
|
||||
"test_alphanumeric_map.cpp"
|
||||
"test_alphanumeric_unordered_map.cpp"
|
||||
"test_anonymous_fields.cpp"
|
||||
"test_any_of.cpp"
|
||||
"test_array.cpp"
|
||||
"test_as.cpp"
|
||||
"test_as2.cpp"
|
||||
"test_as_flatten.cpp"
|
||||
"test_box.cpp"
|
||||
"test_custom_class1.cpp"
|
||||
"test_custom_class2.cpp"
|
||||
"test_custom_class3.cpp"
|
||||
"test_custom_class4.cpp"
|
||||
"test_custom_constructor.cpp"
|
||||
"test_default_values.cpp"
|
||||
"test_deque.cpp"
|
||||
"test_email.cpp"
|
||||
"test_enum.cpp"
|
||||
"test_error_messages.cpp"
|
||||
"test_field_variant.cpp"
|
||||
"test_flag_enum.cpp"
|
||||
"test_flag_enum_with_int.cpp"
|
||||
"test_flatten.cpp"
|
||||
"test_flatten_anonymous.cpp"
|
||||
"test_forward_list.cpp"
|
||||
"test_list.cpp"
|
||||
"test_literal.cpp"
|
||||
"test_literal_map.cpp"
|
||||
"test_literal_unordered_map.cpp"
|
||||
"test_map.cpp"
|
||||
"test_map_with_key_validation.cpp"
|
||||
"test_meta_fields.cpp"
|
||||
"test_monster_example.cpp"
|
||||
"test_move_replace.cpp"
|
||||
"test_multimap.cpp"
|
||||
"test_multiset.cpp"
|
||||
"test_one_of.cpp"
|
||||
"test_optional_fields.cpp"
|
||||
"test_readme_example.cpp"
|
||||
"test_ref.cpp"
|
||||
"test_replace.cpp"
|
||||
"test_replace2.cpp"
|
||||
"test_replace_flatten.cpp"
|
||||
"test_replace_flatten2.cpp"
|
||||
"test_replace_with_other_struct.cpp"
|
||||
"test_replace_with_other_struct2.cpp"
|
||||
"test_result.cpp"
|
||||
"test_save_load.cpp"
|
||||
"test_set.cpp"
|
||||
"test_size.cpp"
|
||||
"test_string_map.cpp"
|
||||
"test_string_unordered_map.cpp"
|
||||
"test_tagged_union.cpp"
|
||||
"test_tagged_union2.cpp"
|
||||
"test_timestamp.cpp"
|
||||
"test_unique_ptr.cpp"
|
||||
"test_unique_ptr2.cpp"
|
||||
"test_unordered_map.cpp"
|
||||
"test_unordered_multimap.cpp"
|
||||
"test_unordered_multiset.cpp"
|
||||
"test_unordered_set.cpp"
|
||||
"test_variant.cpp"
|
||||
"../../src/yyjson.c"
|
||||
)
|
||||
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -O2")
|
||||
|
||||
if (MSVC)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std:c++20")
|
||||
else()
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++20 -Wall -Wno-sign-compare -Wno-missing-braces -Wno-psabi -pthread -fno-strict-aliasing -fwrapv -O2 -ftemplate-backtrace-limit=0 -fsanitize=undefined")
|
||||
endif()
|
||||
add_executable(reflect-cpp-json-tests ${SOURCES})
|
||||
|
||||
target_link_libraries(reflect-cpp-json-tests PRIVATE reflectcpp)
|
||||
|
||||
Submodule
+1
Submodule vcpkg added at 50bffcc62d
+18
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"name" : "reflectcpp",
|
||||
"version-string" : "1.0.0",
|
||||
"builtin-baseline" : "50bffcc62d7f6571eb32bc1a0b1807e77af1166c",
|
||||
"dependencies" : [ {
|
||||
"name" : "flatbuffers",
|
||||
"version>=" : "23.5.26#1"
|
||||
}, {
|
||||
"name" : "vcpkg-cmake-config",
|
||||
"version>=" : "2022-02-06#1"
|
||||
}, {
|
||||
"name" : "vcpkg-cmake",
|
||||
"version>=" : "2023-05-04"
|
||||
}, {
|
||||
"name" : "yyjson",
|
||||
"version>=" : "0.8.0"
|
||||
} ]
|
||||
}
|
||||
Reference in New Issue
Block a user