shithub: rgbds

Download patch

ref: e99a651165c104daae1dba4737e23f964a181ee8
parent: 0ae69b3114b096cf1b0a1ed6a5740db0b00b0955
author: Antonio Niño Díaz <[email protected]>
date: Mon Apr 2 18:07:10 EDT 2018

Create makefile target to check all warnings

Remove '-Werror' from the default make target to make it easy for
regular users of RGBDS to compile the source code. Only a few basic
warnings are left in that target.

All the warnings have been moved to a new target called 'develop'. This
target is now the one used in Travis CI to check for problems during
compilation.

Signed-off-by: Antonio Niño Díaz <[email protected]>

--- a/CONTRIBUTING.rst
+++ b/CONTRIBUTING.rst
@@ -70,17 +70,22 @@
 3. Create a new branch to work on. You could still work on ``develop``, but it's
    easier that way.
 
-4. Sign off your commits: ``git commit -s``
+4. Compile your changes with ``make develop`` instead of just ``make``. This
+   target checks for additional warnings. Your patches shouldn't introduce any
+   new warning (but it may be possible to remove some warning checks if it makes
+   the code much easier).
 
-5. Follow the Linux kernel coding style, which can be found in the file
+5. Sign off your commits: ``git commit -s``
+
+6. Follow the Linux kernel coding style, which can be found in the file
    ``Documentation/process/coding-style.rst`` in the Linux kernel repository.
    Note that the coding style isn't writen on stone, if there is a good reason
    to deviate from it, it should be fine.
 
-6. Download the files ``checkpatch.pl``, ``const_structs.checkpatch`` and
+7. Download the files ``checkpatch.pl``, ``const_structs.checkpatch`` and
    ``spelling.txt`` from the folder ``scripts`` in the Linux kernel repository.
 
-7. To use ``checkpatch.pl`` you can use ``make checkpatch``, which will check
+8. To use ``checkpatch.pl`` you can use ``make checkpatch``, which will check
    the coding style of all patches between the current one and the upstream
    code. By default, the Makefile expects the script (and associate files) to be
    located in ``../linux/scripts/``, but you can place them anywhere you like as
@@ -87,7 +92,7 @@
    long as you specify it when executing the command:
    ``CHECKPATCH=../path/to/folder make checkpatch``.
 
-8. Create a pull request against the branch ``develop``.
+9. Create a pull request against the branch ``develop``.
 
-9. Be prepared to get some comments about your code and to modify it. Tip: Use
-   ``git rebase -i origin/develop`` to modify chains of commits.
+10. Be prepared to get some comments about your code and to modify it. Tip: Use
+    ``git rebase -i origin/develop`` to modify chains of commits.
--- a/Makefile
+++ b/Makefile
@@ -26,14 +26,7 @@
 
 VERSION_STRING	:= `git describe --tags --dirty --always 2>/dev/null`
 
-WARNFLAGS	:= -Werror -Wall -Wextra -Wpedantic -Wno-sign-compare -Wchkp \
-		   -Wformat=2 -Wformat-overflow=2 -Wformat-truncation=1 \
-		   -Wformat-y2k -Wswitch-enum -Wunused -Wuninitialized \
-		   -Wunknown-pragmas -Wstrict-overflow=5 -Wstringop-overflow=4 \
-		   -Walloc-zero -Wduplicated-cond -Wfloat-equal -Wshadow \
-		   -Wcast-qual -Wcast-align -Wlogical-op -Wnested-externs \
-		   -Wno-aggressive-loop-optimizations -Winline -Wundef \
-		   -Wstrict-prototypes -Wold-style-definition
+WARNFLAGS	:= -Wall
 
 # Overridable CFLAGS
 CFLAGS		:= -g
@@ -167,6 +160,7 @@
 
 # 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' | grep -v '\.html'`; do	\
 		${CHECKPATCH} -f "$$file";					\
@@ -176,6 +170,7 @@
 # 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		\
@@ -200,6 +195,20 @@
 	$Qmandoc ${MANDOC} src/link/rgblink.5 > docs/rgblink.5.html
 	$Qmandoc ${MANDOC} src/gfx/rgbgfx.1 > docs/rgbgfx.1.html
 
+# This target is used during development in order to prevent adding new issues
+# to the source code. All warnings are treated as errors in order to block the
+# compilation and make the continous integration infrastructure return failure.
+
+develop:
+	$Qenv make -j WARNFLAGS="-Werror -Wall -Wextra -Wpedantic \
+		-Wno-sign-compare -Wchkp -Wformat=2 -Wformat-overflow=2 \
+		-Wformat-truncation=1 -Wformat-y2k -Wswitch-enum -Wunused \
+		-Wuninitialized -Wunknown-pragmas -Wstrict-overflow=5 \
+		-Wstringop-overflow=4 -Walloc-zero -Wduplicated-cond \
+		-Wfloat-equal -Wshadow -Wcast-qual -Wcast-align -Wlogical-op \
+		-Wnested-externs -Wno-aggressive-loop-optimizations -Winline \
+		-Wundef -Wstrict-prototypes -Wold-style-definition"
+
 # Targets for the project maintainer to easily create Windows exes.
 # This is not for Windows users!
 # If you're building on Windows with Cygwin or Mingw, just follow the Unix
@@ -207,7 +216,7 @@
 
 mingw32:
 	$Qenv PKG_CONFIG_PATH=/usr/i686-w64-mingw32/sys-root/mingw/lib/pkgconfig/ \
-		make CC=i686-w64-mingw32-gcc YACC=bison WARNFLAGS= -j
+		make CC=i686-w64-mingw32-gcc YACC=bison -j
 	$Qmv rgbasm rgbasm.exe
 	$Qmv rgblink rgblink.exe
 	$Qmv rgbfix rgbfix.exe
@@ -215,7 +224,7 @@
 
 mingw64:
 	$Qenv PKG_CONFIG_PATH=/usr/x86_64-w64-mingw32/sys-root/mingw/lib/pkgconfig/ \
-		make CC=x86_64-w64-mingw32-gcc YACC=bison WARNFLAGS= -j
+		make CC=x86_64-w64-mingw32-gcc YACC=bison -j
 	$Qmv rgbasm rgbasm.exe
 	$Qmv rgblink rgblink.exe
 	$Qmv rgbfix rgbfix.exe