Navigation Menu

Skip to content

Commit

Permalink
Add auto-formatter script
Browse files Browse the repository at this point in the history
  • Loading branch information
sipa committed Nov 27, 2014
1 parent 2adce1f commit a126129
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions contrib/devtools/auto-format.sh
@@ -0,0 +1,13 @@
#!/bin/bash

if [ ! -f src/main.cpp ]; then
echo "This tool must be run from the project root directory." >&2
exit 1
fi

cd src

find . \( -name bip32_tests.cpp -o -name utilstrencodings.cpp -o -name chainparams.cpp -o -name chainparamsseed.h -o -name tinyformat.h -o -name qt -o -name leveldb -o -name univalue -o -name secp256k1 -o -name json \) -prune -o -name '*.h' -o -name '*.cpp' -print | while read FILE; do
clang-format-3.5 -style=file -i "$FILE"

This comment has been minimized.

Copy link
@jonasschnelli

jonasschnelli Nov 27, 2014

Could we not use clang-format as command?

This comment has been minimized.

Copy link
@sipa

sipa Nov 28, 2014

Author Owner

I'd rather keep things consistent for now. For example, using 3.4 will cause weird errors (before the .clang-format file contains options that it doesn't know) and result in completely wrong formatting. For 3.6 we don't know how the behaviour may change.

This comment has been minimized.

Copy link
@laanwj

laanwj Nov 28, 2014

Please do add an option (either a command line argument or optional environment variable) to override this. E.g. I compile clang from source, and it would never guess by itself to look for it in /opt/clang/bin/clang-format.

This comment has been minimized.

Copy link
@laanwj

laanwj Nov 28, 2014

Well on the other hand fixing the version makes sense. When running this with clang version 3.6.0 (http://llvm.org/git/clang.git 5acd9709d79e3c80e92a0d43884c671a034e2a01) (http://llvm.org/git/llvm.git 1e165a0d5ec41e8847b59c9f67d0e471b7a3b58b) I get the following diff compared to 2037211: http://paste.ubuntu.com/9279808/
(mainly the { after struct on the next line instead of the same one, and some spaces difference before *)

This comment has been minimized.

Copy link
@jonasschnelli

jonasschnelli Nov 28, 2014

Why not use clang-format command and check the -version string if it's an acceptable version?

done

0 comments on commit a126129

Please sign in to comment.