Skip to content

Commit

Permalink
add lint
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhuLingQing committed Mar 17, 2024
1 parent c9320eb commit 7306ca4
Show file tree
Hide file tree
Showing 5 changed files with 572 additions and 0 deletions.
2 changes: 2 additions & 0 deletions bash_build.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#for no cmake installed.

RED=$(tput setaf 1)
GREEN=$(tput setaf 2)
NCOLOR=$(tput sgr0)
Expand Down
126 changes: 126 additions & 0 deletions ci/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
---
Language: Cpp
# BasedOnStyle: LLVM
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: DontAlign
AlignOperands: true
AlignTrailingComments: false
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: true
AllowShortCaseLabelsOnASingleLine: true
AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: true
AllowShortLoopsOnASingleLine: true
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: true
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
AfterClass: true
AfterControlStatement: true
AfterEnum: true
AfterFunction: true
AfterNamespace: true
AfterObjCDeclaration: true
AfterStruct: true
AfterUnion: true
AfterExternBlock: true
BeforeCatch: true
BeforeElse: true
IndentBraces: true
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakBeforeBinaryOperators: All
BreakBeforeBraces: Attach
BreakBeforeInheritanceComma: true
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: true
BreakConstructorInitializers: BeforeComma
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
ColumnLimit: 120
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
ForEachMacros:
- Q_FOREACH
- BOOST_FOREACH

# Include grouping/sorting
SortIncludes: false
IncludeBlocks: Regroup
IncludeCategories:
- Regex: '"V3Pch.*\.h"'
Priority: -2 # Precompiled headers
- Regex: '"(config_build|verilated_config|verilatedos)\.h"'
Priority: -1 # Sepecials before main header
- Regex: '(<|")verilated.*'
Priority: 1 # Runtime headers
- Regex: '"V3.*__gen.*\.h"'
Priority: 3 # Generated internal headers separately
- Regex: '"V3.*"'
Priority: 2 # Internal header
- Regex: '".*"'
Priority: 4 # Other non-system headers
- Regex: '<[[:alnum:]_.]+>'
Priority: 5 # Simple system headers next
- Regex: '<.*>'
Priority: 6 # Other system headers next
IncludeIsMainRegex: '$'

IndentCaseLabels: false
IndentPPDirectives: None
IndentWidth: 4
IndentWrappedFunctionNames: false
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: true
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBlockIndentWidth: 4
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PenaltyBreakAssignment: 4
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Right
ReflowComments: true
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 4
SpacesInAngles: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInLineCommentPrefix:
Minimum: 0
Maximum: -1
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp11
TabWidth: 8
UseTab: Never
BitFieldColonSpacing: None
...
23 changes: 23 additions & 0 deletions ci/ci-lint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash
set -e
set -o pipefail

REPO_DIR=$(cd "$(dirname $0)";pwd)/..
CURR_DIR=${REPO_DIR}
LIB_DIR=${REPO_DIR}
TESTS_DIR=${REPO_DIR}/tests

clang-format --version
if [ $# -lt 1 ]; then
# just print the list of files
echo "Lint test: C++ Lint (clang-format) check for check start"
python3 "${CURR_DIR}"/ci/run_clang_format.py --clang-format-executable clang-format -r "${LIB_DIR}" --exclude "${REPO_DIR}/build"
python3 "${CURR_DIR}"/ci/run_clang_format.py --clang-format-executable clang-format -r "${TESTS_DIR}" --exclude "${REPO_DIR}/build"
echo "Lint test: C++ Lint (clang-format) check for check passed"
elif [ $1 == "fix" ]; then
# format file instead of printing differences
echo "Lint test: C++ Lint check for (clang-format) auto fix start"
python3 "${CURR_DIR}"/ci/run_clang_format.py --clang-format-executable clang-format -r -i "${LIB_DIR}" --exclude "${REPO_DIR}/build"
python3 "${CURR_DIR}"/ci/run_clang_format.py --clang-format-executable clang-format -r -i "${TESTS_DIR}" --exclude "${REPO_DIR}/build"
echo "Lint test: C++ Lint check for (clang-format) auto fix passed"
fi
13 changes: 13 additions & 0 deletions ci/ci-unit-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
set -e
set -o pipefail

REPO_DIR=$(cd "$(dirname $0)";pwd)/..
CURR_DIR=${REPO_DIR}/tests

pushd ${REPO_DIR}

echo "******* Unit Tests Start *******"
echo "******* All Unit Tests Passed *******"

popd
Loading

0 comments on commit 7306ca4

Please sign in to comment.