Skip to content

Commit 93f26cb

Browse files
Donald-RupinDonald-Rupin
authored andcommitted
Initial commit of ZAB v0.0.0.1
1 parent 874dbfa commit 93f26cb

Some content is hidden

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

53 files changed

+15800
-1
lines changed

.clang-format

Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
---
2+
Language: Cpp
3+
# BasedOnStyle: LLVM
4+
AccessModifierOffset: 3
5+
AlignAfterOpenBracket: AlwaysBreak
6+
AlignArrayOfStructures: None
7+
AlignConsecutiveMacros: AcrossEmptyLinesAndComments
8+
AlignConsecutiveAssignments: AcrossComments
9+
AlignConsecutiveBitFields: AcrossComments
10+
AlignConsecutiveDeclarations: AcrossComments
11+
AlignEscapedNewlines: Right
12+
AlignOperands: Align
13+
AlignTrailingComments: true
14+
AllowAllArgumentsOnNextLine: false
15+
AllowAllConstructorInitializersOnNextLine: false
16+
AllowAllParametersOfDeclarationOnNextLine: false
17+
AllowShortEnumsOnASingleLine: false
18+
AllowShortBlocksOnASingleLine: Always
19+
AllowShortCaseLabelsOnASingleLine: false
20+
AllowShortFunctionsOnASingleLine: Inline
21+
AllowShortLambdasOnASingleLine: Inline
22+
AllowShortIfStatementsOnASingleLine: WithoutElse
23+
AllowShortLoopsOnASingleLine: false
24+
AlwaysBreakAfterDefinitionReturnType: None
25+
AlwaysBreakAfterReturnType: All
26+
AlwaysBreakBeforeMultilineStrings: false
27+
AlwaysBreakTemplateDeclarations: Yes
28+
AttributeMacros:
29+
- __capability
30+
BinPackArguments: false
31+
BinPackParameters: false
32+
BraceWrapping:
33+
AfterCaseLabel: false
34+
AfterClass: false
35+
AfterControlStatement: Always
36+
AfterEnum: false
37+
AfterFunction: true
38+
AfterNamespace: false
39+
AfterObjCDeclaration: false
40+
AfterStruct: false
41+
AfterUnion: false
42+
AfterExternBlock: true
43+
BeforeCatch: false
44+
BeforeElse: true
45+
BeforeLambdaBody: true
46+
BeforeWhile: false
47+
IndentBraces: false
48+
SplitEmptyFunction: false
49+
SplitEmptyRecord: false
50+
SplitEmptyNamespace: false
51+
BreakBeforeBinaryOperators: None
52+
BreakBeforeConceptDeclarations: true
53+
BreakBeforeBraces: Custom
54+
BreakBeforeInheritanceComma: false
55+
BreakInheritanceList: BeforeColon
56+
BreakBeforeTernaryOperators: true
57+
BreakConstructorInitializersBeforeComma: false
58+
BreakConstructorInitializers: BeforeColon
59+
BreakAfterJavaFieldAnnotations: false
60+
BreakStringLiterals: true
61+
ColumnLimit: 100
62+
CommentPragmas: '^ IWYU pragma:'
63+
CompactNamespaces: false
64+
ConstructorInitializerAllOnOneLineOrOnePerLine: false
65+
ConstructorInitializerIndentWidth: 4
66+
ContinuationIndentWidth: 4
67+
Cpp11BracedListStyle: true
68+
DeriveLineEnding: true
69+
DerivePointerAlignment: false
70+
DisableFormat: false
71+
EmptyLineAfterAccessModifier: Always
72+
EmptyLineBeforeAccessModifier: Always
73+
ExperimentalAutoDetectBinPacking: false
74+
FixNamespaceComments: true
75+
ForEachMacros:
76+
- foreach
77+
- Q_FOREACH
78+
- BOOST_FOREACH
79+
IfMacros:
80+
- KJ_IF_MAYBE
81+
IncludeBlocks: Regroup
82+
IncludeCategories:
83+
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
84+
Priority: 0
85+
SortPriority: 0
86+
CaseSensitive: false
87+
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
88+
Priority: 1
89+
SortPriority: 0
90+
CaseSensitive: false
91+
- Regex: '^(<|"(zab)/)'
92+
Priority: 2
93+
SortPriority: 2
94+
CaseSensitive: false
95+
- Regex: '^.*/.*'
96+
Priority: 3
97+
SortPriority: 3
98+
- Regex: '.*'
99+
Priority: 4
100+
SortPriority: 4
101+
CaseSensitive: false
102+
IncludeIsMainRegex: '(Test)?$'
103+
IncludeIsMainSourceRegex: ''
104+
IndentAccessModifiers: true
105+
IndentCaseLabels: true
106+
IndentCaseBlocks: true
107+
IndentGotoLabels: true
108+
IndentPPDirectives: AfterHash
109+
IndentExternBlock: AfterExternBlock
110+
IndentRequires: true
111+
IndentWidth: 4
112+
IndentWrappedFunctionNames: false
113+
InsertTrailingCommas: None
114+
JavaScriptQuotes: Leave
115+
JavaScriptWrapImports: true
116+
KeepEmptyLinesAtTheStartOfBlocks: true
117+
LambdaBodyIndentation: Signature
118+
MacroBlockBegin: ''
119+
MacroBlockEnd: ''
120+
MaxEmptyLinesToKeep: 1
121+
NamespaceIndentation: All
122+
ObjCBinPackProtocolList: Auto
123+
ObjCBlockIndentWidth: 2
124+
ObjCBreakBeforeNestedBlockParam: true
125+
ObjCSpaceAfterProperty: false
126+
ObjCSpaceBeforeProtocolList: true
127+
PenaltyBreakAssignment: 2
128+
PenaltyBreakBeforeFirstCallParameter: 19
129+
PenaltyBreakComment: 300
130+
PenaltyBreakFirstLessLess: 120
131+
PenaltyBreakString: 1000
132+
PenaltyBreakTemplateDeclaration: 10
133+
PenaltyExcessCharacter: 1000000
134+
PenaltyReturnTypeOnItsOwnLine: 60
135+
PenaltyIndentedWhitespace: 0
136+
PointerAlignment: Left
137+
PPIndentWidth: -1
138+
ReferenceAlignment: Pointer
139+
ReflowComments: true
140+
ShortNamespaceLines: 1
141+
SortIncludes: CaseSensitive
142+
SortJavaStaticImport: Before
143+
SortUsingDeclarations: true
144+
SpaceAfterCStyleCast: true
145+
SpaceAfterLogicalNot: false
146+
SpaceAfterTemplateKeyword: true
147+
SpaceBeforeAssignmentOperators: true
148+
SpaceBeforeCaseColon: false
149+
SpaceBeforeCpp11BracedList: false
150+
SpaceBeforeCtorInitializerColon: true
151+
SpaceBeforeInheritanceColon: true
152+
SpaceBeforeParens: ControlStatements
153+
SpaceAroundPointerQualifiers: Default
154+
SpaceBeforeRangeBasedForLoopColon: true
155+
SpaceInEmptyBlock: true
156+
SpaceInEmptyParentheses: false
157+
SpacesBeforeTrailingComments: 3
158+
SpacesInAngles: Never
159+
SpacesInConditionalStatement: false
160+
SpacesInContainerLiterals: true
161+
SpacesInCStyleCastParentheses: false
162+
SpacesInLineCommentPrefix:
163+
Minimum: 1
164+
Maximum: -1
165+
SpacesInParentheses: false
166+
SpacesInSquareBrackets: false
167+
SpaceBeforeSquareBrackets: false
168+
BitFieldColonSpacing: Both
169+
Standard: Latest
170+
StatementAttributeLikeMacros:
171+
- Q_EMIT
172+
StatementMacros:
173+
- Q_UNUSED
174+
- QT_REQUIRE_VERSION
175+
TabWidth: 4
176+
UseCRLF: false
177+
UseTab: Never
178+
WhitespaceSensitiveMacros:
179+
- STRINGIZE
180+
- PP_STRINGIZE
181+
- BOOST_PP_STRINGIZE
182+
- NS_SWIFT_NAME
183+
- CF_SWIFT_NAME
184+
...
185+

.github/workflows/cmake.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: CMake
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
env:
10+
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
11+
BUILD_TYPE: Release
12+
13+
jobs:
14+
build:
15+
# The CMake configure and build commands are platform agnostic and should work equally
16+
# well on Windows or Mac. You can convert this to a matrix build if you need
17+
# cross-platform coverage.
18+
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
19+
runs-on: ubuntu-latest
20+
21+
env:
22+
CXX: g++-10
23+
24+
steps:
25+
- uses: actions/checkout@v2
26+
27+
- name: Configure CMake
28+
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
29+
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
30+
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
31+
32+
- name: Build
33+
# Build your program with the given configuration
34+
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
35+
36+
- name: Test
37+
working-directory: ${{github.workspace}}/build
38+
# execute tests defined by the CMake configuration.
39+
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
40+
run: ctest -C ${{env.BUILD_TYPE}} --rerun-failed --output-on-failure
41+
42+

.gitignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,14 @@
3030
*.exe
3131
*.out
3232
*.app
33+
34+
#dirs
35+
build
36+
source/_static
37+
source/api
38+
source/_template
39+
40+
#editor-artifacts
41+
*.sublime*
42+
compile_commands.*
43+
.cache

CMakeLists.txt

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
# MMM"""AMV db `7MM"""Yp,
2+
# M' AMV ;MM: MM Yb
3+
# ' AMV ,V^MM. MM dP
4+
# AMV ,M `MM MM"""bg.
5+
# AMV , AbmmmqMA MM `Y
6+
# AMV ,M A' VML MM ,9
7+
# AMVmmmmMM .AMA. .AMMA..JMMmmmd9
8+
9+
cmake_minimum_required(VERSION 3.7...3.18 FATAL_ERROR)
10+
11+
project(ZAB, CXX)
12+
13+
set(CMAKE_CXX_FLAGS_DEBUG "-DDEBUG -Og -g")
14+
set(CMAKE_CXX_FLAGS_RELEASE "-DRELEASE -O3 -g")
15+
16+
set(CMAKE_CXX_STANDARD 20)
17+
18+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -fuse-linker-plugin -D_FILE_OFFSET_BITS=64")
19+
20+
enable_testing()
21+
22+
add_library(zab STATIC
23+
src/event_loop.cpp
24+
src/engine.cpp
25+
src/signal_handler.cpp
26+
src/descriptor_notifications.cpp
27+
src/file_io_overlay.cpp
28+
src/network_overlay.cpp
29+
src/tcp_stream.cpp
30+
)
31+
32+
target_compile_options(zab PUBLIC
33+
-fcoroutines
34+
-pthread
35+
-Wall
36+
-Wextra
37+
)
38+
39+
target_include_directories(zab PUBLIC
40+
includes
41+
)
42+
43+
44+
macro(add_zab_test test)
45+
46+
message(STATUS "Adding test ${test}")
47+
48+
add_executable(${test} test/${test}.cpp)
49+
50+
target_compile_options(${test} PUBLIC
51+
-fcoroutines
52+
-g
53+
-pthread
54+
-Wall
55+
-Wextra
56+
)
57+
58+
target_include_directories(${test} PUBLIC
59+
includes
60+
)
61+
62+
target_link_libraries(
63+
${test} PUBLIC
64+
zab -lpthread -latomic
65+
)
66+
67+
add_test(
68+
NAME ${test}
69+
COMMAND ${test}
70+
)
71+
72+
endmacro()
73+
74+
add_zab_test(test-event_loop)
75+
add_zab_test(test-engine_enabled)
76+
add_zab_test(test-engine_awaitable)
77+
add_zab_test(test-signal_handler)
78+
add_zab_test(test-pause_token)
79+
add_zab_test(test-async_latch)
80+
add_zab_test(test-wait_for)
81+
add_zab_test(test-async_mutex)
82+
add_zab_test(test-async_semaphore)
83+
add_zab_test(test-async_barrier)
84+
add_zab_test(test-defer_block_promise)
85+
add_zab_test(test-visitor_promise)
86+
add_zab_test(test-file_io_overlay)
87+
add_zab_test(test-network_overlay)
88+
89+
macro(add_zab_example example)
90+
91+
message(STATUS "Adding example ${example}")
92+
93+
add_executable(${example} example/${example}.cpp)
94+
95+
target_compile_options(${example} PUBLIC
96+
-fcoroutines
97+
-g
98+
-pthread
99+
-Wall
100+
-Wextra
101+
)
102+
103+
target_include_directories(${example} PUBLIC
104+
includes
105+
)
106+
107+
target_link_libraries(
108+
${example} PUBLIC
109+
zab -lpthread -latomic
110+
)
111+
112+
endmacro()
113+
114+
115+
add_zab_example(echo_server)

0 commit comments

Comments
 (0)