Skip to content

Commit

Permalink
Merge pull request #27 from lkpworkspace/dev
Browse files Browse the repository at this point in the history
v0.9.0
  • Loading branch information
lkpworkspace authored Oct 25, 2023
2 parents e3f2a8e + 9237935 commit 0f3884e
Show file tree
Hide file tree
Showing 33 changed files with 370 additions and 67 deletions.
137 changes: 137 additions & 0 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
name: Windows

on: [push, pull_request]

jobs:
build-msvc:
name: ${{matrix.msvc}}-${{matrix.arch}}-C++${{matrix.std}}-${{matrix.build_type}}
runs-on: ${{matrix.os}}
defaults:
run:
shell: powershell
env:
CL: /MP
CXXFLAGS: /permissive-
strategy:
fail-fast: true
matrix:
arch: [Win32, x64]
build_type: [Release]
msvc: [VS-16-2019, VS-17-2022]
std: [17]
include:
- msvc: VS-16-2019
os: windows-2019
generator: 'Visual Studio 16 2019'
- msvc: VS-17-2022
os: windows-2022
generator: 'Visual Studio 17 2022'

steps:
- uses: actions/checkout@v3

- name: Cache jsoncpp
id: cache-jsoncpp
uses: actions/cache@v2
with:
path: jsoncpp/
key: ${{runner.os}}-jsoncpp-1.9.5-${{matrix.arch}}-${{matrix.build_type}}

- name: Download jsoncpp
if: steps.cache-jsoncpp.outputs.cache-hit != 'true'
run: |
(New-Object System.Net.WebClient).DownloadFile("https://github.com/open-source-parsers/jsoncpp/archive/refs/tags/1.9.5.zip", "jsoncpp-1.9.5.zip")
Expand-Archive jsoncpp-1.9.5.zip .
- name: Build jsoncpp
if: steps.cache-jsoncpp.outputs.cache-hit != 'true'
run: |
cmake -S jsoncpp-1.9.5 -B build-jsoncpp `
-A ${{matrix.arch}} `
-DCMAKE_BUILD_TYPE=${{matrix.build_type}} `
-DCMAKE_INSTALL_PREFIX=${{github.workspace}}/jsoncpp `
-DBUILD_OBJECT_LIBS=OFF `
-DJSONCPP_WITH_TESTS=OFF `
-DJSONCPP_WITH_POST_BUILD_UNITTEST=OFF `
-DJSONCPP_WITH_PKGCONFIG_SUPPORT=OFF
cmake --build build-jsoncpp `
--config ${{matrix.build_type}} `
--target install
- name: Cache gflags
id: cache-gflags
uses: actions/cache@v2
with:
path: gflags/
key: ${{runner.os}}-gflags-2.2.2-${{matrix.arch}}-${{matrix.build_type}}

- name: Download gflags
if: steps.cache-gflags.outputs.cache-hit != 'true'
run: |
(New-Object System.Net.WebClient).DownloadFile("https://github.com/gflags/gflags/archive/refs/tags/v2.2.2.zip", "v2.2.2.zip")
Expand-Archive v2.2.2.zip .
- name: Build gflags
if: steps.cache-gflags.outputs.cache-hit != 'true'
run: |
cmake -S gflags-2.2.2 -B build-gflags `
-A ${{matrix.arch}} `
-DBUILD_SHARED_LIBS=ON `
-DCMAKE_INSTALL_PREFIX=${{github.workspace}}/gflags
cmake --build build-gflags `
--config ${{matrix.build_type}} `
--target install
- name: Cache glog
id: cache-glog
uses: actions/cache@v2
with:
path: glog/
key: ${{runner.os}}-glog-0.6.0-${{matrix.arch}}-${{matrix.build_type}}

- name: Download glog
if: steps.cache-glog.outputs.cache-hit != 'true'
run: |
(New-Object System.Net.WebClient).DownloadFile("https://github.com/google/glog/archive/refs/tags/v0.6.0.zip", "glog-0.6.0.zip")
Expand-Archive glog-0.6.0.zip .
- name: Build glog
if: steps.cache-glog.outputs.cache-hit != 'true'
run: |
cmake -S glog-0.6.0 -B build-glog `
-A ${{matrix.arch}} `
-DBUILD_SHARED_LIBS=ON `
-DWITH_GTEST=OFF `
-DWITH_PKGCONFIG=OFF `
-DCMAKE_PREFIX_PATH="${{github.workspace}}/gflags" `
-DCMAKE_INSTALL_PREFIX=${{github.workspace}}/glog
cmake --build build-glog `
--config ${{matrix.build_type}} `
--target install
- name: Configure
run: |
cmake -S . -B build_${{matrix.build_type}} `
-A ${{matrix.arch}} `
-DMYFRAME_USE_CV=ON `
-DBUILD_SHARED_LIBS=ON `
-DCMAKE_CXX_EXTENSIONS=OFF `
-DCMAKE_CXX_STANDARD=${{matrix.std}} `
-DCMAKE_CXX_STANDARD_REQUIRED=ON `
-DCMAKE_EXE_LINKER_FLAGS='/NOIMPLIB' `
-DCMAKE_EXE_LINKER_FLAGS_RELEASE='/INCREMENTAL:NO /DEBUG' `
-DCMAKE_INSTALL_PREFIX=${{github.workspace}}/myframe `
-DCMAKE_PREFIX_PATH="${{github.workspace}}/jsoncpp;${{github.workspace}}/glog;${{github.workspace}}/gflags" `
-DCMAKE_MSVC_RUNTIME_LIBRARY='MultiThreaded$<$<CONFIG:Debug>:Debug>DLL' `
-G "${{matrix.generator}}" `
-Werror
- name: Build
run: cmake --build build_${{matrix.build_type}} `
--config ${{matrix.build_type}}

- name: Install
run: |
cmake --build build_${{matrix.build_type}} `
--config ${{matrix.build_type}} `
--target install
5 changes: 3 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.10)
project(myframe VERSION 0.8.4)
project(myframe VERSION 0.9.0)

### option
option(MYFRAME_USE_CV "Using conditional variables for thread communication" OFF)
Expand Down Expand Up @@ -87,6 +87,7 @@ if (MYFRAME_INSTALL_DEPS)
if (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.21")
install(IMPORTED_RUNTIME_ARTIFACTS jsoncpp_lib)
install(IMPORTED_RUNTIME_ARTIFACTS glog::glog)
install(IMPORTED_RUNTIME_ARTIFACTS gflags)
endif()
endif()

Expand Down Expand Up @@ -117,7 +118,7 @@ configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
VERSION "${PROJECT_VERSION}"
COMPATIBILITY SameMajorVersion
COMPATIBILITY SameMinorVersion
)

# install the configuration file
Expand Down
21 changes: 14 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,23 @@ worker自驱动,可以通过消息与actor交互;
适用于构建中大型项目.

## 开发/运行环境
操作系统: Ubuntu 18.04+
开发语言:C++17
| C++ 标准支持 |
| -------------- |
| C++17 |
| C++20 |

| 操作系统支持 |
| -------------- |
| Windows |
| Linux |

## 构建
参考 [github ci](.github/workflows/linux.yml)
* [github ci linux](.github/workflows/linux.yml)
* [github ci windows](.github/workflows/windows.yml)

## 运行所有的example
```sh
cd ~/myframe/bin
./launcher -p app
path/to/myframe/bin/launcher -p app
```

### Hello,World 示例
Expand Down Expand Up @@ -60,11 +67,11 @@ extern "C" std::shared_ptr<Actor> actor_create(const std::string& actor_name) {

```
### actor配置文件
### Hello,World 配置文件
```json
{
"type":"library",
"lib":"libdemo.so",
"lib":"demo",
"actor":{
"demo":[
{
Expand Down
23 changes: 10 additions & 13 deletions doc/development_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
```json
{
"type": "library",
"lib": "libHello.so",
"lib": "Hello",
"actor": {
"HelloActor": [
{
Expand All @@ -40,7 +40,9 @@
}
```
- "type":"library": 服务通过库的形式提供
- "lib":"libHello.so": 需要加载的库名称是libHello.so
- "lib":"Hello": 需要加载的库名称
- 可以写简略库名,比如 Hello
- 也可以写库的全名,比如libHello.so, Hello,dll
- 创建1个actor实例,名称是 actor.HelloActor.1
- 创建1个worker实例,名称是 worker.HelloReceiver.1
- 创建1个worker实例,名称是 worker.HelloSender.1
Expand All @@ -52,7 +54,7 @@

### 创建组件工程
```sh
python3 ~/myframe/tools/gen_mod_proj.py --dir="/path/to/proj_dir/" --name="mod_name"
python3 path/to/myframe/tools/gen_mod_proj.py --dir="path/to/proj_dir/" --name="mod_name"
```

### 组件工程目录说明
Expand All @@ -64,21 +66,16 @@ python3 ~/myframe/tools/gen_mod_proj.py --dir="/path/to/proj_dir/" --name="mod_n

### 组件工程构建安装
```sh
cmake -S . -B build \
-DCMAKE_INSTALL_PREFIX="/path/to/myframe" \
-DCMAKE_PREFIX_PATH="/path/to/jsoncpp;/path/to/glog"

make -C build -j "$(nproc)" install
cmake -S . -B build -DCMAKE_INSTALL_PREFIX="path/to/myframe" -DCMAKE_PREFIX_PATH="path/to/jsoncpp;path/to/glog"
cmake --build build --config Release --target install
```

### 运行组件
```sh
cd /path/to/myframe/bin
./launcher -p app ${组件名}.json
/path/to/myframe/bin/launcher -p app ${组件名}.json
```

### 查看运行日志
### 日志文件
```sh
cd /path/to/myframe/log
vi app.INFO
path/to/myframe/log/app.INFO
```
Binary file modified doc/pics/myframe.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion examples/example_actor_concurrent.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"type":"library",
"lib":"libexample_actor_concurrent.so",
"lib":"example_actor_concurrent",
"actor":{
"example_actor_concurrent_trigger":[
{
Expand Down
2 changes: 1 addition & 1 deletion examples/example_actor_helloworld.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"type":"library",
"lib":"libexample_actor_helloworld.so",
"lib":"example_actor_helloworld",
"actor":{
"example":[
{
Expand Down
2 changes: 1 addition & 1 deletion examples/example_actor_serial.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"type":"library",
"lib":"libexample_actor_serial.so",
"lib":"example_actor_serial",
"actor":{
"example_serial1":[
{
Expand Down
2 changes: 1 addition & 1 deletion examples/example_actor_subscribe.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"type":"library",
"lib":"libexample_actor_subscribe.so",
"lib":"example_actor_subscribe",
"actor":{
"example_b_pub":[
{
Expand Down
2 changes: 1 addition & 1 deletion examples/example_actor_timer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"type":"library",
"lib":"libexample_actor_timer.so",
"lib":"example_actor_timer",
"actor":{
"example_actor_timer":[
{
Expand Down
2 changes: 1 addition & 1 deletion examples/example_config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"type":"library",
"lib":"libexample_config.so",
"lib":"example_config",
"actor":{
"example_actor_config":[
{
Expand Down
2 changes: 1 addition & 1 deletion examples/example_trans_obj.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"type":"library",
"lib":"libexample_trans_obj.so",
"lib":"example_trans_obj",
"actor":{
"example_actor_trans_obj":[
{
Expand Down
2 changes: 1 addition & 1 deletion examples/example_worker_actor_interactive.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"type":"library",
"lib":"libexample_worker_actor_interactive.so",
"lib":"example_worker_actor_interactive",
"actor":{
"example_actor_interactive":[
{
Expand Down
2 changes: 1 addition & 1 deletion examples/example_worker_interactive_with_3rd_frame.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"type":"library",
"lib":"libexample_worker_interactive_with_3rd_frame.so",
"lib":"example_worker_interactive_with_3rd_frame",
"actor":{
"example_actor_interactive_with_3rd_frame":[
{
Expand Down
2 changes: 1 addition & 1 deletion examples/example_worker_publish.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"type":"library",
"lib":"libexample_worker_publish.so",
"lib":"example_worker_publish",
"worker":{
"example_worker_publish":[
{
Expand Down
2 changes: 1 addition & 1 deletion examples/example_worker_quit.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"type":"library",
"lib":"libexample_worker_quit.so",
"lib":"example_worker_quit",
"worker":{
"example_worker_quit":[
{
Expand Down
2 changes: 1 addition & 1 deletion examples/example_worker_talk.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"type":"library",
"lib":"libexample_worker_talk.so",
"lib":"example_worker_talk",
"worker":{
"example_worker_talk":[
{
Expand Down
Loading

0 comments on commit 0f3884e

Please sign in to comment.