diff mbox

[3/3] scripts: add odp_format to match chekpatch style

Message ID 1440001229-22483-3-git-send-email-mike.holmes@linaro.org
State New
Headers show

Commit Message

Mike Holmes Aug. 19, 2015, 4:20 p.m. UTC
This odp_format script applies source file formatting to match the ODP
checkpatch style

Signed-off-by: Mike Holmes <mike.holmes@linaro.org>
---
 scripts/odp_format | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)
 create mode 100755 scripts/odp_format

Comments

Maxim Uvarov Aug. 24, 2015, 11:16 a.m. UTC | #1
On 08/19/15 19:20, Mike Holmes wrote:
> This odp_format script applies source file formatting to match the ODP
> checkpatch style
>
> Signed-off-by: Mike Holmes <mike.holmes@linaro.org>
> ---
>   scripts/odp_format | 31 +++++++++++++++++++++++++++++++
>   1 file changed, 31 insertions(+)
>   create mode 100755 scripts/odp_format
>
> diff --git a/scripts/odp_format b/scripts/odp_format
> new file mode 100755
> index 0000000..192e63d
> --- /dev/null
> +++ b/scripts/odp_format
> @@ -0,0 +1,31 @@
> +#!/bin/bash
> +# This script is a clean up tool for the ODP project source files.
> +# It will replace the src files with versions that are formatted to match the
> +# checkpatch rules for ODP.
> +
> +set -e
> +
> +CLANG_FORMAT=clang-format-3.6
> +
> +if ! type $CLANG_FORMAT >/dev/null ; then
> +	echo "Require $CLANG_FORMAT"
> +	echo "try apt-get install $CLANG_FORMAT"
> +	exit
> +fi
> +
> +if [[ $# -eq 0 ]]
> +then
> +	echo "No source file paths supplied"
> +	exit
> +fi
> +
> +#work on specified files
> +while (( "$#" )); do
> +	echo $1
> +	clang-format-3.6 -i -style=file $1
You defined CLANG_FORMAT above. It has to be used here, instead of 
clang-format-3.6.
Most likely there should be symlink for clang-format without version.

> +	#as of version 3.6 a few corner cases slip though so use sed
> +	#to fix them bacasue it uses space where checkpatch wants a tab
> +	sed -i 's/^    /\t/' $1
> +	sed -i 's/\\    /\\\t/' $1
> +  shift
> +done
diff mbox

Patch

diff --git a/scripts/odp_format b/scripts/odp_format
new file mode 100755
index 0000000..192e63d
--- /dev/null
+++ b/scripts/odp_format
@@ -0,0 +1,31 @@ 
+#!/bin/bash
+# This script is a clean up tool for the ODP project source files.
+# It will replace the src files with versions that are formatted to match the
+# checkpatch rules for ODP.
+
+set -e
+
+CLANG_FORMAT=clang-format-3.6
+
+if ! type $CLANG_FORMAT >/dev/null ; then
+	echo "Require $CLANG_FORMAT"
+	echo "try apt-get install $CLANG_FORMAT"
+	exit
+fi
+
+if [[ $# -eq 0 ]]
+then
+	echo "No source file paths supplied"
+	exit
+fi
+
+#work on specified files
+while (( "$#" )); do
+	echo $1
+	clang-format-3.6 -i -style=file $1
+	#as of version 3.6 a few corner cases slip though so use sed
+	#to fix them bacasue it uses space where checkpatch wants a tab
+	sed -i 's/^    /\t/' $1
+	sed -i 's/\\    /\\\t/' $1
+  shift
+done