[Common] Import gst-indent script from Gstreamer mainline.
authorMyungJoo Ham <myungjoo.ham@samsung.com>
Tue, 12 Jun 2018 06:29:27 +0000 (15:29 +0900)
committer문지중/동작제어Lab(SR)/Principal Engineer/삼성전자 <jijoong.moon@samsung.com>
Thu, 14 Jun 2018 06:27:30 +0000 (15:27 +0900)
Use the script to do coding style check.

Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
common/gst-indent [new file with mode: 0755]

diff --git a/common/gst-indent b/common/gst-indent
new file mode 100755 (executable)
index 0000000..fdfec72
--- /dev/null
@@ -0,0 +1,55 @@
+#!/bin/sh
+#
+# Check that the code follows a consistant code style
+#
+
+# Check for existence of indent, and error out if not present.
+# On some *bsd systems the binary seems to be called gnunindent,
+# so check for that first.
+
+version=`gnuindent --version 2>/dev/null`
+if test "x$version" = "x"; then
+  version=`gindent --version 2>/dev/null`
+  if test "x$version" = "x"; then
+    version=`indent --version 2>/dev/null`
+    if test "x$version" = "x"; then
+      echo "GStreamer git pre-commit hook:"
+      echo "Did not find GNU indent, please install it before continuing."
+      exit 1
+    else
+      INDENT=indent
+    fi
+  else
+    INDENT=gindent
+  fi
+else
+  INDENT=gnuindent
+fi
+
+case `$INDENT --version` in
+  GNU*)
+      ;;
+  default)
+      echo "GStreamer git pre-commit hook:"
+      echo "Did not find GNU indent, please install it before continuing."
+      echo "(Found $INDENT, but it doesn't seem to be GNU indent)"
+      exit 1
+      ;;
+esac
+
+# These parameters are from: https://gstreamer.freedesktop.org/documentation/frequently-asked-questions/developing.html#what-is-the-coding-style-for-gstreamer-code
+INDENT_PARAMETERS="--braces-on-if-line \
+       --case-brace-indentation0 \
+       --case-indentation2 \
+       --braces-after-struct-decl-line \
+       --line-length80 \
+       --no-tabs \
+       --cuddle-else \
+       --dont-line-up-parentheses \
+       --continuation-indentation4 \
+       --honour-newlines \
+       --tab-size8 \
+       --indent-level2 \
+       --leave-preprocessor-space"
+
+$INDENT ${INDENT_PARAMETERS} $@