Skip to content

Commit

Permalink
Update to .clang-format (#222)
Browse files Browse the repository at this point in the history
* Apply clang format

* Add code format robot

* Set the ColumnLimit to 100

* [pre-commit.ci] auto fixes from pre-commit.com hooks

* Remove code-format in workflows

* Enable Restyled

* Enable auto code-format bot and disable restyled

* Apply code-format changes

* Minor fixes

* Apply code-format changes

* Delete .clang-tidy

* Fixing clang-format style

* Fix code-format bot

* Apply code-format changes

* [pre-commit.ci] auto fixes from pre-commit.com hooks

* Cleanup code-format GH Actions

* Modify the step names in code-format Actions

* Cleanup code-format GH Actions

* Revert the changes in ORT CmakeLists

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: zhiqwang <[email protected]>
  • Loading branch information
3 people authored Nov 1, 2021
1 parent cc3259a commit e5e1408
Show file tree
Hide file tree
Showing 11 changed files with 1,443 additions and 998 deletions.
88 changes: 88 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
---
AccessModifierOffset: -1
AlignAfterOpenBracket: AlwaysBreak
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlinesLeft: true
AlignOperands: false
AlignTrailingComments: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: true
BinPackArguments: false
BinPackParameters: false
BraceWrapping:
AfterClass: false
AfterControlStatement: false
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Attach
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: false
ColumnLimit: 100
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DisableFormat: false
ForEachMacros: [ FOR_EACH_RANGE, FOR_EACH, ]
IncludeCategories:
- Regex: '^<.*\.h(pp)?>'
Priority: 1
- Regex: '^<.*'
Priority: 2
- Regex: '.*'
Priority: 3
IndentCaseLabels: true
IndentWidth: 2
IndentWrappedFunctionNames: false
KeepEmptyLinesAtTheStartOfBlocks: false
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: false
PenaltyBreakBeforeFirstCallParameter: 1
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 2000000
PointerAlignment: Left
ReflowComments: true
SortIncludes: true
SpaceAfterCStyleCast: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp11
TabWidth: 8
UseTab: Never
...
25 changes: 25 additions & 0 deletions .github/workflows/code-format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Code format

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

jobs:
clang-format:
runs-on: ubuntu-latest

steps:
- name: Clone repository
uses: actions/checkout@v2
- name: Run clang format
run: |
curl https://oss-clang-format.s3.us-east-2.amazonaws.com/linux64/clang-format-linux64 -o clang-format
chmod +x clang-format
sudo mv clang-format /opt/clang-format
python tools/run_clang_format.py --files deployment test/tracing --recursive --clang_format_executable /opt/clang-format --style file --fix
- name: Apply code-format changes
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Apply code-format changes
12 changes: 6 additions & 6 deletions deployment/libtorch/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.14)

project(yolo_inference)
project(yolort_torch)

find_package(Torch REQUIRED)
find_package(TorchVision REQUIRED)
Expand All @@ -20,18 +20,18 @@ message(STATUS " include path: ${OpenCV_INCLUDE_DIRS}")
# This due to some headers importing Python.h
find_package(Python3 COMPONENTS Development)

FILE(GLOB YOLO_SOURCE_FILES *.cpp)
file(GLOB YOLO_SOURCE_FILES *.cpp)

add_executable(yolo_inference ${YOLO_SOURCE_FILES})
target_compile_features(yolo_inference PUBLIC cxx_range_for)
add_executable(yolort_torch ${YOLO_SOURCE_FILES})
target_compile_features(yolort_torch PUBLIC cxx_range_for)

target_link_libraries(
yolo_inference
yolort_torch
${OpenCV_LIBS}
${TORCH_LIBRARIES}
TorchVision::TorchVision
Python3::Python
)

# set C++14 to compile
set_property(TARGET yolo_inference PROPERTY CXX_STANDARD 14)
set_property(TARGET yolort_torch PROPERTY CXX_STANDARD 14)
Loading

0 comments on commit e5e1408

Please sign in to comment.