From 5bc18195d55570ef01e4b24dd248f222f081b0a2 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 27 May 2011 15:58:54 -0400 Subject: [PATCH] Add check-includes.sh --- src/Makefile.am | 7 ++++++ src/check-c-linkage-decls.sh | 6 ++++- src/check-header-guards.sh | 8 ++++++- src/check-includes.sh | 42 +++++++++++++++++++++++++++++++++++ src/check-internal-symbols.sh | 8 +++---- src/check-libstdc++.sh | 7 +++--- src/hb-ot-shape.h | 1 + 7 files changed, 70 insertions(+), 9 deletions(-) create mode 100755 src/check-includes.sh diff --git a/src/Makefile.am b/src/Makefile.am index df5c52f00..93a51381b 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -146,6 +146,7 @@ dist_check_SCRIPTS = \ check-c-linkage-decls.sh \ check-header-guards.sh \ check-internal-symbols.sh \ + check-includes.sh \ $(NULL) if HAVE_ICU @@ -154,5 +155,11 @@ dist_check_SCRIPTS += check-libstdc++.sh endif TESTS = $(dist_check_SCRIPTS) +TESTS_ENVIRONMENT = \ + srcdir="$(srcdir)" \ + MAKE="$(MAKE) $(AM_MAKEFLAGS)" \ + HBSOURCES="$(HBSOURCES)" \ + HBHEADERS="$(HBHEADERS)" \ + $(NULL) -include $(top_srcdir)/git.mk diff --git a/src/check-c-linkage-decls.sh b/src/check-c-linkage-decls.sh index ffdb9e35f..84e77cfb2 100755 --- a/src/check-c-linkage-decls.sh +++ b/src/check-c-linkage-decls.sh @@ -6,9 +6,13 @@ export LC_ALL test -z "$srcdir" && srcdir=. stat=0 +test "x$HBHEADERS" = x && HBHEADERS=`find . -maxdepth 1 -name 'hb*.h'` +test "x$HBSOURCES" = x && HBSOURCES=`find . -maxdepth 1 -name 'hb-*.cc' -or -name 'hb-*.hh'` + + cd "$srcdir" -for x in hb-*.cc hb-*.h hb-*.hh ; do +for x in $HBHEADERS $HBSOURCES; do if ! grep -q HB_BEGIN_DECLS "$x" || ! grep -q HB_END_DECLS "$x"; then echo "Ouch, file $x does not HB_BEGIN_DECLS / HB_END_DECLS" stat=1 diff --git a/src/check-header-guards.sh b/src/check-header-guards.sh index c966cd2f1..ddbcd8337 100755 --- a/src/check-header-guards.sh +++ b/src/check-header-guards.sh @@ -6,9 +6,15 @@ export LC_ALL test -z "$srcdir" && srcdir=. stat=0 +test "x$HBHEADERS" = x && HBHEADERS=`find . -maxdepth 1 -name 'hb*.h'` +test "x$HBSOURCES" = x && HBSOURCES=`find . -maxdepth 1 -name 'hb-*.cc' -or -name 'hb-*.hh'` + + cd "$srcdir" -for x in hb-*.h hb-*.hh ; do +for x in $HBHEADERS $HBSOURCES; do + echo "$x" | grep '[^h]$' -q && continue; + x=`echo "$x" | sed 's@.*/@@'` tag=`echo "$x" | tr 'a-z.-' 'A-Z_'` lines=`grep "\<$tag\>" "$x" | wc -l` if test "x$lines" != x3; then diff --git a/src/check-includes.sh b/src/check-includes.sh new file mode 100755 index 000000000..79323a74f --- /dev/null +++ b/src/check-includes.sh @@ -0,0 +1,42 @@ +#!/bin/sh + +LC_ALL=C +export LC_ALL + +test -z "$srcdir" && srcdir=. +stat=0 + +test "x$HBHEADERS" = x && HBHEADERS=`find . -maxdepth 1 -name 'hb*.h'` +test "x$HBSOURCES" = x && HBSOURCES=`find . -maxdepth 1 -name 'hb-*.cc' -or -name 'hb-*.hh'` + + +cd "$srcdir" + + +echo 'Checking that public header files #include "hb-common.h" or "hb.h" first (or none)' + +for x in $HBHEADERS; do + grep '#.*\' "$x" /dev/null | head -n 1 +done | +grep -v '"hb-common[.]h"' | +grep -v '"hb[.]h"' | +grep -v 'hb-common[.]h:' | +grep -v 'hb[.]h:' | +grep . >&2 && stat=1 + + +echo 'Checking that source files #include "hb-*private.hh" first (or none)' + +for x in $HBSOURCES; do + grep '#.*\' "$x" /dev/null | head -n 1 +done | +grep -v '"hb-.*private[.]hh"' | +grep -v 'hb-private[.]hh:' | +grep . >&2 && stat=1 + + +echo 'Checking that there is no #include ' +grep '#.*\.*<.*hb' $HBHEADERS $HBSOURCES >&2 && stat=1 + + +exit $stat diff --git a/src/check-internal-symbols.sh b/src/check-internal-symbols.sh index 124a7b04d..2885fa4de 100755 --- a/src/check-internal-symbols.sh +++ b/src/check-internal-symbols.sh @@ -3,6 +3,10 @@ LC_ALL=C export LC_ALL +test -z "$srcdir" && srcdir=. +stat=0 + + if which nm 2>/dev/null >/dev/null; then : else @@ -10,10 +14,6 @@ else exit 0 fi -test -z "$srcdir" && srcdir=. -test -z "$MAKE" && MAKE=make -stat=0 - so=.libs/libharfbuzz.so if test -f "$so"; then echo "Checking that we are exposing internal symbols" diff --git a/src/check-libstdc++.sh b/src/check-libstdc++.sh index c0abcbe41..40e73b04e 100755 --- a/src/check-libstdc++.sh +++ b/src/check-libstdc++.sh @@ -3,6 +3,10 @@ LC_ALL=C export LC_ALL +test -z "$srcdir" && srcdir=. +stat=0 + + if which ldd 2>/dev/null >/dev/null; then : else @@ -10,9 +14,6 @@ else exit 0 fi -test -z "$srcdir" && srcdir=. -stat=0 - so=.libs/libharfbuzz.so if test -f "$so"; then echo "Checking that we are not linking to libstdc++" diff --git a/src/hb-ot-shape.h b/src/hb-ot-shape.h index 70a81721d..f9560e57e 100644 --- a/src/hb-ot-shape.h +++ b/src/hb-ot-shape.h @@ -27,6 +27,7 @@ #ifndef HB_OT_SHAPE_H #define HB_OT_SHAPE_H +#include "hb-common.h" #include "hb-shape.h"