git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[RFC PATCH v2 1/2] Makefile: add check-headers target

From
David Aguilar <davvid@gmail.com>
Date
Sep 7, 2014, 00:30 UTC
Message-ID
<1410049821-49861-1-git-send-email-davvid@gmail.com>

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
Next: David Aguilar
Message 1 of 14 in “Makefile: add check-headers target”
  1. 1/2 Makefile: add check-headers targetDavid Aguilar, Sep 7, 2014
  2. 2/2 headers: include dependent headersDavid Aguilar, Sep 7, 2014
  3. René ScharfeSep 7, 2014
  4. Jonathan NiederSep 7, 2014
  5. Johannes SixtSep 7, 2014
  6. Jonathan NiederSep 7, 2014
  7. David AguilarSep 7, 2014
  8. Jonathan NiederSep 7, 2014
  9. Junio C HamanoSep 8, 2014
  10. Matthieu MoySep 8, 2014
  11. Junio C HamanoSep 8, 2014
  12. David AguilarSep 10, 2014
  13. Junio C HamanoSep 10, 2014
  14. Matthieu MoySep 10, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.