diff options
Diffstat (limited to 'src/corefx/format-code.sh')
-rwxr-xr-x | src/corefx/format-code.sh | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/corefx/format-code.sh b/src/corefx/format-code.sh new file mode 100755 index 0000000000..3d0cfcc93c --- /dev/null +++ b/src/corefx/format-code.sh @@ -0,0 +1,40 @@ +#!/usr/bin/env bash + +# OS X names clang-format as clang-format; Ubuntu uses +# clang-format-version so check for the right one +if which "clang-format-3.6" > /dev/null 2>&1 ; then + export CF="$(which clang-format-3.6)" +elif which "clang-format" > /dev/null 2>&1 ; then + export CF="$(which clang-format)" +else + echo "Unable to find clang-format" + exit 1 +fi + +cd $(dirname "$0") + +for D in */; do + for file in "${D}"*.cpp; do + if [ -e $file ] ; then + $CF -style=file -i "$file" + fi + done + + for file in "${D}"*.h ; do + if [ -e $file ] ; then + $CF -style=file -i "$file" + fi + done + + for file in "${D}"*.hpp ; do + if [ -e $file ] ; then + $CF -style=file -i "$file" + fi + done + + for file in "${D}"*.in ; do + if [ -e $file ] ; then + $CF -style=file -i "$file" + fi + done +done |