Skip to content

Commit

Permalink
Add c++ brpc
Browse files Browse the repository at this point in the history
  • Loading branch information
fantasy-peak committed Apr 7, 2024
1 parent b666060 commit 1900f92
Show file tree
Hide file tree
Showing 20 changed files with 3,723 additions and 0 deletions.
88 changes: 88 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# https://blog.csdn.net/softimite_zifeng/article/details/78357898
---
Language: Cpp
#BasedOnStyle: Google
AccessModifierOffset: -4
#AlignAfterOpenBracket: false
AlignAfterOpenBracket: Align
#AlignAfterOpenBracket: AlwaysBreak
AlignConsecutiveAssignments: false
AlignEscapedNewlinesLeft: true
AlignOperands: true
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: true
BinPackArguments: true
BinPackParameters: true
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Attach
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: true
ColumnLimit: 0
#ColumnLimit: 300
CommentPragmas: '^ IWYU pragma:'
#ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
IncludeCategories:
- Regex: '^<.*\.h>'
Priority: 1
- Regex: '^<.*'
Priority: 2
- Regex: '.*'
Priority: 3
IndentCaseLabels: true
IndentWidth: 4
IndentWrappedFunctionNames: false
KeepEmptyLinesAtTheStartOfBlocks: false
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: false
PenaltyBreakBeforeFirstCallParameter: 1
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 200
PointerAlignment: Left
SpaceAfterCStyleCast: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Auto
TabWidth: 4
# 使用tab字符: Never, ForIndentation, ForContinuationAndIndentation, Always
# UseTab: ForContinuationAndIndentation
# 在方括号的[后和]前添加空格,lamda表达式和未指明大小的数组的声明不受影响
#SpacesInSquareBrackets: true
# 对齐续航符位置
AlignEscapedNewlines: Left
# https://clang.llvm.org/docs/ClangFormatStyleOptions.html
AllowShortLambdasOnASingleLine: Empty
FixNamespaceComments: true
#SBS_Never: Never
#CompactNamespaces: false
#LanguageStandard: LS_Cpp17
...
47 changes: 47 additions & 0 deletions .github/workflows/ubuntu-gcc13.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: ubuntu-gcc13

on:
push:
branches: ["main", "dev"]
pull_request:
branches: ["main"]

jobs:
build:
runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [ubuntu-22.04]

steps:
- name: Installation
run: |
sudo apt-get update
sudo apt-get install -y libgl1-mesa-dev libglu1-mesa-dev p7zip gobjc g++-13 wget sudo libmsgpack-dev/jammy
- uses: xmake-io/github-action-setup-xmake@v1
with:
xmake-version: v2.8.9

- name: checkout
uses: actions/checkout@v3
- name: build
run: |
export XMAKE_ROOT="y"
g++-13 -v
export CXX=g++-13
export CC=gcc-13
xmake build -y
xmake install -o .
./bin/brpc -f ./config/config.yaml -t ./template/cpp -o ./out
xmake build -v -y --file=./test_xmake.lua
xmake install -o . --file=./example_xmake.lua
./
- name: build test and run test
run: |
./bin/brpc -f ./config/config.yaml -t ./template/cpp -o ./out
xmake build -v -y --file=./test_xmake.lua
xmake install -o . --file=./example_xmake.lua
./bin/cpp23
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# brpc
```
xmake build -v -y
xmake install -o .
cd bin
./brpc -f ../config/config.yaml -t ../template/cpp/ast.cpp.inja -o ../out
```
59 changes: 59 additions & 0 deletions config/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
property:
filename: brpc.hpp
namespace: brpc

TestType:
type: enum
value_type: i32
definitions:
EnumOne: { default: 0, comment: "zero" }
EnumTwo: { default: 1, comment: "one" }

Info:
type: struct
definitions:
Name: { type: string, comment: "test Name" }

BankInfo:
type: struct
definitions:
Name: { type: string, comment: "test Name" }
Type: { type: TestType, comment: "test Type" }
TestOne: { type: i32, comment: "test 1" }
TestTwo: { type: u32, comment: "test 2" }
TestMapOne: { type: map<string;TestType>, comment: "test map" }
TestMap: { type: map<bool;u32>, comment: "test map" }
TestVector: { type: vector<string>, comment: "test map" }
Info: { type: Info, comment: "Info" }

HelloWorldApi:
type: interface
pattern: bi
caller: HelloWorldClient
callee: HelloWorldServer
definitions:
hello_world:
type: func
inputs:
bank_info: {type: BankInfo}
bank_name: {type: string}
blance: {type: u64}
outputs:
reply: {type: string}
info: {type: Info}
count: {type: u64}

UniInterface:
type: interface
pattern: uni
caller: HelloWorldSender
callee: HelloWorldReceiver
definitions:
hello_world:
inputs:
in: {type: string}
notice:
inputs:
in: {type: i32}
info: {type: string}

Loading

0 comments on commit 1900f92

Please sign in to comment.