[Parted-edge] [PATCH] Create the needed infra-structure to enforce
the coding style
Otavio Salvador
otavio at debian.org
Wed Apr 18 01:59:05 UTC 2007
From: Otavio Salvador <otavio at ossystems.com.br>
To enforce the coding style we'll use this infra-structure. It
currently uses astyle for code formating and provides a 'format-code'
Makefile target that does the indentation.
This new infra-structure has:
o scripts/enforce-coding-style: script that runs astyle;
o Makefile.am: provides the 'format-code' target;
Signed-off-by: Otavio Salvador <otavio at ossystems.com.br>
---
Makefile.am | 3 +++
scripts/enforce-coding-style | 37 +++++++++++++++++++++++++++++++++++++
2 files changed, 40 insertions(+), 0 deletions(-)
diff --git a/Makefile.am b/Makefile.am
index 0f6318c..5f7cace 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,3 +1,6 @@
SUBDIRS = src test
EXTRA_DIST = AUTHORS TODO README configure
+
+format-code:
+ scripts/enforce-coding-style
\ No newline at end of file
diff --git a/scripts/enforce-coding-style b/scripts/enforce-coding-style
new file mode 100755
index 0000000..7715cd3
--- /dev/null
+++ b/scripts/enforce-coding-style
@@ -0,0 +1,37 @@
+#!/bin/sh
+
+############################################################################
+# Copyright (c) 2006, 2007 O.S. Systems
+# Copyright (c) 2007 Free Software Foundation, Inc.
+#
+# Author: Otavio Salvador <otavio at ossystems.com.br>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+############################################################################
+
+if [ ! -x /usr/bin/astyle ]; then
+ echo "ERROR: You need to have astyle installed."
+ exit 1
+fi
+
+astyle --mode=c \
+ --indent=spaces=4 \
+ --indent-classes \
+ --indent-switches \
+ --indent-cases \
+ --indent-namespaces \
+ --brackets=linux \
+ -p \
+ --convert-tabs \
+ --break-blocks \
+ --break-blocks=all \
+ $(find . -iname '*.h' -o -iname '*.c' -o -iname '*.hpp' -o \
+ -iname '*.cpp' -o -iname '*.cc')
--
1.5.1
More information about the Parted-edge
mailing list