Skip to content

Commit

Permalink
Merge pull request #248 from qicosmos/struct_pb
Browse files Browse the repository at this point in the history
  • Loading branch information
qicosmos authored May 15, 2024
2 parents 191c82e + 2bc1b89 commit fccdecf
Show file tree
Hide file tree
Showing 21 changed files with 3,639 additions and 30 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/clang-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Clang Format Diff

on:
push:
branches: [ master]
branches: [ master, struct_pb ]
pull_request:
branches: [ master]
branches: [ master, struct_pb ]

jobs:
build:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/linux-clang.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Ubuntu (clang)

on:
push:
branches: [ master]
branches: [ master, struct_pb ]
pull_request:
branches: [ master]
branches: [ master, struct_pb ]

jobs:
build:
Expand Down
9 changes: 6 additions & 3 deletions .github/workflows/linux-gcc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Ubuntu (gcc)

on:
push:
branches: [ master]
branches: [ master, struct_pb ]
pull_request:
branches: [ master]
branches: [ master, struct_pb ]

jobs:
ubuntu_gcc:
Expand All @@ -21,8 +21,11 @@ jobs:
- name: checkout gcc version
run: gcc --version

- name: Install Protobuf and Dev Package
run: sudo apt-get update && sudo apt-get install -y protobuf-compiler libprotobuf-dev

- name: configure cmake
run: CXX=g++ CC=gcc cmake -B ${{ github.workspace }}/build -DCMAKE_BUILD_TYPE=${{ matrix.mode }} -DCMAKE_CXX_STANDARD=${{ matrix.cpp_version }}
run: CXX=g++ CC=gcc cmake -B ${{ github.workspace }}/build -DCMAKE_BUILD_TYPE=${{ matrix.mode }} -DHAS_PROTOBUF=ON -DCMAKE_CXX_STANDARD=${{ matrix.cpp_version }}

- name: build project
run: cmake --build ${{ github.workspace }}/build --config ${{ matrix.mode }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: macOS Monterey 12

on:
push:
branches: [ master]
branches: [ master, struct_pb ]
pull_request:
branches: [ master]
branches: [ master, struct_pb ]

jobs:
build:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: Windows Server 2022

on:
on:
push:
branches: [ master]
branches: [ master, struct_pb ]
pull_request:
branches: [ master]
branches: [ master, struct_pb ]

jobs:
build:
Expand Down
35 changes: 34 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
cmake_minimum_required(VERSION 2.15)
project(iguana)

message(STATUS "C++ Compiler Version: ${CMAKE_CXX_COMPILER_VERSION}")

if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++17")
add_compile_options(/utf-8)
Expand Down Expand Up @@ -35,6 +37,8 @@ message(STATUS "C++ standard: ${CMAKE_CXX_STANDARD}")

add_definitions(-DTHROW_UNKNOWN_KEY)

add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/bigobj>")

option(ENABLE_SEQUENTIAL_PARSE "parse json sequential more efficient if the json fields sequences are the same with struct fields" OFF)
if (${ENABLE_SEQUENTIAL_PARSE})
ADD_DEFINITIONS(-DSEQUENTIAL_PARSE)
Expand Down Expand Up @@ -82,6 +86,9 @@ set(YAMLBENCH benchmark/yaml_benchmark.cpp)
set(TEST_NOTHROW test/test_yaml_nothrow.cpp)
set(TEST_UTIL test/test_util.cpp)
set(TEST_XMLNOTHROW test/test_xml_nothrow.cpp)
set(TEST_PB test/test_pb.cpp)
set(TEST_PROTO test/test_proto3.cpp)
set(PB_BENCHMARK benchmark/pb_benchmark.cpp)

add_executable(json_example ${JSON_EXAMPLE})
add_executable(json_benchmark ${JSONBENCHMARK})
Expand All @@ -97,6 +104,31 @@ add_executable(test_yaml ${TEST_YAML})
add_executable(yaml_benchmark ${YAMLBENCH})
add_executable(test_nothrow ${TEST_NOTHROW})
add_executable(test_util ${TEST_UTIL})
add_executable(test_pb ${TEST_PB})

option(HAS_PROTOBUF "import protobuf" OFF)
if(HAS_PROTOBUF)
find_package(Protobuf REQUIRED)
if(Protobuf_FOUND)
message(STATUS "Found Protobuf: ${Protobuf_VERSION}")
else()
message(STATUS "Protobuf not found")
endif()

include_directories(${Protobuf_INCLUDE_DIRS})
include_directories(${CMAKE_CURRENT_BINARY_DIR})
set(PROTO_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/test/proto)
file(GLOB PROTO_FILES ${PROTO_SRC_DIR}/*.proto)

protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS ${PROTO_FILES})
message(STATUS "Proto source files: ${PROTO_SRCS}")
message(STATUS "Proto header files: ${PROTO_HDRS}")

add_executable(pb_benchmark ${PB_BENCHMARK} ${PROTO_SRCS})
target_link_libraries(pb_benchmark ${Protobuf_LIBRARIES})
add_executable(test_proto ${PROTO_SRCS} ${TEST_PROTO})
target_link_libraries(test_proto ${Protobuf_LIBRARIES})
endif()

# unit test
option(BUILD_UNIT_TESTS "Build unit tests" ON)
Expand All @@ -121,4 +153,5 @@ add_test(NAME test_xml COMMAND test_xml)
add_test(NAME test_yaml COMMAND test_yaml)
add_test(NAME test_nothrow COMMAND test_nothrow)
add_test(NAME test_util COMMAND test_util)
add_test(NAME test_xml_nothrow COMMAND test_xml_nothrow)
add_test(NAME test_xml_nothrow COMMAND test_xml_nothrow)
add_test(NAME test_pb COMMAND test_pb)
Loading

0 comments on commit fccdecf

Please sign in to comment.