diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..906e38a --- /dev/null +++ b/.clang-format @@ -0,0 +1,47 @@ +--- +Language: Cpp +BasedOnStyle: Google +AccessModifierOffset: -4 +AlignEscapedNewlines: Left +AlignTrailingComments: true +AlignAfterOpenBracket: true +AllowAllArgumentsOnNextLine: true +AllowShortBlocksOnASingleLine: false +AllowShortFunctionsOnASingleLine: Empty +AllowShortIfStatementsOnASingleLine: Never +AllowShortLambdasOnASingleLine: Empty +AlwaysBreakTemplateDeclarations: "Yes" +AlignArrayOfStructures: Left +BinPackArguments: true +BinPackParameters: false +BraceWrapping: + AfterEnum: false + BeforeCatch: true + BeforeElse: true + BeforeLambdaBody: false + BeforeWhile: false +BreakBeforeBinaryOperators: NonAssignment +BreakBeforeBraces: Custom +BreakBeforeTernaryOperators: false +BreakConstructorInitializers: BeforeColon +BreakInheritanceList: BeforeColon +BreakStringLiterals: false +ColumnLimit: 0 +DerivePointerAlignment: false +#EmptyLineAfterAccessModifier: Leave +#EmptyLineBeforeAccessModifier: LogicalBlock +ExperimentalAutoDetectBinPacking: true +FixNamespaceComments: false +IndentCaseLabels: true +IndentWidth: 4 +KeepEmptyLinesAtTheStartOfBlocks: true +MaxEmptyLinesToKeep: 10 +NamespaceIndentation: All +PenaltyBreakComment: 20 +PenaltyExcessCharacter: 5 +PointerAlignment: Middle +SortUsingDeclarations: false +SpaceAfterTemplateKeyword: false +SpaceBeforeCpp11BracedList: true +SpacesBeforeTrailingComments: 1 +UseTab: Never diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..eda637f --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,71 @@ +name: Lint & Test + +on: + push: + branches: + - main + + pull_request: + types: + - opened + - reopened + - synchronize + +jobs: + # test: + # runs-on: ubuntu-latest + + # steps: + # - uses: actions/checkout@v4 + + # - name: Install dependencies + # run: sudo apt-get install -y build-essential gcc-multilib g++-multilib + + # - name: Install gcovr + # run: pip install gcovr + + # - name: Setup project + # run: cmake -S ${TEST_DIR} -B ${BUILD_DIR} -DCMAKE_BUILD_TYPE=Debug + + # - name: Build + # run: cmake --build ${BUILD_DIR} + + # # - name: Test + # # working-directory: build + # # run: ctest -V + + # - name: Test with Coverage + # working-directory: build + # run: cmake --build ${BUILD_DIR} --target os_test_coverage + + lint: + runs-on: ubuntu-latest + + strategy: + matrix: + folder: + - src + - include + - tests + + steps: + - uses: actions/checkout@v4 + + - name: Lint ${{ matrix.folder }} + uses: jidicula/clang-format-action@v4.14.0 + with: + clang-format-version: "20" + check-path: ${{ matrix.folder }} + + increment_version: + name: Increment Version + uses: automas-dev/reusable-workflows/.github/workflows/increment_version.yml@main + if: github.ref == 'refs/heads/main' + secrets: inherit + + needs: + # - test + - lint + + permissions: + contents: write diff --git a/.gitignore b/.gitignore index cccc604..ab2b409 100644 --- a/.gitignore +++ b/.gitignore @@ -1,52 +1,21 @@ -# Some rules taken from https://github.com/github/gitignore/blob/master/CMake.gitignore +# Created by https://www.gitignore.io/api/visualstudiocode +# Edit at https://www.gitignore.io/?templates=visualstudiocode -# IDE's -.vscode/ -tags - -# Compiled Object files -**/.DS_Store -*.slo -*.lo -*.o -*.obj - -# Precompiled Headers -*.gch -*.pch - -# Compiled Dynamic libraries -*.so -*.dylib -*.dll +### VisualStudioCode ### +.vscode/**/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json -# Compiled Static libraries -*.lai -*.la -*.a -*.lib +### VisualStudioCode Patch ### +# Ignore all local history of files +**/.history -# Executables -*.exe -*.out -*.app - -**/cmake-build-debug -**/CMakeCache.txt -**/cmake_install.cmake -**/install_manifest.txt -**/CMakeFiles/ -**/CTestTestfile.cmake -**/Makefile -**/*.cbp -**/CMakeScripts -**/compile_commands.json - -## Local +# End of https://www.gitignore.io/api/visualstudiocode +tags compile_commands.json -.idea/ + build/ install/ -Release/ -Debug/ diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..99907a1 --- /dev/null +++ b/Makefile @@ -0,0 +1,31 @@ + +CC=/usr/bin/gcc +CXX=/usr/bin/g++ +CONFIG=Debug +TARGET=all + +all: config build + +config: + cmake --no-warn-unused-cli \ + -DCMAKE_BUILD_TYPE=${CONFIG} \ + -DCMAKE_EXPORT_COMPILE_COMMANDS=TRUE \ + -DCMAKE_C_COMPILER=${CC} \ + -DCMAKE_CXX_COMPILER=${CXX} \ + -S${PWD} \ + -B${PWD}/build \ + -G Ninja + +build: + cmake --build ${PWD}/build --config ${CONFIG} --target ${TARGET} + +install: + cmake --install ${PWD}/build --config ${CONFIG} + +lint: + @find src include tests -name '*.c' -or -name '*.h' -or -name '*.cpp' -or -name '*.hpp' | xargs clang-format --dry-run --Werror --sort-includes + +format: + @find src include tests -name '*.c' -or -name '*.h' -or -name '*.cpp' -or -name '*.hpp' | xargs clang-format -i --Werror --sort-includes + +.PHONY: config build install lint format diff --git a/src/Wavefront.cpp b/src/Wavefront.cpp index 34e20be..187bb69 100644 --- a/src/Wavefront.cpp +++ b/src/Wavefront.cpp @@ -118,7 +118,7 @@ namespace wavefront { material->texSpecular = token.value; } } break; - case 'B': // map_Bump + case 'B': // map_Bump case 'b': { // map_bump material->texNormal = token.value; } break; diff --git a/src/WavefrontParser.cpp b/src/WavefrontParser.cpp index d30bda3..2d3b764 100644 --- a/src/WavefrontParser.cpp +++ b/src/WavefrontParser.cpp @@ -12,7 +12,7 @@ namespace wavefront { while (end < str.size() && (maxcount-- > 0)) { while (end < str.size()) { if (str[end] == delim) { - parts.push_back(str.substr(start, end-start)); + parts.push_back(str.substr(start, end - start)); start = ++end; break; }