shithub: rgbds

Download patch

ref: 3c15b141e07a099bbb33e092d594efa95ea8074e
parent: 72f801283df68672dc568c6acd9345bb4f01d46f
author: Antonio Niño Díaz <[email protected]>
date: Tue Jan 2 11:25:04 EST 2018

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 <[email protected]>

--- /dev/null
+++ b/.checkpatch.conf
@@ -1,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
--- a/.gitignore
+++ b/.gitignore
@@ -5,3 +5,4 @@
 *.o
 *.exe
 *.html
+.checkpatch-camelcase.*
--- a/Makefile
+++ b/Makefile
@@ -7,6 +7,7 @@
 STRIP		:= -s
 BINMODE		:= 555
 MANMODE		:= 444
+CHECKPATCH	:= ../linux/scripts/checkpatch.pl
 
 # Other variables
 
@@ -143,6 +144,25 @@
 	$Qinstall -m ${MANMODE} src/link/rgblink.1 ${DESTDIR}${mandir}/man1/rgblink.1
 	$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
--- a/README.md
+++ b/README.md
@@ -123,9 +123,11 @@
 
 - `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.
@@ -139,6 +141,9 @@
 - `BINMODE`: Permissions of the installed binaries. Defaults to `555`.
 
 - `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