From 86be4c9d5931cd69678c6174102450d5c72cec99 Mon Sep 17 00:00:00 2001 From: Sergey Yagovtsev Date: Tue, 7 Nov 2017 21:45:13 +0300 Subject: [PATCH] Add .clang-format file and script for styling --- .clang-format | 9 +++++++++ scripts/make_style.sh | 19 +++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 .clang-format create mode 100755 scripts/make_style.sh diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..0bc782a --- /dev/null +++ b/.clang-format @@ -0,0 +1,9 @@ +--- +Language: Cpp +BasedOnStyle: Google +ColumnLimit: 100 +IndentWidth: 4 +ReflowComments: false +#IndentPPDirectives: PPDIS_AfterHash #since clang 6.0 +... + diff --git a/scripts/make_style.sh b/scripts/make_style.sh new file mode 100755 index 0000000..6646ccd --- /dev/null +++ b/scripts/make_style.sh @@ -0,0 +1,19 @@ +if [ "$#" -ne 1 ]; then + echo -e "Usage: \n$0 DIRECTORY\n\twhere DIRECTORY is a derectory with sources for styling" + exit 1 +fi + +if ! [ -x "$(command -v clang-format)" ]; then + echo 'Error: clang-format is not installed. Please install clang-format with minimal version 3.8' >&2 + exit 1 +fi + +DIR=$1 + +FILES=`find $DIR -name "*.h" -or -name "*.cpp"` + +for FILE in $FILES +do + echo "Set style for $FILE" + clang-format -i $FILE +done