Skip to content

Commit

Permalink
Merge pull request #23 from lkpworkspace/dev
Browse files Browse the repository at this point in the history
v0.8.2
  • Loading branch information
lkpworkspace authored Oct 23, 2023
2 parents b5063d5 + 2dcb95b commit 536e8cc
Show file tree
Hide file tree
Showing 87 changed files with 2,128 additions and 801 deletions.
7 changes: 2 additions & 5 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- uses: actions/checkout@v3
- run: sudo apt update
- run: sudo apt install build-essential cmake ninja-build
- run: sudo apt install libjsoncpp-dev libgflags-dev libgoogle-glog-dev libunwind-dev
- run: sudo apt install libjsoncpp-dev libgoogle-glog-dev libunwind-dev

- name: Setup Ninja
uses: ashutoshvarma/setup-ninja@master
Expand All @@ -28,12 +28,9 @@ jobs:

- name: Configure CMake
env:
# glog option:
# -DNDEBUG
# -DDCHECK_ALWAYS_ON
# unit test option:
# -fno-omit-frame-pointer -fsanitize=address -fsanitize=undefined
CXXFLAGS: ${{env.CXXFLAGS}} -DNDEBUG -fPIC -Wall -Wextra -Werror -pedantic-errors -Wswitch-default -Wfloat-equal -Wshadow -Wcast-qual -Wnon-virtual-dtor -Wold-style-cast -Woverloaded-virtual -Wsign-promo -Wsuggest-override
CXXFLAGS: ${{env.CXXFLAGS}} -Wall -Wextra -Werror -pedantic-errors -Wswitch-default -Wfloat-equal -Wshadow -Wcast-qual -Wnon-virtual-dtor -Wold-style-cast -Woverloaded-virtual -Wsign-promo -Wsuggest-override -Wextra-semi
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: |
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ build/
.vscode

launcher/launcher_config.h
test/performance_test_config.h
test/performance_test_config.h
myframe/export.h
myframe/config.h
62 changes: 30 additions & 32 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
cmake_minimum_required(VERSION 3.10)
project(myframe VERSION 0.8.1)

### gcc version
if (CMAKE_COMPILER_IS_GNUCC)
execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpfullversion -dumpversion
OUTPUT_VARIABLE GCC_VERSION)
string(REGEX MATCHALL "[0-9]+" GCC_VERSION_COMPONENTS ${GCC_VERSION})
list(GET GCC_VERSION_COMPONENTS 0 GCC_MAJOR)
list(GET GCC_VERSION_COMPONENTS 1 GCC_MINOR)
set(GCC_VERSION "${GCC_MAJOR}.${GCC_MINOR}")
endif ()

### cpp option
if (GCC_VERSION GREATER "8.0")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra-semi")
endif ()
project(myframe VERSION 0.8.2)

### option
option(GENERATE_EXAMPLE "generate example library" ON)
option(GENERATE_TEST "generate test exec" ON)
option(MYFRAME_USE_CV "Using conditional variables for thread communication" OFF)
option(MYFRAME_GENERATE_EXAMPLE "Generate example library" ON)
option(MYFRAME_GENERATE_TEST "Generate test executable program" ON)

### compile option
set(CMAKE_C_VISIBILITY_PRESET hidden)
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_VISIBILITY_INLINES_HIDDEN ON)
if (CMAKE_CXX_STANDARD_REQUIRED)
message(STATUS "Set cxx standard ${CMAKE_CXX_STANDARD}")
else()
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_STANDARD 17)
message(STATUS "Set default cxx standard 17")
endif()

### output path
set(MYFRAME_OUTPUT_ROOT "${CMAKE_BINARY_DIR}/output")
Expand All @@ -27,9 +26,13 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${MYFRAME_OUTPUT_ROOT}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${MYFRAME_OUTPUT_ROOT}/bin)

### install path
# set(CMAKE_INSTALL_PREFIX "$ENV{HOME}/${CMAKE_PROJECT_NAME}")
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "$ENV{HOME}/${CMAKE_PROJECT_NAME}" CACHE PATH "myframe default install prefix" FORCE)
message(STATUS "Set default install prefix $ENV{HOME}/${CMAKE_PROJECT_NAME}")
else()
message(STATUS "Set install prefix ${CMAKE_INSTALL_PREFIX}")
endif()
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
set(MYFRAME_TEST_DIR "test")
set(MYFRAME_BIN_DIR "bin")
set(MYFRAME_INC_DIR "include")
set(MYFRAME_LIB_DIR "lib")
Expand All @@ -38,36 +41,31 @@ set(MYFRAME_SERVICE_DIR "service")
set(MYFRAME_CONF_DIR "conf")

### deps libs
find_package(Threads REQUIRED)
find_package(jsoncpp REQUIRED)
find_package(gflags REQUIRED)

link_libraries(
pthread dl rt m
glog gflags
Threads::Threads
${CMAKE_DL_LIBS}
glog
jsoncpp
-Wl,-z,defs
)
if (GCC_VERSION LESS "8.0")
link_libraries(
stdc++fs
)
endif ()

### include dir
include_directories(.)

### sub directory
add_subdirectory(myframe)
add_subdirectory(launcher)
if (GENERATE_EXAMPLE)
if (MYFRAME_GENERATE_EXAMPLE)
add_subdirectory(examples)
endif()
if (GENERATE_TEST)
if (MYFRAME_GENERATE_TEST)
add_subdirectory(test)
endif()

### install file/dir
install(FILES
install(FILES
"LICENSE"
PERMISSIONS OWNER_READ GROUP_READ WORLD_READ
DESTINATION .
Expand Down
3 changes: 2 additions & 1 deletion cpplint.bash
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ function main() {
-name "*.hxx" -or \
-name "*.cxx" -or \
-name "*.cuh" \
')' | xargs python3 ./cpplint.py
')' -and -not -path "./build/*" \
| xargs python3 ./cpplint.py
}

main "$@"
4 changes: 2 additions & 2 deletions doc/development_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ make -C build -j "$(nproc)" install
### 运行组件
```sh
cd ${myframe目录}/bin
./launcher -c ${组件名}.json -p app
./launcher -p app ${组件名}.json
```

### 查看运行日志
```sh
cd ${myframe目录}/log
vi ${日志}
vi app.INFO
```
2 changes: 2 additions & 0 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
CMAKE_MINIMUM_REQUIRED(VERSION 3.10)

add_compile_definitions(${PROJECT_NAME}_EXPORTS)

### actor
add_library(example_actor_helloworld SHARED example_actor_helloworld.cpp)
target_link_libraries(example_actor_helloworld ${PROJECT_NAME})
Expand Down
6 changes: 3 additions & 3 deletions examples/example_actor_concurrent.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/****************************************************************************
Copyright (c) 2018, likepeng
Copyright (c) 2019, 李柯鹏
All rights reserved.
Author: likepeng <likepeng0418@163.com>
Author: 李柯鹏 <likepeng0418@163.com>
****************************************************************************/
#include <chrono>
#include <random>
Expand Down Expand Up @@ -78,7 +78,7 @@ class ExampleActorConcurrentTrigger : public myframe::Actor {
std::unordered_map<std::string, bool> state_;
};

extern "C" std::shared_ptr<myframe::Actor> actor_create(
extern "C" MYFRAME_EXPORT std::shared_ptr<myframe::Actor> actor_create(
const std::string& actor_name) {
if (actor_name == "example_actor_concurrent") {
return std::make_shared<ExampleActorConcurrent>();
Expand Down
6 changes: 3 additions & 3 deletions examples/example_actor_helloworld.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/****************************************************************************
Copyright (c) 2018, likepeng
Copyright (c) 2019, 李柯鹏
All rights reserved.
Author: likepeng <likepeng0418@163.com>
Author: 李柯鹏 <likepeng0418@163.com>
****************************************************************************/

#include <glog/logging.h>
Expand Down Expand Up @@ -32,7 +32,7 @@ class ExampleActorHelloWorld : public myframe::Actor {
};

/* 创建actor模块实例函数 */
extern "C" std::shared_ptr<myframe::Actor> actor_create(
extern "C" MYFRAME_EXPORT std::shared_ptr<myframe::Actor> actor_create(
const std::string& actor_name) {
if (actor_name == "example") {
return std::make_shared<ExampleActorHelloWorld>();
Expand Down
6 changes: 3 additions & 3 deletions examples/example_actor_serial.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/****************************************************************************
Copyright (c) 2018, likepeng
Copyright (c) 2019, 李柯鹏
All rights reserved.
Author: likepeng <likepeng0418@163.com>
Author: 李柯鹏 <likepeng0418@163.com>
****************************************************************************/
#include <chrono>
#include <random>
Expand Down Expand Up @@ -81,7 +81,7 @@ class ExampleActorSerial3 : public myframe::Actor {
}
};

extern "C" std::shared_ptr<myframe::Actor> actor_create(
extern "C" MYFRAME_EXPORT std::shared_ptr<myframe::Actor> actor_create(
const std::string& actor_name) {
if (actor_name == "example_serial1") {
return std::make_shared<ExampleActorSerial1>();
Expand Down
6 changes: 3 additions & 3 deletions examples/example_actor_subscribe.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/****************************************************************************
Copyright (c) 2018, likepeng
Copyright (c) 2019, 李柯鹏
All rights reserved.
Author: likepeng <likepeng0418@163.com>
Author: 李柯鹏 <likepeng0418@163.com>
****************************************************************************/
#include <chrono>
#include <random>
Expand Down Expand Up @@ -53,7 +53,7 @@ class ExampleActorSub : public myframe::Actor {
}
};

extern "C" std::shared_ptr<myframe::Actor> actor_create(
extern "C" MYFRAME_EXPORT std::shared_ptr<myframe::Actor> actor_create(
const std::string& actor_name) {
if (actor_name == "example_b_pub") {
return std::make_shared<ExampleActorPub>();
Expand Down
6 changes: 3 additions & 3 deletions examples/example_actor_timer.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/****************************************************************************
Copyright (c) 2018, likepeng
Copyright (c) 2019, 李柯鹏
All rights reserved.
Author: likepeng <likepeng0418@163.com>
Author: 李柯鹏 <likepeng0418@163.com>
****************************************************************************/

#include <glog/logging.h>
Expand All @@ -28,7 +28,7 @@ class ExampleActorTimer : public myframe::Actor {
}
};

extern "C" std::shared_ptr<myframe::Actor> actor_create(
extern "C" MYFRAME_EXPORT std::shared_ptr<myframe::Actor> actor_create(
const std::string& actor_name) {
if (actor_name == "example_actor_timer") {
return std::make_shared<ExampleActorTimer>();
Expand Down
8 changes: 4 additions & 4 deletions examples/example_config.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/****************************************************************************
Copyright (c) 2018, likepeng
Copyright (c) 2019, 李柯鹏
All rights reserved.
Author: likepeng <likepeng0418@163.com>
Author: 李柯鹏 <likepeng0418@163.com>
****************************************************************************/
#include <chrono>
#include <thread>
Expand Down Expand Up @@ -42,7 +42,7 @@ class ExampleWorkerConfig : public myframe::Worker {
};

/* 创建actor实例函数 */
extern "C" std::shared_ptr<myframe::Actor> actor_create(
extern "C" MYFRAME_EXPORT std::shared_ptr<myframe::Actor> actor_create(
const std::string& actor_name) {
if (actor_name == "example_actor_config") {
return std::make_shared<ExampleActorConfig>();
Expand All @@ -51,7 +51,7 @@ extern "C" std::shared_ptr<myframe::Actor> actor_create(
}

/* 创建worker实例函数 */
extern "C" std::shared_ptr<myframe::Worker> worker_create(
extern "C" MYFRAME_EXPORT std::shared_ptr<myframe::Worker> worker_create(
const std::string& worker_name) {
if (worker_name == "example_worker_config") {
return std::make_shared<ExampleWorkerConfig>();
Expand Down
8 changes: 4 additions & 4 deletions examples/example_trans_obj.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/****************************************************************************
Copyright (c) 2018, likepeng
Copyright (c) 2019, 李柯鹏
All rights reserved.
Author: likepeng <likepeng0418@163.com>
Author: 李柯鹏 <likepeng0418@163.com>
****************************************************************************/
#include <chrono>
#include <thread>
Expand Down Expand Up @@ -61,7 +61,7 @@ class ExampleWorkerTransObj : public myframe::Worker {
};

/* 创建actor实例函数 */
extern "C" std::shared_ptr<myframe::Actor> actor_create(
extern "C" MYFRAME_EXPORT std::shared_ptr<myframe::Actor> actor_create(
const std::string& actor_name) {
if (actor_name == "example_actor_trans_obj") {
return std::make_shared<ExampleActorTransObj>();
Expand All @@ -70,7 +70,7 @@ extern "C" std::shared_ptr<myframe::Actor> actor_create(
}

/* 创建worker实例函数 */
extern "C" std::shared_ptr<myframe::Worker> worker_create(
extern "C" MYFRAME_EXPORT std::shared_ptr<myframe::Worker> worker_create(
const std::string& worker_name) {
if (worker_name == "example_worker_trans_obj") {
return std::make_shared<ExampleWorkerTransObj>();
Expand Down
10 changes: 5 additions & 5 deletions examples/example_worker_actor_interactive.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/****************************************************************************
Copyright (c) 2018, likepeng
Copyright (c) 2019, 李柯鹏
All rights reserved.
Author: likepeng <likepeng0418@163.com>
Author: 李柯鹏 <likepeng0418@163.com>
****************************************************************************/
#include <chrono>
#include <thread>
Expand Down Expand Up @@ -44,7 +44,7 @@ class ExampleWorkerInteractive : public myframe::Worker {
return;
}
while (1) {
const auto& msg = mailbox->PopRecv();
const auto msg = mailbox->PopRecv();
if (msg == nullptr) {
break;
}
Expand All @@ -55,7 +55,7 @@ class ExampleWorkerInteractive : public myframe::Worker {
};

/* 创建actor实例函数 */
extern "C" std::shared_ptr<myframe::Actor> actor_create(
extern "C" MYFRAME_EXPORT std::shared_ptr<myframe::Actor> actor_create(
const std::string& actor_name) {
if (actor_name == "example_actor_interactive") {
return std::make_shared<ExampleActorInteractive>();
Expand All @@ -64,7 +64,7 @@ extern "C" std::shared_ptr<myframe::Actor> actor_create(
}

/* 创建worker实例函数 */
extern "C" std::shared_ptr<myframe::Worker> worker_create(
extern "C" MYFRAME_EXPORT std::shared_ptr<myframe::Worker> worker_create(
const std::string& worker_name) {
if (worker_name == "example_worker_interactive") {
return std::make_shared<ExampleWorkerInteractive>();
Expand Down
Loading

0 comments on commit 536e8cc

Please sign in to comment.