Commit a3ba7c60 authored by tqcq's avatar tqcq
Browse files

feat update rpc_core

parent b412e7e1
Loading
Loading
Loading
Loading

3party/rpc_core/.clang-format

deleted100644 → 0
+0 −5
Original line number Diff line number Diff line
Language: Cpp
BasedOnStyle: Google
ColumnLimit: 150
AllowShortFunctionsOnASingleLine: Empty
AllowShortLambdasOnASingleLine: Empty
+0 −29
Original line number Diff line number Diff line
name: build

on:
  push:
    paths-ignore:
      - '**.md'
  pull_request:
    paths-ignore:
      - '**.md'

jobs:
  Linux:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3

      - name: CMake
        run: |
          mkdir build && cd build
          cmake -DCMAKE_BUILD_TYPE=Debug -DRPC_CORE_TEST_PLUGIN=ON ..

      - name: Init thirdparty
        run: cd build && make rpc_core_test_init

      - name: Build
        run: cd build && make -j2

      - name: Run
        run: cd build && ./rpc_core_test

3party/rpc_core/.gitignore

deleted100644 → 0
+0 −14
Original line number Diff line number Diff line
build/

# clion
.idea/
cmake-build-*/

# qt creator
CMakeLists.txt.user

# vscode
.vscode/

# thirdparty
/thirdparty/
+59 −39
Original line number Diff line number Diff line
@@ -2,6 +2,11 @@ cmake_minimum_required(VERSION 3.5)

project(rpc_core CXX)

# config
option(RPC_CORE_SERIALIZE_USE_CUSTOM "" "")
option(RPC_CORE_SERIALIZE_USE_NLOHMANN_JSON "" ON)

# test
option(RPC_CORE_BUILD_TEST "" OFF)
option(RPC_CORE_TEST_PLUGIN "" OFF)
option(RPC_CORE_TEST_LINK_PTHREAD "" OFF)
@@ -16,15 +21,26 @@ add_compile_options(-Wall -Wunused-parameter)
add_library(${PROJECT_NAME} INTERFACE)
target_include_directories(${PROJECT_NAME} INTERFACE include)

if(RPC_CORE_SERIALIZE_USE_CUSTOM)
  target_compile_definitions(
    ${PROJECT_NAME}
    INTERFACE -DRPC_CORE_SERIALIZE_USE_CUSTOM="${RPC_CORE_SERIALIZE_USE_CUSTOM}"
  )
endif()

if(RPC_CORE_SERIALIZE_USE_NLOHMANN_JSON)
  target_compile_definitions(${PROJECT_NAME}
                             INTERFACE -DRPC_CORE_SERIALIZE_USE_NLOHMANN_JSON)
endif()

if(RPC_CORE_BUILD_TEST)
    set(EXAMPLE_COMPILE_DEFINE
            ANDROID_STANDALONE
            RPC_CORE_LOG_SHOW_DEBUG
  set(EXAMPLE_COMPILE_DEFINE ANDROID_STANDALONE RPC_CORE_LOG_SHOW_DEBUG
                             # RPC_CORE_LOG_SHOW_VERBOSE
  )

  set(TARGET_NAME ${PROJECT_NAME}_test)
    file(GLOB SRCS test/main.cpp test/test_rpc.cpp test/test_serialize.cpp test/test_data_packer.cpp)
  file(GLOB SRCS test/main.cpp test/test_rpc.cpp test/test_serialize.cpp
       test/test_data_packer.cpp)
  add_executable(${TARGET_NAME})
  if(RPC_CORE_TEST_LINK_PTHREAD)
    # some linux platform need link -pthread for std::future api
@@ -36,19 +52,23 @@ if (RPC_CORE_BUILD_TEST)
  if(RPC_CORE_TEST_PLUGIN)
    list(APPEND SRCS test/test_plugin.cpp)
    target_compile_definitions(${TARGET_NAME} PRIVATE "RPC_CORE_TEST_PLUGIN")
        add_custom_target(${TARGET_NAME}_init
    add_custom_target(
      ${TARGET_NAME}_init
      # clear dir
      COMMAND rm -rf ${CMAKE_CURRENT_LIST_DIR}/thirdparty
      # json
      COMMAND mkdir -p ${CMAKE_CURRENT_LIST_DIR}/thirdparty/nlohmann
                COMMAND curl -L -o ${CMAKE_CURRENT_LIST_DIR}/thirdparty/nlohmann/json.hpp https://github.com/nlohmann/json/releases/download/v3.11.2/json.hpp
      COMMAND
        curl -L -o ${CMAKE_CURRENT_LIST_DIR}/thirdparty/nlohmann/json.hpp
        https://github.com/nlohmann/json/releases/download/v3.11.2/json.hpp
      # flatbuffers
                COMMAND git clone https://github.com/google/flatbuffers.git --depth=1 --branch=v23.1.21 ${CMAKE_CURRENT_LIST_DIR}/thirdparty/flatbuffers
                WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
        )
      COMMAND git clone https://github.com/google/flatbuffers.git --depth=1
              --branch=v23.1.21 ${CMAKE_CURRENT_LIST_DIR}/thirdparty/flatbuffers
      WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR})

    target_include_directories(${TARGET_NAME} PRIVATE thirdparty)
        target_include_directories(${TARGET_NAME} PRIVATE thirdparty/flatbuffers/include)
    target_include_directories(${TARGET_NAME}
                               PRIVATE thirdparty/flatbuffers/include)
  endif()
  target_sources(${TARGET_NAME} PRIVATE ${SRCS})
endif()
+21 −0
Original line number Diff line number Diff line
MIT License

Copyright (c) 2023-2024 liushuai

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.
Loading