]> rtime.felk.cvut.cz Git - ulut.git/commitdiff
Added script to generate log domains arrays for static registration.
authorppisa <ppisa>
Mon, 25 May 2009 15:34:28 +0000 (15:34 +0000)
committerppisa <ppisa>
Mon, 25 May 2009 15:34:28 +0000 (15:34 +0000)
ulut/ul_log_domains [new file with mode: 0755]

diff --git a/ulut/ul_log_domains b/ulut/ul_log_domains
new file mode 100755 (executable)
index 0000000..3723907
--- /dev/null
@@ -0,0 +1,54 @@
+#!/bin/sh
+
+ARRAY_NAME=ul_log_domains_array
+
+DIRS=""
+
+while [ $# -gt 0 ] ; do
+  case "x${1}x" in
+    "x--helpx" | "x-hx" )
+      echo -e Usage: `basename ${0}`" [options] <srcdir> .."
+      echo -e "      -h --help       help"
+      echo -e "      -a --array      identifier of log domain array variable"
+      exit 0
+      ;;
+    "x--arrayx" | "x-ax" )
+      shift 1
+      ARRAY_NAME="${1}"
+      ;;
+    "x--"* )
+      echo "Unknown option"
+      exit 2
+      ;;
+    * )
+      DIRS="$DIRS ${1}"
+      ;;
+  esac
+  shift 1
+done
+
+DOMAINS=$( for d in $DIRS ; do find -L $d '(' -name '*.c' -o -name '*.cc' ')' -exec grep UL_LOG_CUST '{}' ';' | \
+  sed -n -e 's/^.*UL_LOG_CUST(\([^)]*\)).*$/\1/p' ; done | sort -u )
+
+#echo $DOMAINS
+
+#echo -e "#define UL_LOGL_DEF UL_LOGL_DEB\n"
+
+echo "/*"
+echo " * This is generated file, do not edit it directly."
+echo " * Take it from standard output of \"ul_log_domains\""
+echo " * script called in the top level project directory"
+echo " */"
+
+for i in $DOMAINS ; do
+  echo "ul_log_domain_t $i     = {UL_LOGL_DEF, \"$(echo -n $i | sed -n -e 's/ulogd_\(.*\)/\1/pg' )\"};"
+done
+
+echo
+echo "ul_log_domain_t *$ARRAY_NAME[] = {"
+
+for i in $DOMAINS ; do
+  echo "  &$i,"
+done
+
+echo "};"