Format: Add format check script and enforce format checking
Signed-off-by: Tomasz Michalak <tmichalak@antmicro.com>
diff --git a/.github/workflows/build-and-test.sh b/.github/workflows/build-and-test.sh
index 8fd95f9..6a33c39 100755
--- a/.github/workflows/build-and-test.sh
+++ b/.github/workflows/build-and-test.sh
@@ -23,3 +23,9 @@
end_section
##########################################################################
+
+start_section Cleanup
+make clean -j`nproc`
+end_section
+
+##########################################################################
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 42f5810..5fb51b9 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -18,7 +18,7 @@
sudo apt-get install git g++-9 build-essential bison flex \
libreadline-dev gawk tcl-dev libffi-dev git graphviz xdot \
pkg-config libboost-system-dev libboost-python-dev \
- libboost-filesystem-dev zlib1g-dev
+ libboost-filesystem-dev zlib1g-dev clang-format-5.0
- name: Install Yosys
run: source .github/workflows/setup.sh
@@ -29,3 +29,8 @@
run: source .github/workflows/build-and-test.sh
env:
OS: ${{ runner.os }}
+
+ - name: Format
+ run: source .github/workflows/format-check.sh
+ env:
+ OS: ${{ runner.os }}
diff --git a/.github/workflows/format-check.sh b/.github/workflows/format-check.sh
new file mode 100755
index 0000000..20814bf
--- /dev/null
+++ b/.github/workflows/format-check.sh
@@ -0,0 +1,14 @@
+#! /bin/bash
+
+set -e
+
+source .github/workflows/common.sh
+
+##########################################################################
+
+start_section Formatting
+make format -j`nproc`
+test $(git status --porcelain | wc -l) -eq 0 || { git diff; false; }
+end_section
+
+##########################################################################
diff --git a/Makefile b/Makefile
index 1fe1c9e..0d54794 100644
--- a/Makefile
+++ b/Makefile
@@ -32,5 +32,5 @@
CLANG_FORMAT ?= clang-format-5.0
format:
- find . -name \*.cc -print0 | xargs -0 -P $$(nproc) ${CLANG_FORMAT} -style=file -i
- find . -name \*.h -print0 | xargs -0 -P $$(nproc) ${CLANG_FORMAT} -style=file -i
+ find . -name \*.cc -and -not -path './third_party/*' -print0 | xargs -0 -P $$(nproc) ${CLANG_FORMAT} -style=file -i
+ find . -name \*.h -and -not -path './third_party/*' -print0 | xargs -0 -P $$(nproc) ${CLANG_FORMAT} -style=file -i
diff --git a/sdc-plugin/.clang-format b/sdc-plugin/.clang-format
deleted file mode 100644
index 3b94352..0000000
--- a/sdc-plugin/.clang-format
+++ /dev/null
@@ -1,151 +0,0 @@
----
-Language: Cpp
-BasedOnStyle: Chromium
-AccessModifierOffset: -1
-AlignAfterOpenBracket: Align
-AlignConsecutiveAssignments: false
-AlignConsecutiveDeclarations: false
-AlignEscapedNewlines: Left
-AlignOperands: true
-AlignTrailingComments: true
-AllowAllParametersOfDeclarationOnNextLine: true
-AllowShortBlocksOnASingleLine: false
-AllowShortCaseLabelsOnASingleLine: false
-AllowShortFunctionsOnASingleLine: All
-AllowShortIfStatementsOnASingleLine: true
-AllowShortLoopsOnASingleLine: true
-AlwaysBreakAfterDefinitionReturnType: None
-AlwaysBreakAfterReturnType: None
-AlwaysBreakBeforeMultilineStrings: true
-AlwaysBreakTemplateDeclarations: Yes
-BinPackArguments: true
-BinPackParameters: true
-BraceWrapping:
- AfterClass: false
- AfterControlStatement: false
- AfterEnum: false
- AfterFunction: false
- AfterNamespace: false
- AfterObjCDeclaration: false
- AfterStruct: false
- AfterUnion: false
- AfterExternBlock: false
- BeforeCatch: false
- BeforeElse: false
- IndentBraces: false
- SplitEmptyFunction: true
- SplitEmptyRecord: true
- SplitEmptyNamespace: true
-BreakBeforeBinaryOperators: None
-BreakBeforeBraces: Attach
-BreakBeforeInheritanceComma: false
-BreakInheritanceList: BeforeColon
-BreakBeforeTernaryOperators: true
-BreakConstructorInitializersBeforeComma: false
-BreakConstructorInitializers: BeforeColon
-BreakAfterJavaFieldAnnotations: false
-BreakStringLiterals: true
-ColumnLimit: 80
-CommentPragmas: '^ IWYU pragma:'
-CompactNamespaces: false
-ConstructorInitializerAllOnOneLineOrOnePerLine: true
-ConstructorInitializerIndentWidth: 4
-ContinuationIndentWidth: 4
-Cpp11BracedListStyle: true
-DerivePointerAlignment: true
-DisableFormat: false
-ExperimentalAutoDetectBinPacking: false
-FixNamespaceComments: true
-ForEachMacros:
- - foreach
- - Q_FOREACH
- - BOOST_FOREACH
-IncludeBlocks: Preserve
-IncludeCategories:
- - Regex: '^<ext/.*\.h>'
- Priority: 2
- - Regex: '^<.*\.h>'
- Priority: 1
- - Regex: '^<.*'
- Priority: 2
- - Regex: '.*'
- Priority: 3
-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: ''
- BasedOnStyle: google
-ReflowComments: true
-SortIncludes: true
-SortUsingDeclarations: true
-SpaceAfterCStyleCast: false
-SpaceAfterTemplateKeyword: true
-SpaceBeforeAssignmentOperators: true
-SpaceBeforeCpp11BracedList: false
-SpaceBeforeCtorInitializerColon: true
-SpaceBeforeInheritanceColon: true
-SpaceBeforeParens: ControlStatements
-SpaceBeforeRangeBasedForLoopColon: true
-SpaceInEmptyParentheses: false
-SpacesBeforeTrailingComments: 2
-SpacesInAngles: false
-SpacesInContainerLiterals: true
-SpacesInCStyleCastParentheses: false
-SpacesInParentheses: false
-SpacesInSquareBrackets: false
-Standard: Auto
-StatementMacros:
- - Q_UNUSED
- - QT_REQUIRE_VERSION
-TabWidth: 8
-UseTab: ForIndentation
-...
-