Add checkpatch.pl config file and Makefile targets

This is used to verify the coding style of patches.

Signed-off-by: Antonio Niño Díaz <antonio_nd@outlook.com>
This commit is contained in:
Antonio Niño Díaz
2018-01-02 16:25:04 +01:00
parent 72f801283d
commit 3c15b141e0
4 changed files with 91 additions and 2 deletions

63
.checkpatch.conf Normal file
View File

@@ -0,0 +1,63 @@
# Configuration for checkpatch.pl
# ===============================
# Enable more tests
--strict
# Quiet
--quiet
# No per-file summary
--no-summary
# Don't expect the Linux kernel tree
--no-tree
# Show file line, not input line
--showfile
# List of ignored rules
# ---------------------
# Allow the usage of 'extern' in .c files
--ignore AVOID_EXTERNS
# There's no BIT macro
--ignore BIT_MACRO
# Allow CamelCase
--ignore CAMELCASE
# Comparing to NULL explicitly isn't a bad thing
--ignore COMPARISON_TO_NULL
# Causes false positives
--ignore COMPLEX_MACRO
# Don't complain about structs not being const
--ignore CONST_STRUCT
# Do not check the format of commit messages
--ignore GIT_COMMIT_ID
# We don't have a MAINTAINERS file, don't complain about it.
--ignore FILE_PATH_CHANGES
# Writing the continuation on the start of the line can make it clearer
--ignore LOGICAL_CONTINUATIONS
# Don't complain if a line that contains a string is too long. It's better to
# have a really long line that can be found with grep.
--ignore LONG_LINE_STRING
# Allow new typedefs
--ignore NEW_TYPEDEFS
# Prefer stdint.h types over kernel types
--ignore PREFER_KERNEL_TYPES
# Parentheses can make the code clearer
--ignore UNNECESSARY_PARENTHESES
# Don't complain when files are modified in 'include/asm'
--ignore MODIFIED_INCLUDE_ASM

1
.gitignore vendored
View File

@@ -5,3 +5,4 @@ rgbgfx
*.o
*.exe
*.html
.checkpatch-camelcase.*

View File

@@ -7,6 +7,7 @@ mandir := ${PREFIX}/man
STRIP := -s
BINMODE := 555
MANMODE := 444
CHECKPATCH := ../linux/scripts/checkpatch.pl
# Other variables
@@ -144,6 +145,25 @@ install: all
$Qinstall -m ${MANMODE} src/link/rgblink.5 ${DESTDIR}${mandir}/man5/rgblink.5
$Qinstall -m ${MANMODE} src/gfx/rgbgfx.1 ${DESTDIR}${mandir}/man1/rgbgfx.1
# Target used to check the coding style of the whole codebase. '.y' and '.l'
# files aren't checked, unfortunately...
checkcodebase:
$Qfor file in `git ls-files | grep -E '\.c|\.h'`; do \
${CHECKPATCH} -f "$$file"; \
done
# Target used to check the coding style of the patches from the upstream branch
# to the HEAD. Runs checkpatch once for each commit between the current HEAD and
# the first common commit between the HEAD and origin/develop. '.y' and '.l'
# files aren't checked, unfortunately...
checkpatch:
$Qeval COMMON_COMMIT=$$(git merge-base HEAD origin/develop); \
for commit in `git rev-list $$COMMON_COMMIT..HEAD`; do \
echo "[*] Analyzing commit "$$commit"" && \
git format-patch --stdout "$$commit~..$$commit" \
| ${CHECKPATCH} - || true;\
done
# Target for the project maintainer to easily create web manuals.
# It relies on mandoc: http://mdocml.bsd.lv

View File

@@ -123,9 +123,11 @@ This is the complete list of user-defined variables:
- `PREFIX`: Location where RGBDS will be installed. Defaults to `/usr/local`.
- `bindir`: Location where the binaries will be installed. Defaults to `${PREFIX}/bin`.
- `bindir`: Location where the binaries will be installed. Defaults to
`${PREFIX}/bin`.
- `mandir`: Location where the manpages will be installed. Defaults to `${PREFIX}/man`.
- `mandir`: Location where the manpages will be installed. Defaults to
`${PREFIX}/man`.
- `DESTDIR`: This is prepended to all paths during the installation. It is
mainly used for packaging.
@@ -140,6 +142,9 @@ This is the complete list of user-defined variables:
- `MANMODE`: Permissions of the installed manpages. Defaults to `444`.
- `CHECKPATCH`: Path of the script `checkpatch.pl` of the Linux kernel. Defaults
to `../linux/scripts/checkpatch.pl`.
## 3 History
- Around 1997, Carsten Sorensen (AKA SurfSmurf) writes ASMotor as a