3 Wrapper script for clang-format 5 Copyright (c) 2015 MarcoFalke 6 Copyright (c) 2015 The Bitcoin Core developers 7 Distributed under the MIT software license, see the accompanying 8 file COPYING or http://www.opensource.org/licenses/mit-license.php. 15 tested_versions = [
'3.6.0',
'3.6.1',
'3.6.2']
16 accepted_file_extensions = (
'.h',
'.cpp')
20 output = subprocess.check_output([clang_format_exe,
'-version'])
21 for ver
in tested_versions:
23 print "Detected clang-format version " + ver
25 raise RuntimeError(
"Untested version: " + output)
26 except Exception
as e:
27 print 'Could not verify version of ' + clang_format_exe +
'.' 31 required_args = [
'{clang-format-exe}',
'{files}']
32 example_args = [
'clang-format-3.x',
'src/main.cpp',
'src/wallet/*']
34 if(len(argv) < len(required_args) + 1):
35 for word
in ([
'Usage:', argv[0]] + required_args):
38 for word
in ([
'E.g:', argv[0]] + example_args):
45 if os.path.isdir(target):
46 for path, dirs, files
in os.walk(target):
48 elif target.endswith(accepted_file_extensions):
49 print "Format " + target
50 subprocess.check_call([clang_format_exe,
'-i',
'-style=file', target], stdout=open(os.devnull,
'wb'), stderr=subprocess.STDOUT)
52 print "Skip " + target
56 clang_format_exe = argv[1]
61 if __name__ ==
"__main__":