commit cc22eacce6b080427a041f340523d0f6e1022c3c Author: LUCASTUCIOUS Date: Wed Mar 5 08:52:49 2025 +0100 Initial commit diff --git a/.tools/.clang-format b/.tools/.clang-format new file mode 100644 index 0000000..f360e09 --- /dev/null +++ b/.tools/.clang-format @@ -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 diff --git a/.tools/clang-format.exe b/.tools/clang-format.exe new file mode 100644 index 0000000..036faf3 Binary files /dev/null and b/.tools/clang-format.exe differ diff --git a/.tools/format_code.sh b/.tools/format_code.sh new file mode 100644 index 0000000..dc7a5fc --- /dev/null +++ b/.tools/format_code.sh @@ -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 \ No newline at end of file diff --git a/.tools/install_hook.sh b/.tools/install_hook.sh new file mode 100644 index 0000000..d1f24e7 --- /dev/null +++ b/.tools/install_hook.sh @@ -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!" \ No newline at end of file