]> rtime.felk.cvut.cz Git - jailhouse.git/commitdiff
tooling: Add include dependency checker for header files
authorJan Kiszka <jan.kiszka@siemens.com>
Thu, 9 Oct 2014 06:05:04 +0000 (08:05 +0200)
committerJan Kiszka <jan.kiszka@siemens.com>
Fri, 10 Oct 2014 11:45:05 +0000 (13:45 +0200)
This script checks is all dependencies of a header file are fulfilled so
that the header can be included stand-alone.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
scripts/header_check [new file with mode: 0755]

diff --git a/scripts/header_check b/scripts/header_check
new file mode 100755 (executable)
index 0000000..ca02f17
--- /dev/null
@@ -0,0 +1,55 @@
+#!/bin/bash
+#
+# Jailhouse, a Linux-based partitioning hypervisor
+#
+# Copyright (c) Siemens AG, 2014
+#
+# Authors:
+#  Jan Kiszka <jan.kiszka@siemens.com>
+#
+# This work is licensed under the terms of the GNU GPL, version 2.  See
+# the COPYING file in the top-level directory.
+#
+
+if [ "$ARCH" == "" ]; then
+       ARCH=x86
+fi
+
+CFLAGS="-fno-builtin-ffsl -Wall -Wstrict-prototypes -Wtype-limits \
+       -Wmissing-declarations -Wmissing-prototypes \
+       -Ihypervisor/arch/$ARCH/include -Ihypervisor/include \
+       $EXTRA_CFLAGS"
+
+test_compile()
+{
+       header=`basename $2`
+       prepend=
+       case $header in
+       cell-config.h|header.h|hypercall.h)
+               prepend="#include <asm/types.h>"
+               ;;
+       jailhouse_hypercall.h)
+               # only included directly for linker script
+               prepend="#define __ASSEMBLY__
+                        #include <asm/types.h>"
+               ;;
+       esac
+
+       echo "$prepend" > .header_check.tmp.c
+       echo "#include <$1/$header>" >> .header_check.tmp.c
+
+       if ! ${CROSS_COMPILE}gcc -c -o .header_check.tmp.o .header_check.tmp.c $CFLAGS; then
+               exit 1;
+       fi
+       echo $1/$header - OK
+}
+
+for header in hypervisor/include/jailhouse/*.h; do
+       test_compile jailhouse $header
+done
+
+for header in hypervisor/arch/$ARCH/include/asm/*.h; do
+       test_compile asm $header
+done
+
+rm -f .header_check.tmp.[oc]