summaryrefslogtreecommitdiff
path: root/src/check-preprocessor-syntax.sh
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@behdad.org>2008-09-20 17:20:36 -0400
committerBehdad Esfahbod <behdad@behdad.org>2008-09-20 17:20:36 -0400
commitfee72c26afff2120315ebbab32708520307e7a5e (patch)
treed9d09053fdaec65c3c54692a875490579460ef6f /src/check-preprocessor-syntax.sh
parente00565fa3c9579566abb31b71af3f13f44c45139 (diff)
downloadcairo-fee72c26afff2120315ebbab32708520307e7a5e.tar.gz
Make sure feature macros are checked using #if, not #ifdef; add a test for it
This is more robust to cases where people want to assign 0 to those variables. (win32/alternate build systems, etc)
Diffstat (limited to 'src/check-preprocessor-syntax.sh')
-rwxr-xr-xsrc/check-preprocessor-syntax.sh57
1 files changed, 57 insertions, 0 deletions
diff --git a/src/check-preprocessor-syntax.sh b/src/check-preprocessor-syntax.sh
new file mode 100755
index 000000000..12577eb5a
--- /dev/null
+++ b/src/check-preprocessor-syntax.sh
@@ -0,0 +1,57 @@
+#!/bin/sh
+
+LANG=C
+
+test -z "$srcdir" && srcdir=.
+cd "$srcdir"
+stat=0
+
+
+HEADERS=$all_cairo_headers
+test "x$HEADERS" = x && HEADERS=`find . -name 'cairo*.h' ! -name 'cairo*-private.h' ! -name 'cairoint.h'`
+
+PRIVATE=$all_cairo_private
+test "x$PRIVATE" = x && PRIVATE=`find . -name 'cairo*-private.h' -or -name 'cairoint.h'`
+
+SOURCES=$all_cairo_sources
+test "x$SOURCES" = x && SOURCES=`find . -name 'cairo*.c' -or -name 'cairo*.cpp'`
+
+ALL="/dev/null $HEADERS $PRIVATE $SOURCES"
+
+echo 'Checking that public header files #include "cairo.h" first (or none)'
+
+for x in $HEADERS; do
+ grep '\<include\>' "$x" /dev/null | head -n 1
+done |
+grep -v '"cairo[.]h"' |
+grep -v 'cairo[.]h:' |
+grep . && stat=1
+
+
+echo 'Checking that private header files #include "some cairo header" first (or none)'
+
+for x in $PRIVATE; do
+ grep '\<include\>' "$x" /dev/null | head -n 1
+done |
+grep -v '"cairo.*[.]h"' |
+grep -v 'cairoint[.]h:' |
+grep . && stat=1
+
+
+echo 'Checking that source files #include "cairoint.h" first (or none)'
+
+for x in $SOURCES; do
+ grep '\<include\>' "$x" /dev/null | head -n 1
+done |
+grep -v '"cairoint[.]h"' |
+grep . && stat=1
+
+
+echo 'Checking that there is no #include <cairo.*.h>'
+grep '\<include\>.*<.*cairo' $ALL && stat=1
+
+
+echo 'Checking that feature conditionals are used with #if only (not #ifdef)'
+grep '#if.*CAIRO_HAS_' $ALL | grep def && stat=1
+
+exit $stat