Skip to content

Commit 536e8cc

Browse files
authored
Merge pull request #23 from lkpworkspace/dev
v0.8.2
2 parents b5063d5 + 2dcb95b commit 536e8cc

File tree

87 files changed

+2128
-801
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+2128
-801
lines changed

.github/workflows/linux.yml

+2-5
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
- uses: actions/checkout@v3
2020
- run: sudo apt update
2121
- run: sudo apt install build-essential cmake ninja-build
22-
- run: sudo apt install libjsoncpp-dev libgflags-dev libgoogle-glog-dev libunwind-dev
22+
- run: sudo apt install libjsoncpp-dev libgoogle-glog-dev libunwind-dev
2323

2424
- name: Setup Ninja
2525
uses: ashutoshvarma/setup-ninja@master
@@ -28,12 +28,9 @@ jobs:
2828

2929
- name: Configure CMake
3030
env:
31-
# glog option:
32-
# -DNDEBUG
33-
# -DDCHECK_ALWAYS_ON
3431
# unit test option:
3532
# -fno-omit-frame-pointer -fsanitize=address -fsanitize=undefined
36-
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
33+
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
3734
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
3835
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
3936
run: |

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,6 @@ build/
1212
.vscode
1313

1414
launcher/launcher_config.h
15-
test/performance_test_config.h
15+
test/performance_test_config.h
16+
myframe/export.h
17+
myframe/config.h

CMakeLists.txt

+30-32
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,23 @@
11
cmake_minimum_required(VERSION 3.10)
2-
project(myframe VERSION 0.8.1)
3-
4-
### gcc version
5-
if (CMAKE_COMPILER_IS_GNUCC)
6-
execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpfullversion -dumpversion
7-
OUTPUT_VARIABLE GCC_VERSION)
8-
string(REGEX MATCHALL "[0-9]+" GCC_VERSION_COMPONENTS ${GCC_VERSION})
9-
list(GET GCC_VERSION_COMPONENTS 0 GCC_MAJOR)
10-
list(GET GCC_VERSION_COMPONENTS 1 GCC_MINOR)
11-
set(GCC_VERSION "${GCC_MAJOR}.${GCC_MINOR}")
12-
endif ()
13-
14-
### cpp option
15-
if (GCC_VERSION GREATER "8.0")
16-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra-semi")
17-
endif ()
2+
project(myframe VERSION 0.8.2)
183

194
### option
20-
option(GENERATE_EXAMPLE "generate example library" ON)
21-
option(GENERATE_TEST "generate test exec" ON)
5+
option(MYFRAME_USE_CV "Using conditional variables for thread communication" OFF)
6+
option(MYFRAME_GENERATE_EXAMPLE "Generate example library" ON)
7+
option(MYFRAME_GENERATE_TEST "Generate test executable program" ON)
8+
9+
### compile option
10+
set(CMAKE_C_VISIBILITY_PRESET hidden)
11+
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
12+
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
13+
set(CMAKE_VISIBILITY_INLINES_HIDDEN ON)
14+
if (CMAKE_CXX_STANDARD_REQUIRED)
15+
message(STATUS "Set cxx standard ${CMAKE_CXX_STANDARD}")
16+
else()
17+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
18+
set(CMAKE_CXX_STANDARD 17)
19+
message(STATUS "Set default cxx standard 17")
20+
endif()
2221

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

2928
### install path
30-
# set(CMAKE_INSTALL_PREFIX "$ENV{HOME}/${CMAKE_PROJECT_NAME}")
29+
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
30+
set(CMAKE_INSTALL_PREFIX "$ENV{HOME}/${CMAKE_PROJECT_NAME}" CACHE PATH "myframe default install prefix" FORCE)
31+
message(STATUS "Set default install prefix $ENV{HOME}/${CMAKE_PROJECT_NAME}")
32+
else()
33+
message(STATUS "Set install prefix ${CMAKE_INSTALL_PREFIX}")
34+
endif()
3135
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
32-
set(MYFRAME_TEST_DIR "test")
3336
set(MYFRAME_BIN_DIR "bin")
3437
set(MYFRAME_INC_DIR "include")
3538
set(MYFRAME_LIB_DIR "lib")
@@ -38,36 +41,31 @@ set(MYFRAME_SERVICE_DIR "service")
3841
set(MYFRAME_CONF_DIR "conf")
3942

4043
### deps libs
44+
find_package(Threads REQUIRED)
4145
find_package(jsoncpp REQUIRED)
42-
find_package(gflags REQUIRED)
4346

4447
link_libraries(
45-
pthread dl rt m
46-
glog gflags
48+
Threads::Threads
49+
${CMAKE_DL_LIBS}
50+
glog
4751
jsoncpp
48-
-Wl,-z,defs
4952
)
50-
if (GCC_VERSION LESS "8.0")
51-
link_libraries(
52-
stdc++fs
53-
)
54-
endif ()
5553

5654
### include dir
5755
include_directories(.)
5856

5957
### sub directory
6058
add_subdirectory(myframe)
6159
add_subdirectory(launcher)
62-
if (GENERATE_EXAMPLE)
60+
if (MYFRAME_GENERATE_EXAMPLE)
6361
add_subdirectory(examples)
6462
endif()
65-
if (GENERATE_TEST)
63+
if (MYFRAME_GENERATE_TEST)
6664
add_subdirectory(test)
6765
endif()
6866

6967
### install file/dir
70-
install(FILES
68+
install(FILES
7169
"LICENSE"
7270
PERMISSIONS OWNER_READ GROUP_READ WORLD_READ
7371
DESTINATION .

cpplint.bash

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ function main() {
1818
-name "*.hxx" -or \
1919
-name "*.cxx" -or \
2020
-name "*.cuh" \
21-
')' | xargs python3 ./cpplint.py
21+
')' -and -not -path "./build/*" \
22+
| xargs python3 ./cpplint.py
2223
}
2324

2425
main "$@"

doc/development_guide.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,11 @@ make -C build -j "$(nproc)" install
7171
### 运行组件
7272
```sh
7373
cd ${myframe目录}/bin
74-
./launcher -c ${组件名}.json -p app
74+
./launcher -p app ${组件名}.json
7575
```
7676

7777
### 查看运行日志
7878
```sh
7979
cd ${myframe目录}/log
80-
vi ${日志}
80+
vi app.INFO
8181
```

examples/CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
CMAKE_MINIMUM_REQUIRED(VERSION 3.10)
22

3+
add_compile_definitions(${PROJECT_NAME}_EXPORTS)
4+
35
### actor
46
add_library(example_actor_helloworld SHARED example_actor_helloworld.cpp)
57
target_link_libraries(example_actor_helloworld ${PROJECT_NAME})

examples/example_actor_concurrent.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/****************************************************************************
2-
Copyright (c) 2018, likepeng
2+
Copyright (c) 2019, 李柯鹏
33
All rights reserved.
44
5-
Author: likepeng <[email protected]>
5+
Author: 李柯鹏 <[email protected]>
66
****************************************************************************/
77
#include <chrono>
88
#include <random>
@@ -78,7 +78,7 @@ class ExampleActorConcurrentTrigger : public myframe::Actor {
7878
std::unordered_map<std::string, bool> state_;
7979
};
8080

81-
extern "C" std::shared_ptr<myframe::Actor> actor_create(
81+
extern "C" MYFRAME_EXPORT std::shared_ptr<myframe::Actor> actor_create(
8282
const std::string& actor_name) {
8383
if (actor_name == "example_actor_concurrent") {
8484
return std::make_shared<ExampleActorConcurrent>();

examples/example_actor_helloworld.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/****************************************************************************
2-
Copyright (c) 2018, likepeng
2+
Copyright (c) 2019, 李柯鹏
33
All rights reserved.
44
5-
Author: likepeng <[email protected]>
5+
Author: 李柯鹏 <[email protected]>
66
****************************************************************************/
77

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

3434
/* 创建actor模块实例函数 */
35-
extern "C" std::shared_ptr<myframe::Actor> actor_create(
35+
extern "C" MYFRAME_EXPORT std::shared_ptr<myframe::Actor> actor_create(
3636
const std::string& actor_name) {
3737
if (actor_name == "example") {
3838
return std::make_shared<ExampleActorHelloWorld>();

examples/example_actor_serial.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/****************************************************************************
2-
Copyright (c) 2018, likepeng
2+
Copyright (c) 2019, 李柯鹏
33
All rights reserved.
44
5-
Author: likepeng <[email protected]>
5+
Author: 李柯鹏 <[email protected]>
66
****************************************************************************/
77
#include <chrono>
88
#include <random>
@@ -81,7 +81,7 @@ class ExampleActorSerial3 : public myframe::Actor {
8181
}
8282
};
8383

84-
extern "C" std::shared_ptr<myframe::Actor> actor_create(
84+
extern "C" MYFRAME_EXPORT std::shared_ptr<myframe::Actor> actor_create(
8585
const std::string& actor_name) {
8686
if (actor_name == "example_serial1") {
8787
return std::make_shared<ExampleActorSerial1>();

examples/example_actor_subscribe.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/****************************************************************************
2-
Copyright (c) 2018, likepeng
2+
Copyright (c) 2019, 李柯鹏
33
All rights reserved.
44
5-
Author: likepeng <[email protected]>
5+
Author: 李柯鹏 <[email protected]>
66
****************************************************************************/
77
#include <chrono>
88
#include <random>
@@ -53,7 +53,7 @@ class ExampleActorSub : public myframe::Actor {
5353
}
5454
};
5555

56-
extern "C" std::shared_ptr<myframe::Actor> actor_create(
56+
extern "C" MYFRAME_EXPORT std::shared_ptr<myframe::Actor> actor_create(
5757
const std::string& actor_name) {
5858
if (actor_name == "example_b_pub") {
5959
return std::make_shared<ExampleActorPub>();

examples/example_actor_timer.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/****************************************************************************
2-
Copyright (c) 2018, likepeng
2+
Copyright (c) 2019, 李柯鹏
33
All rights reserved.
44
5-
Author: likepeng <[email protected]>
5+
Author: 李柯鹏 <[email protected]>
66
****************************************************************************/
77

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

31-
extern "C" std::shared_ptr<myframe::Actor> actor_create(
31+
extern "C" MYFRAME_EXPORT std::shared_ptr<myframe::Actor> actor_create(
3232
const std::string& actor_name) {
3333
if (actor_name == "example_actor_timer") {
3434
return std::make_shared<ExampleActorTimer>();

examples/example_config.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/****************************************************************************
2-
Copyright (c) 2018, likepeng
2+
Copyright (c) 2019, 李柯鹏
33
All rights reserved.
44
5-
Author: likepeng <[email protected]>
5+
Author: 李柯鹏 <[email protected]>
66
****************************************************************************/
77
#include <chrono>
88
#include <thread>
@@ -42,7 +42,7 @@ class ExampleWorkerConfig : public myframe::Worker {
4242
};
4343

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

5353
/* 创建worker实例函数 */
54-
extern "C" std::shared_ptr<myframe::Worker> worker_create(
54+
extern "C" MYFRAME_EXPORT std::shared_ptr<myframe::Worker> worker_create(
5555
const std::string& worker_name) {
5656
if (worker_name == "example_worker_config") {
5757
return std::make_shared<ExampleWorkerConfig>();

examples/example_trans_obj.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/****************************************************************************
2-
Copyright (c) 2018, likepeng
2+
Copyright (c) 2019, 李柯鹏
33
All rights reserved.
44
5-
Author: likepeng <[email protected]>
5+
Author: 李柯鹏 <[email protected]>
66
****************************************************************************/
77
#include <chrono>
88
#include <thread>
@@ -61,7 +61,7 @@ class ExampleWorkerTransObj : public myframe::Worker {
6161
};
6262

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

7272
/* 创建worker实例函数 */
73-
extern "C" std::shared_ptr<myframe::Worker> worker_create(
73+
extern "C" MYFRAME_EXPORT std::shared_ptr<myframe::Worker> worker_create(
7474
const std::string& worker_name) {
7575
if (worker_name == "example_worker_trans_obj") {
7676
return std::make_shared<ExampleWorkerTransObj>();

examples/example_worker_actor_interactive.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/****************************************************************************
2-
Copyright (c) 2018, likepeng
2+
Copyright (c) 2019, 李柯鹏
33
All rights reserved.
44
5-
Author: likepeng <[email protected]>
5+
Author: 李柯鹏 <[email protected]>
66
****************************************************************************/
77
#include <chrono>
88
#include <thread>
@@ -44,7 +44,7 @@ class ExampleWorkerInteractive : public myframe::Worker {
4444
return;
4545
}
4646
while (1) {
47-
const auto& msg = mailbox->PopRecv();
47+
const auto msg = mailbox->PopRecv();
4848
if (msg == nullptr) {
4949
break;
5050
}
@@ -55,7 +55,7 @@ class ExampleWorkerInteractive : public myframe::Worker {
5555
};
5656

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

6666
/* 创建worker实例函数 */
67-
extern "C" std::shared_ptr<myframe::Worker> worker_create(
67+
extern "C" MYFRAME_EXPORT std::shared_ptr<myframe::Worker> worker_create(
6868
const std::string& worker_name) {
6969
if (worker_name == "example_worker_interactive") {
7070
return std::make_shared<ExampleWorkerInteractive>();

0 commit comments

Comments
 (0)