Skip to content

Commit

Permalink
Initial commit of ZAB v0.0.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Donald-Rupin authored and Donald-Rupin committed Sep 21, 2021
1 parent 874dbfa commit 93f26cb
Show file tree
Hide file tree
Showing 53 changed files with 15,800 additions and 1 deletion.
185 changes: 185 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
---
Language: Cpp
# BasedOnStyle: LLVM
AccessModifierOffset: 3
AlignAfterOpenBracket: AlwaysBreak
AlignArrayOfStructures: None
AlignConsecutiveMacros: AcrossEmptyLinesAndComments
AlignConsecutiveAssignments: AcrossComments
AlignConsecutiveBitFields: AcrossComments
AlignConsecutiveDeclarations: AcrossComments
AlignEscapedNewlines: Right
AlignOperands: Align
AlignTrailingComments: true
AllowAllArgumentsOnNextLine: false
AllowAllConstructorInitializersOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortEnumsOnASingleLine: false
AllowShortBlocksOnASingleLine: Always
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Inline
AllowShortLambdasOnASingleLine: Inline
AllowShortIfStatementsOnASingleLine: WithoutElse
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: All
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: Yes
AttributeMacros:
- __capability
BinPackArguments: false
BinPackParameters: false
BraceWrapping:
AfterCaseLabel: false
AfterClass: false
AfterControlStatement: Always
AfterEnum: false
AfterFunction: true
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
AfterExternBlock: true
BeforeCatch: false
BeforeElse: true
BeforeLambdaBody: true
BeforeWhile: false
IndentBraces: false
SplitEmptyFunction: false
SplitEmptyRecord: false
SplitEmptyNamespace: false
BreakBeforeBinaryOperators: None
BreakBeforeConceptDeclarations: true
BreakBeforeBraces: Custom
BreakBeforeInheritanceComma: false
BreakInheritanceList: BeforeColon
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeColon
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
ColumnLimit: 100
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DeriveLineEnding: true
DerivePointerAlignment: false
DisableFormat: false
EmptyLineAfterAccessModifier: Always
EmptyLineBeforeAccessModifier: Always
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IfMacros:
- KJ_IF_MAYBE
IncludeBlocks: Regroup
IncludeCategories:
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
Priority: 0
SortPriority: 0
CaseSensitive: false
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
Priority: 1
SortPriority: 0
CaseSensitive: false
- Regex: '^(<|"(zab)/)'
Priority: 2
SortPriority: 2
CaseSensitive: false
- Regex: '^.*/.*'
Priority: 3
SortPriority: 3
- Regex: '.*'
Priority: 4
SortPriority: 4
CaseSensitive: false
IncludeIsMainRegex: '(Test)?$'
IncludeIsMainSourceRegex: ''
IndentAccessModifiers: true
IndentCaseLabels: true
IndentCaseBlocks: true
IndentGotoLabels: true
IndentPPDirectives: AfterHash
IndentExternBlock: AfterExternBlock
IndentRequires: true
IndentWidth: 4
IndentWrappedFunctionNames: false
InsertTrailingCommas: None
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: true
LambdaBodyIndentation: Signature
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: All
ObjCBinPackProtocolList: Auto
ObjCBlockIndentWidth: 2
ObjCBreakBeforeNestedBlockParam: true
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PenaltyIndentedWhitespace: 0
PointerAlignment: Left
PPIndentWidth: -1
ReferenceAlignment: Pointer
ReflowComments: true
ShortNamespaceLines: 1
SortIncludes: CaseSensitive
SortJavaStaticImport: Before
SortUsingDeclarations: true
SpaceAfterCStyleCast: true
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeCaseColon: false
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceAroundPointerQualifiers: Default
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyBlock: true
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 3
SpacesInAngles: Never
SpacesInConditionalStatement: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInLineCommentPrefix:
Minimum: 1
Maximum: -1
SpacesInParentheses: false
SpacesInSquareBrackets: false
SpaceBeforeSquareBrackets: false
BitFieldColonSpacing: Both
Standard: Latest
StatementAttributeLikeMacros:
- Q_EMIT
StatementMacros:
- Q_UNUSED
- QT_REQUIRE_VERSION
TabWidth: 4
UseCRLF: false
UseTab: Never
WhitespaceSensitiveMacros:
- STRINGIZE
- PP_STRINGIZE
- BOOST_PP_STRINGIZE
- NS_SWIFT_NAME
- CF_SWIFT_NAME
...

42 changes: 42 additions & 0 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: CMake

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release

jobs:
build:
# The CMake configure and build commands are platform agnostic and should work equally
# well on Windows or Mac. You can convert this to a matrix build if you need
# cross-platform coverage.
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
runs-on: ubuntu-latest

env:
CXX: g++-10

steps:
- uses: actions/checkout@v2

- name: Configure CMake
# 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: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}

- name: Build
# Build your program with the given configuration
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}

- name: Test
working-directory: ${{github.workspace}}/build
# execute tests defined by the CMake configuration.
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ctest -C ${{env.BUILD_TYPE}} --rerun-failed --output-on-failure


11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,14 @@
*.exe
*.out
*.app

#dirs
build
source/_static
source/api
source/_template

#editor-artifacts
*.sublime*
compile_commands.*
.cache
115 changes: 115 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
# MMM"""AMV db `7MM"""Yp,
# M' AMV ;MM: MM Yb
# ' AMV ,V^MM. MM dP
# AMV ,M `MM MM"""bg.
# AMV , AbmmmqMA MM `Y
# AMV ,M A' VML MM ,9
# AMVmmmmMM .AMA. .AMMA..JMMmmmd9

cmake_minimum_required(VERSION 3.7...3.18 FATAL_ERROR)

project(ZAB, CXX)

set(CMAKE_CXX_FLAGS_DEBUG "-DDEBUG -Og -g")
set(CMAKE_CXX_FLAGS_RELEASE "-DRELEASE -O3 -g")

set(CMAKE_CXX_STANDARD 20)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -fuse-linker-plugin -D_FILE_OFFSET_BITS=64")

enable_testing()

add_library(zab STATIC
src/event_loop.cpp
src/engine.cpp
src/signal_handler.cpp
src/descriptor_notifications.cpp
src/file_io_overlay.cpp
src/network_overlay.cpp
src/tcp_stream.cpp
)

target_compile_options(zab PUBLIC
-fcoroutines
-pthread
-Wall
-Wextra
)

target_include_directories(zab PUBLIC
includes
)


macro(add_zab_test test)

message(STATUS "Adding test ${test}")

add_executable(${test} test/${test}.cpp)

target_compile_options(${test} PUBLIC
-fcoroutines
-g
-pthread
-Wall
-Wextra
)

target_include_directories(${test} PUBLIC
includes
)

target_link_libraries(
${test} PUBLIC
zab -lpthread -latomic
)

add_test(
NAME ${test}
COMMAND ${test}
)

endmacro()

add_zab_test(test-event_loop)
add_zab_test(test-engine_enabled)
add_zab_test(test-engine_awaitable)
add_zab_test(test-signal_handler)
add_zab_test(test-pause_token)
add_zab_test(test-async_latch)
add_zab_test(test-wait_for)
add_zab_test(test-async_mutex)
add_zab_test(test-async_semaphore)
add_zab_test(test-async_barrier)
add_zab_test(test-defer_block_promise)
add_zab_test(test-visitor_promise)
add_zab_test(test-file_io_overlay)
add_zab_test(test-network_overlay)

macro(add_zab_example example)

message(STATUS "Adding example ${example}")

add_executable(${example} example/${example}.cpp)

target_compile_options(${example} PUBLIC
-fcoroutines
-g
-pthread
-Wall
-Wextra
)

target_include_directories(${example} PUBLIC
includes
)

target_link_libraries(
${example} PUBLIC
zab -lpthread -latomic
)

endmacro()


add_zab_example(echo_server)
Loading

0 comments on commit 93f26cb

Please sign in to comment.