Skip to content

Commit

Permalink
Merge branch 'format'
Browse files Browse the repository at this point in the history
  • Loading branch information
kimci86 committed Feb 6, 2024
2 parents 49a5a8e + 6b9218b commit 746fae9
Show file tree
Hide file tree
Showing 35 changed files with 1,370 additions and 1,205 deletions.
39 changes: 39 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
Language: Cpp
BasedOnStyle: LLVM
AccessModifierOffset: -4
AlignConsecutiveAssignments:
Enabled: true
AlignConsecutiveDeclarations:
Enabled: true
AllowShortFunctionsOnASingleLine: Empty
AlwaysBreakTemplateDeclarations: Yes
BraceWrapping:
AfterCaseLabel: true
AfterClass: true
AfterControlStatement: Always
AfterEnum: true
AfterFunction: true
AfterNamespace: true
AfterObjCDeclaration: true
AfterStruct: true
AfterUnion: true
AfterExternBlock: true
BeforeCatch: true
BeforeElse: true
BeforeLambdaBody: true
BreakBeforeBraces: Custom
BreakConstructorInitializers: BeforeComma
ColumnLimit: 120
QualifierAlignment: Left
ConstructorInitializerIndentWidth: 0
PackConstructorInitializers: Never
IncludeBlocks: Regroup
IncludeCategories:
- Regex: '".*"'
Priority: 1
- Regex: '<.+>'
Priority: 2
IndentWidth: 4
PointerAlignment: Left
...
19 changes: 18 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,27 @@ jobs:
build/*.zip
build/*.tar.gz
format:
name: Formatting
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Configure project
run: cmake -S . -B build -DBKCRACK_CLANG_FORMAT_EXECUTABLE=/usr/bin/clang-format-15

- name: Format C++ code
run: cmake --build build --target format

- name: Check for difference
run: git diff --exit-code

release:
name: Release
runs-on: ubuntu-latest
needs: build
needs: [build, format]
if: startsWith(github.ref, 'refs/tags/')

steps:
Expand Down
10 changes: 10 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@ if(BKCRACK_BUILD_TESTING)
add_subdirectory(tests)
endif()

# code formatting
find_program(BKCRACK_CLANG_FORMAT_EXECUTABLE clang-format DOC "Path to clang-format program used to format C++ code.")
if(BKCRACK_CLANG_FORMAT_EXECUTABLE)
get_target_property(files_to_format bkcrack SOURCES)
add_custom_target(format
COMMAND ${BKCRACK_CLANG_FORMAT_EXECUTABLE} -i ${files_to_format}
COMMENT "Formatting C++ code with ${BKCRACK_CLANG_FORMAT_EXECUTABLE}"
VERBATIM)
endif()

# install rules
install(DIRECTORY example DESTINATION .)
install(DIRECTORY tools DESTINATION .)
Expand Down
Loading

0 comments on commit 746fae9

Please sign in to comment.