Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Commit

Permalink
Add format-code.sh from CoreFX
Browse files Browse the repository at this point in the history
  • Loading branch information
ellismg committed Oct 13, 2015
1 parent fec8f02 commit eb13823
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/corefx/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
Language: Cpp
# BasedOnStyle: LLVM
AlignEscapedNewlinesLeft: false
AlignAfterOpenBracket: true
AllowShortFunctionsOnASingleLine: false
AlwaysBreakTemplateDeclarations: true
BinPackArguments: false
BinPackParameters: false
BreakBeforeBraces: Allman
ColumnLimit: 120
ConstructorInitializerAllOnOneLineOrOnePerLine: true
IndentCaseLabels: true
IndentWidth: 4
PointerAlignment: Left
TabWidth: 4
...

40 changes: 40 additions & 0 deletions src/corefx/format-code.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit eb13823

Please sign in to comment.