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

[struct_pack][feat] support c++17 #392

Merged
merged 64 commits into from
Aug 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
401f9f0
[struct_pack] remove constexpr
poor-circle Jul 27, 2023
28fa7ca
[struct_pack] compatible likely/unlikely
poor-circle Jul 27, 2023
dc0d438
[struct_pack] don't include tuplet:tuple in cpp17
poor-circle Jul 27, 2023
f565266
[struct_pack] bench/test/examples support cpp17
poor-circle Jul 27, 2023
7e798de
[struct_pack] remove spaceship operator for cpp17
poor-circle Jul 27, 2023
92bccba
[struct_pack] remove auto in function parameters
poor-circle Jul 27, 2023
731b38a
use void_t/constexpr bool/static_assert to simulate concept when -std…
poor-circle Jul 28, 2023
0338071
fix gcc
poor-circle Jul 28, 2023
6318e4e
remove concept
poor-circle Jul 29, 2023
a8a171b
remove requires
poor-circle Jul 29, 2023
8b9c89b
remove requires
poor-circle Jul 29, 2023
a2caad5
remove std::remove_cvref_t
poor-circle Jul 29, 2023
b10c413
remove char8_t
poor-circle Jul 29, 2023
6914596
remove unsigned concept
poor-circle Jul 29, 2023
4a3d5bd
remove consteval
poor-circle Jul 29, 2023
264fd7c
remove std::same_as
poor-circle Jul 29, 2023
f2d1558
fixfix
poor-circle Jul 29, 2023
74f6fb6
[breakchange] use uint64_t to instead struct_pack::serialize_config
poor-circle Jul 30, 2023
b3b3efe
remove uneval inline lambda
poor-circle Jul 30, 2023
92f73ea
fix fix
poor-circle Jul 30, 2023
bc32a5f
fix trivially_copyable_container
poor-circle Jul 30, 2023
8cebad8
fix typo
poor-circle Jul 30, 2023
d376b89
use enable_if_t to instead concept
poor-circle Jul 30, 2023
2ae38c9
fix struct_pack_benchmark
poor-circle Jul 30, 2023
ed594f0
add enable_if_t
poor-circle Jul 30, 2023
c9f2a8e
remove default operator ==
poor-circle Jul 30, 2023
02b5112
fix a lot
poor-circle Jul 30, 2023
33a6bba
fixfix
poor-circle Jul 30, 2023
0430c05
fix trivial copy container
poor-circle Jul 30, 2023
5f10e0e
fix format
poor-circle Jul 31, 2023
479f4d9
fix bench
poor-circle Jul 31, 2023
70ac762
fix string_literal
poor-circle Jul 31, 2023
f0643d0
fix explicit template paramters in lamdba
poor-circle Jul 31, 2023
d256de4
fix format
poor-circle Jul 31, 2023
168d0c3
fix likely/unlikely
poor-circle Jul 31, 2023
2cc5160
move <bit> header file
poor-circle Jul 31, 2023
7921b97
fix likely
poor-circle Jul 31, 2023
d924251
fix msvc
poor-circle Jul 31, 2023
31e57b9
fix CMAKE
poor-circle Aug 1, 2023
bac6ab0
fix format
poor-circle Aug 1, 2023
befa8f5
fix ci
poor-circle Aug 1, 2023
9ac842f
fix action
poor-circle Aug 1, 2023
e531fbb
fix
poor-circle Aug 1, 2023
36553e3
fix
poor-circle Aug 1, 2023
25fee73
fix
poor-circle Aug 1, 2023
b7440b9
fix
poor-circle Aug 1, 2023
6b82868
fix again again again
poor-circle Aug 1, 2023
de89d8b
fix
poor-circle Aug 1, 2023
72fb9f0
fix
poor-circle Aug 1, 2023
c87e0e5
fix
poor-circle Aug 1, 2023
e3cfd40
fix
poor-circle Aug 1, 2023
b769fe2
fix
poor-circle Aug 1, 2023
4c7f0db
use clang-7
poor-circle Aug 1, 2023
7c73d26
fix
poor-circle Aug 1, 2023
8fe8741
fix
poor-circle Aug 1, 2023
626379e
try fix msvc
poor-circle Aug 1, 2023
0428c97
try fix 2
poor-circle Aug 1, 2023
0681a1d
fix
poor-circle Aug 1, 2023
f2c0d6a
fix
poor-circle Aug 1, 2023
755eb88
fix msvc test failed
poor-circle Aug 1, 2023
9d71277
fix msvc
poor-circle Aug 2, 2023
a40af62
fix format
poor-circle Aug 2, 2023
1ffd319
add doc
poor-circle Aug 2, 2023
bdfa2ec
fix readme
poor-circle Aug 2, 2023
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
43 changes: 40 additions & 3 deletions .github/workflows/ubuntu_clang.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Ubuntu 22.04 (clang)
name: Ubuntu (clang)

on:
push:
Expand Down Expand Up @@ -81,7 +81,7 @@ jobs:
CXX=clang++ CC=clang
cmake -B ${{github.workspace}}/build -G Ninja \
-DCMAKE_BUILD_TYPE=${{matrix.mode}} -DBUILD_WITH_LIBCXX=${{matrix.libcxx}} -DENABLE_SSL=${{matrix.ssl}} \
-DUSE_CCACHE=${{env.ccache}} \
-DUSE_CCACHE=${{env.ccache}} -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++\
-DBUILD_CORO_HTTP=OFF -DBUILD_CORO_IO=OFF -DBUILD_CORO_RPC=OFF -DBUILD_EASYLOG=OFF -DBUILD_STRUCT_JSON=OFF -DBUILD_STRUCT_XML=OFF -DBUILD_STRUCT_YAML=OFF -DBUILD_UTIL=OFF
- name: Build
run: cmake --build ${{github.workspace}}/build --config ${{matrix.mode}}
Expand Down Expand Up @@ -121,12 +121,49 @@ jobs:
-DCMAKE_BUILD_TYPE=${{matrix.mode}} \
-DBUILD_WITH_LIBCXX=${{matrix.libcxx}} \
-DENABLE_IO_URING=${{matrix.io_uring}} \
-DUSE_CCACHE=${{env.ccache}} \
-DUSE_CCACHE=${{env.ccache}} -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++\
-DBUILD_STRUCT_JSON=OFF -DBUILD_STRUCT_XML=OFF -DBUILD_STRUCT_PACK=OFF -DBUILD_STRUCT_PB=OFF -DBUILD_STRUCT_YAML=OFF -DBUILD_UTIL=OFF

- name: Build
run: cmake --build ${{github.workspace}}/build --config ${{matrix.mode}}

- name: Test
working-directory: ${{github.workspace}}/build
run: ctest -C ${{matrix.mode}} -j 1 -V

ubuntu_clang10:
strategy:
matrix:
mode: [ Release, Debug ]

runs-on: ubuntu-20.04

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install ninja-build tool
uses: seanmiddleditch/gha-setup-ninja@master

- name: Install clang-6
run: sudo apt-get install clang-7 clang++-7

- name: ccache
uses: hendrikmuhs/ccache-action@v1.2
with:
key: ${{ github.job }}-${{ matrix.mode}}

- name: Configure
run: |
CXX=clang++-7 CC=clang-7
cmake -B ${{github.workspace}}/build -G Ninja \
-DCMAKE_BUILD_TYPE=${{matrix.mode}} \
-DUSE_CCACHE=${{env.ccache}} -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ \
-DENABLE_CPP_20=OFF

- name: Build
run: cmake --build ${{github.workspace}}/build --config ${{matrix.mode}}

- name: Test
working-directory: ${{github.workspace}}/build
run: ctest -C ${{matrix.mode}} -j 1 -V
35 changes: 34 additions & 1 deletion .github/workflows/ubuntu_gcc.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Ubuntu 22.04 (gcc)
name: Ubuntu (gcc)

on:
push:
Expand Down Expand Up @@ -126,3 +126,36 @@ jobs:
- name: Test
working-directory: ${{github.workspace}}/build
run: ctest -C ${{matrix.mode}} -j 1 -V

ubuntu_gcc9:
strategy:
matrix:
mode: [ Release, Debug ]
runs-on: ubuntu-20.04

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install ninja-build tool
uses: seanmiddleditch/gha-setup-ninja@master

- name: ccache
uses: hendrikmuhs/ccache-action@v1.2
with:
key: ${{ github.job }}-${{ matrix.mode}}

- name: Configure
run: |
CXX=g++ CC=gcc
cmake -B ${{github.workspace}}/build -G Ninja \
-DCMAKE_BUILD_TYPE=${{matrix.mode}} \
-DUSE_CCACHE=${{env.ccache}} \
-DENABLE_CPP_20=OFF\

- name: Build
run: cmake --build ${{github.workspace}}/build --config ${{matrix.mode}}

- name: Test
working-directory: ${{github.workspace}}/build
run: ctest -C ${{matrix.mode}} -j 1 -V
34 changes: 34 additions & 0 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,37 @@ jobs:
- name: Test
working-directory: ${{github.workspace}}\build
run: ctest -C ${{matrix.mode}} -j 1 -V
windows_msvc_2019:
runs-on: windows-2019

strategy:
matrix:
mode: [ Release ] #[ Release, Debug ] #Debug not support ccache
#https://github.com/ccache/ccache/wiki/MS-Visual-Studio
#https://github.com/ccache/ccache/issues/1040
arch: [ amd64, x86 ] #[ amd64,x86 ]

steps:
- name: Checkout
uses: actions/checkout@v3
- name: Enable Developer Command Prompt
uses: ilammy/msvc-dev-cmd@v1.12.0
with:
arch: ${{ matrix.arch }}
- name: Install ninja-build tool
uses: seanmiddleditch/gha-setup-ninja@master
with:
version: 1.11.1
- name: latest ccache
run: choco install ccache
- name: ccache
uses: hendrikmuhs/ccache-action@v1.2
with:
key: ${{ github.job }}-${{ matrix.mode}}-arch-${{ matrix.arch}}
- name: Configure CMake
run: cmake -B ${{github.workspace}}\build -G Ninja -DCMAKE_BUILD_TYPE=${{ matrix.mode }} -DENABLE_SSL=${{matrix.ssl}} -DUSE_CCACHE=ON -DENABLE_CPP_20=OFF
- name: Build
run: cmake --build ${{github.workspace}}\build
- name: Test
working-directory: ${{github.workspace}}\build
run: ctest -C ${{matrix.mode}} -j 1 -V
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,4 @@ include(cmake/install.cmake)
include(cmake/config.cmake)
# add project's source such as unit test, example & benchmark
include(cmake/subdir.cmake)
include(cmake/platform.cmake)

16 changes: 13 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

[中文版](./website/docs/zh/guide/what_is_yalantinglibs.md)

yaLanTingLibs is a collection of C++20 libraries, now it contains struct_pack, struct_json, struct_xml, struct_yaml, struct_pb, easylog, coro_rpc, coro_http and async_simple, more and more cool libraries will be added into yaLanTingLibs(such as http.) in the future.
yaLanTingLibs is a collection of modern c++ util libraries, now it contains struct_pack, struct_json, struct_xml, struct_yaml, struct_pb, easylog, coro_rpc, coro_io, coro_http and async_simple, more and more cool libraries will be added into yaLanTingLibs in the future.

The target of yaLanTingLibs: provide very easy and high performance C++20 libraries for C++ developers, it can help to quickly build high performance applications.
The target of yaLanTingLibs: provide very easy and high performance modern C++ libraries for developers, it can help to quickly build high performance applications.

| OS (Compiler Version) | Status |
|------------------------------------------------|-----------------------------------------------------------------------------------------------------------|
Expand All @@ -25,12 +25,22 @@ The target of yaLanTingLibs: provide very easy and high performance C++20 librar
# Quick Start
## compiler requirements

make sure you have such compilers:
If your compiler don't support C++20, yalantinglibs will only compile the serialization libraries (struct_pack, struct_json, struct_xml, struct_yaml).
Make sure you have such compilers:

- g++9 above;
- clang++6 above (with stdlib = libc++-13/libstdc++-8 or later version);
- msvc 14.20 above;

Otherwise, yalantinglibs will compile all the libraries.
Make sure you have such compilers:

- g++10 above;
- clang++13 above (with stdlib = libc++-13/libstdc++-8 or later version);
- msvc 14.29 above;

You can also use cmake option `-DENABLE_CPP_20=ON` or `-DENABLE_CPP_20=OFF` to control it.

## Install & Compile

Yalantinglibs is a head-only library. You can just copy `./include/ylt` directory into your project. But we suggest you use cmake to install it.
Expand Down
25 changes: 20 additions & 5 deletions cmake/build.cmake
Original file line number Diff line number Diff line change
@@ -1,15 +1,28 @@
# Compile Standard
message(STATUS "-------------COMPILE Setting-------------")
set(CMAKE_CXX_STANDARD 20)

# CPP Standard
foreach(i ${CMAKE_CXX_COMPILE_FEATURES})
if (i STREQUAL cxx_std_20)
set(has_cxx_std_20 TRUE)
endif()
endforeach()
if (has_cxx_std_20)
option(ENABLE_CPP_20 "Enable CPP 20" ON)
else ()
option(ENABLE_CPP_20 "Enable CPP 20" OFF)
endif()
if (ENABLE_CPP_20)
set(CMAKE_CXX_STANDARD 20)
else()
set(CMAKE_CXX_STANDARD 17)
endif()
set(CMAKE_CXX_STANDARD_REQUIRED ON)
message(STATUS "CXX Standard: ${CMAKE_CXX_STANDARD}")

# Build Type
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release")
endif()
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")

# libc++ or libstdc++&clang
option(BUILD_WITH_LIBCXX "Build with libc++" OFF)
message(STATUS "BUILD_WITH_LIBCXX: ${BUILD_WITH_LIBCXX}")
Expand Down Expand Up @@ -42,7 +55,9 @@ endif ()

# --------------------- GCC
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fcoroutines")
if (ENABLE_CPP_20)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fcoroutines")
endif()
#-ftree-slp-vectorize with coroutine cause link error. disable it util gcc fix.
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fno-tree-slp-vectorize")
endif()
Expand Down
15 changes: 0 additions & 15 deletions cmake/platform.cmake

This file was deleted.

16 changes: 15 additions & 1 deletion cmake/subdir.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,23 @@ file(GLOB children src/*)
foreach(child ${children})
get_filename_component(subdir_name ${child} NAME)
string(TOUPPER ${subdir_name} subdir_name)
option(BUILD_${subdir_name} "BUILD_${subdir_name}" ON)
if (ENABLE_CPP_20)
option(BUILD_${subdir_name} "BUILD_${subdir_name}" ON)
else()
option(BUILD_${subdir_name} "BUILD_${subdir_name}" OFF)
endif()
endforeach()

if (NOT ENABLE_CPP_20)
Set(BUILD_STRUCT_PACK ON)
endif()

foreach(child ${children})
get_filename_component(subdir_name ${child} NAME)
string(TOUPPER ${subdir_name} subdir_name)
message(STATUS "BUILD_${subdir_name}: ${BUILD_${subdir_name}}")
endforeach()

foreach(child ${children})
get_filename_component(subdir_name ${child} NAME)
string(TOUPPER ${subdir_name} subdir_name)
Expand Down
Loading
Loading