[glibmm] tools: Add the testheaders.sh script.



commit 8cb94c761cfed43204d814d9494ed9ad98694193
Author: Kjell Ahlstedt <kjell ahlstedt bredband net>
Date:   Sat May 18 11:58:59 2013 +0200

    tools: Add the testheaders.sh script.
    
    * tools/test_scripts/testheaders.sh: New file. Compiles each specified header
    file, one at a time. Bug #697835.

 ChangeLog                         |    7 +++
 tools/test_scripts/testheaders.sh |   80 +++++++++++++++++++++++++++++++++++++
 2 files changed, 87 insertions(+), 0 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 52c4dc9..a586cf3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2013-05-18  Kjell Ahlstedt  <kjell ahlstedt bredband net>
 
+       tools: Add the testheaders.sh script.
+
+       * tools/test_scripts/testheaders.sh: New file. Compiles each specified header
+       file, one at a time. Bug #697835.
+
+2013-05-18  Kjell Ahlstedt  <kjell ahlstedt bredband net>
+
        tools: Add the testmmh.sh script.
 
        * tools/test_scripts/testmmh.sh: New file. Checks if all header files are
diff --git a/tools/test_scripts/testheaders.sh b/tools/test_scripts/testheaders.sh
new file mode 100755
index 0000000..f91a9f5
--- /dev/null
+++ b/tools/test_scripts/testheaders.sh
@@ -0,0 +1,80 @@
+#!/bin/bash
+
+# Compile each header file, one at a time.
+# The compiler will notice if a header file does not include all other header
+# files that it depends on.
+
+# Example: In glibmm, go to directory glibmm, and run
+#   tools/test_scripts/testheaders.sh -I glib glibmm-2.4 gio # compile glibmm/gio/giomm/*.h
+#   tools/test_scripts/testheaders.sh glibmm-2.4 glib gio    # compile glibmm/glib/glibmm/*.h and 
glibmm/gio/giomm/*.h
+#   tools/test_scripts/testheaders.sh -I glib -I gio glibmm-2.4 glib/glibmm/ustring.h # compile 
glibmm/glib/glibmm/ustring.h
+
+# Usage: testheaders.sh [-I<dir>]... <pkg> [<dir> | <file>]...
+# -I<dir> is added to the g++ command.
+# <pkg> is the name of the package, given to pkg-config.
+
+function usage() {
+  echo "Usage: $0 [-I<dir>]... <pkg> [<dir> | <file>]..."
+  exit 1
+}
+
+# Search for directories to include in CFLAGS.
+idirs=""
+while [ $# -gt 0 ]
+do
+  case "$1" in
+    -I) if [ $# -lt 2 ]
+        then
+          usage
+        fi
+        idirs+=" -I$2"
+        shift; shift
+        ;;
+    -I*) idirs+=" $1"
+         shift
+         ;;
+    -*) echo "Illegal option: $1"
+        usage
+        ;;
+    *) break
+       ;;
+  esac
+done
+
+# Package name
+if [ $# -lt 1 ]
+then
+  echo "No package name"
+  usage
+fi
+pkg="$1"
+shift
+
+# Search for more directories to include in CFLAGS.
+for i in "$@"
+do
+  if [ -d "$1" ]
+  then
+    idirs+=" -I$i"
+  fi
+done
+
+CFLAGS="$idirs `pkg-config --cflags $pkg`"
+echo CFLAGS=$CFLAGS
+
+# Compile the specified files
+for i in "$@"
+do
+  if [ -d "$i" ]
+  then
+    for headerfile in $i/${i}mm/*.h
+    do
+      echo "=== $headerfile"
+      g++ -c -x c++ -o /dev/null $headerfile $CFLAGS
+    done
+  else
+    echo "=== $i"
+    g++ -c -x c++ -o /dev/null $i $CFLAGS
+  fi
+done
+


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]