git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH v2 1/2] Makefile: add check-headers target
@ 2014-09-07  0:30 David Aguilar
  2014-09-07  0:30 ` [RFC PATCH v2 2/2] headers: include dependent headers David Aguilar
                   ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: David Aguilar @ 2014-09-07  0:30 UTC (permalink / raw)
  To: git; +Cc: Jeff King, René Scharfe

This allows us to ensure that each header can be included
individually without needing to include other headers first.

Signed-off-by: David Aguilar <davvid@gmail.com>
---
Changes since v1:
We now include xdiff, ewah, and vcs-svn headers.

 Makefile         |  6 ++++++
 check-headers.sh | 29 +++++++++++++++++++++++++++++
 2 files changed, 35 insertions(+)
 create mode 100755 check-headers.sh

diff --git a/Makefile b/Makefile
index 30cc622..39ecc70 100644
--- a/Makefile
+++ b/Makefile
@@ -2591,6 +2591,12 @@ check-docs::
 check-builtins::
 	./check-builtins.sh
 
+### Make sure headers include their dependencies
+#
+check-headers::
+	./check-headers.sh $(CC) $(ALL_CFLAGS) $(EXTRA_CPPFLAGS)
+
+
 ### Test suite coverage testing
 #
 .PHONY: coverage coverage-clean coverage-compile coverage-test coverage-report
diff --git a/check-headers.sh b/check-headers.sh
new file mode 100755
index 0000000..2722dd2
--- /dev/null
+++ b/check-headers.sh
@@ -0,0 +1,29 @@
+#!/bin/sh
+
+exit_code=0
+
+maybe_exit () {
+	status="$1"
+	if test "$status" != 0
+	then
+		exit_code="$status"
+		if test -n "$CHECK_HEADERS_STOP"
+		then
+			exit "$status"
+		fi
+	fi
+}
+
+IFS='
+'
+git ls-files *.h ewah/*.h vcs-svn/*.h xdiff/*.h |
+while read header
+do
+	subdir=$(dirname "$header") &&
+	echo "HEADER $header" &&
+	"$@" -Wno-unused -I"$subdir" -c -o "$header".check -x c - <"$header" &&
+	rm "$header".check ||
+	maybe_exit $?
+done
+
+exit $exit_code
-- 
2.1.0.62.g3e88d26

^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2014-09-10 17:25 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-07  0:30 [RFC PATCH v2 1/2] Makefile: add check-headers target David Aguilar
2014-09-07  0:30 ` [RFC PATCH v2 2/2] headers: include dependent headers David Aguilar
2014-09-07  6:41   ` René Scharfe
2014-09-07 19:49   ` Jonathan Nieder
2014-09-07 19:54     ` Johannes Sixt
2014-09-07 20:01       ` Jonathan Nieder
2014-09-07 20:30     ` David Aguilar
2014-09-07 19:42 ` [RFC PATCH v2 1/2] Makefile: add check-headers target Jonathan Nieder
2014-09-08 18:56 ` Junio C Hamano
2014-09-08 19:29   ` Matthieu Moy
2014-09-08 19:57     ` Junio C Hamano
2014-09-10  0:03       ` David Aguilar
2014-09-10 17:09         ` Junio C Hamano
2014-09-10 17:24           ` Matthieu Moy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).