Initial commit

This commit is contained in:
Lucas 2025-03-05 08:52:49 +01:00
commit cc22eacce6
4 changed files with 202 additions and 0 deletions

138
.tools/.clang-format Normal file
View file

@ -0,0 +1,138 @@
---
Language: Cpp
AccessModifierOffset: -4
AlignAfterOpenBracket: DontAlign
AlignConsecutiveAssignments:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
AlignFunctionPointers: false
PadOperators: true
AlignConsecutiveDeclarations:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
AlignFunctionPointers: false
PadOperators: true
AlignEscapedNewlines: Left
AlignOperands: true
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: true
BinPackParameters: true
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Allman
BreakBeforeInheritanceComma: false
BreakInheritanceList: BeforeColon
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeComma
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
ColumnLimit: 132
CommentPragmas: "^ IWYU pragma:"
CompactNamespaces: true
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DisableFormat: false
FixNamespaceComments: true
ForEachMacros:
- for
IncludeBlocks: Regroup
IncludeCategories:
- Regex: .*\.generated\.h
Priority: 100
- Regex: .*(PCH).*
Priority: -1
- Regex: '".*"'
Priority: 1
- Regex: ^<.*\.(h)>
Priority: 3
- Regex: ^<.*>
Priority: 4
IncludeIsMainRegex: ([-_](test|unittest))?$
IndentCaseLabels: true
IndentPPDirectives: None
IndentWidth: 4
IndentWrappedFunctionNames: false
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: false
MacroBlockBegin: ""
MacroBlockEnd: ""
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBinPackProtocolList: Never
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 1
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 200
PointerAlignment: Left
RawStringFormats:
- Language: Cpp
Delimiters:
- cc
- CC
- cpp
- Cpp
- CPP
- c++
- C++
CanonicalDelimiter: ""
BasedOnStyle: google
- Language: TextProto
Delimiters:
- pb
- PB
- proto
- PROTO
EnclosingFunctions:
- EqualsProto
- EquivToProto
- PARSE_PARTIAL_TEXT_PROTO
- PARSE_TEST_PROTO
- PARSE_TEXT_PROTO
- ParseTextOrDie
- ParseTextProtoOrDie
CanonicalDelimiter: ""
ReflowComments: true
SortIncludes: true
SortUsingDeclarations: true
SpaceAfterCStyleCast: true
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 4
SpacesInAngles: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Auto
TabWidth: 4
UseTab: Always

BIN
.tools/clang-format.exe Normal file

Binary file not shown.

52
.tools/format_code.sh Normal file
View file

@ -0,0 +1,52 @@
#!/bin/bash
# Configuration
CONFIG_FILE="$(dirname "$0")/.clang-format"
TARGET_DIRS=("Source" "Private" "Public" "Classes")
FILE_EXTS=("*.h" "*.cpp" "*.hpp" "*.c")
DRY_RUN=false
VERBOSE=false
# Parse arguments
while [[ $# -gt 0 ]]; do
case $1 in
--dry-run) DRY_RUN=true; shift ;;
--verbose) VERBOSE=true; shift ;;
--config) CONFIG_FILE="$2"; shift 2 ;;
*) echo "Unknown option: $1"; exit 1 ;;
esac
done
# Find all source files
FILES=()
for dir in "../${TARGET_DIRS[@]}"; do
for ext in "${FILE_EXTS[@]}"; do
while IFS= read -r -d $'\0' file; do
FILES+=("$file")
done < <(find "$(pwd)/$dir" -name "$ext" -print0)
done
done
# Formatting command
FORMAT_CMD="./clang-format -style=file:$CONFIG_FILE -i"
$DRY_RUN && FORMAT_CMD+=" --dry-run --Werror"
# Execute formatting
ERRORS=0
for file in "${FILES[@]}"; do
if $VERBOSE; then
echo "Checking $file"
fi
if ! $FORMAT_CMD "$file"; then
((ERRORS++))
fi
done
if [ $ERRORS -gt 0 ]; then
echo "$ERRORS files need formatting!"
exit 1
else
echo "✅ All files formatted correctly!"
exit 0
fi

12
.tools/install_hook.sh Normal file
View file

@ -0,0 +1,12 @@
#!/bin/bash
HOOKS_DIR="../.git/hooks"
PRE_PUSH_HOOK="$HOOKS_DIR/pre-push"
# Create symlink
ln -sf "$(dirname "$0")/format_code.sh" "$PRE_PUSH_HOOK"
# Set permissions
chmod +x "$PRE_PUSH_HOOK"
echo "Git hooks installed successfully!"