summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2007-04-24 13:47:09 +0100
committerSimon McVittie <smcv@carbon.pseudorandom.co.uk>2007-04-24 18:02:25 +0100
commitcdf20eebae59e0ceb2cf8fc2660609e6c38ccebf (patch)
treee7bebef73fd9965c774823a927974364d2903e84 /tools
parentb5552a3ea76b3e229f40a06d32a5860b0e9e2217 (diff)
downloaddbus-python-cdf20eebae59e0ceb2cf8fc2660609e6c38ccebf.tar.gz
Add optional checks for coding style (mainly whitespace at the moment).
These are on by default for git builds, off by default for releases.
Diffstat (limited to 'tools')
-rw-r--r--tools/Makefile.am5
-rw-r--r--tools/check-c-style.sh17
-rw-r--r--tools/check-coding-style.mk25
-rw-r--r--tools/check-py-style.sh18
-rw-r--r--tools/check-whitespace.sh17
5 files changed, 82 insertions, 0 deletions
diff --git a/tools/Makefile.am b/tools/Makefile.am
new file mode 100644
index 0000000..122fa82
--- /dev/null
+++ b/tools/Makefile.am
@@ -0,0 +1,5 @@
+EXTRA_DIST = \
+ check-coding-style.mk \
+ check-c-style.sh \
+ check-py-style.sh \
+ check-whitespace.sh
diff --git a/tools/check-c-style.sh b/tools/check-c-style.sh
new file mode 100644
index 0000000..177355e
--- /dev/null
+++ b/tools/check-c-style.sh
@@ -0,0 +1,17 @@
+#!/bin/sh
+fail=0
+
+/bin/sh "${top_srcdir}"/tools/check-whitespace.sh "$@" || fail=$?
+
+# at the moment we're not actually checking much C style here... to be added
+
+if test -n "$CHECK_FOR_LONG_LINES"
+then
+ if egrep -n '.{80,}' "$@"
+ then
+ echo "^^^ The above files contain long lines"
+ fail=1
+ fi
+fi
+
+exit $fail
diff --git a/tools/check-coding-style.mk b/tools/check-coding-style.mk
new file mode 100644
index 0000000..5209223
--- /dev/null
+++ b/tools/check-coding-style.mk
@@ -0,0 +1,25 @@
+check-local::
+ @fail=0; \
+ if test -n "$(check_misc_sources)"; then \
+ echo check-coding-style.mk: checking misc sources...; \
+ top_srcdir=$(top_srcdir) \
+ sh $(top_srcdir)/tools/check-whitespace.sh \
+ $(check_misc_sources) || fail=1; \
+ fi; \
+ if test -n "$(check_py_sources)"; then \
+ echo check-coding-style.mk: checking Python sources...; \
+ top_srcdir=$(top_srcdir) \
+ sh $(top_srcdir)/tools/check-py-style.sh \
+ $(check_py_sources) || fail=1; \
+ fi;\
+ if test -n "$(check_c_sources)"; then \
+ echo check-coding-style.mk: checking C sources...; \
+ top_srcdir=$(top_srcdir) \
+ sh $(top_srcdir)/tools/check-c-style.sh \
+ $(check_c_sources) || fail=1; \
+ fi;\
+ if test yes = "@ENABLE_CODING_STYLE_CHECKS@"; then \
+ exit "$$fail";\
+ else \
+ exit 0;\
+ fi
diff --git a/tools/check-py-style.sh b/tools/check-py-style.sh
new file mode 100644
index 0000000..16a2c3a
--- /dev/null
+++ b/tools/check-py-style.sh
@@ -0,0 +1,18 @@
+#!/bin/sh
+fail=0
+
+/bin/sh "${top_srcdir}"/tools/check-whitespace.sh "$@" || fail=$?
+
+# at the moment we're not actually checking much Python style here...
+# to be added
+
+if test -n "$CHECK_FOR_LONG_LINES"
+then
+ if egrep -n '.{80,}' "$@"
+ then
+ echo "^^^ The above files contain long lines"
+ fail=1
+ fi
+fi
+
+exit $fail
diff --git a/tools/check-whitespace.sh b/tools/check-whitespace.sh
new file mode 100644
index 0000000..5348331
--- /dev/null
+++ b/tools/check-whitespace.sh
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+fail=0
+
+if grep -n ' $' "$@"
+then
+ echo "^^^ The above files contain unwanted trailing spaces"
+ fail=1
+fi
+
+if grep -n ' ' "$@"
+then
+ echo "^^^ The above files contain tabs"
+ fail=1
+fi
+
+exit $fail