Browse Source

Merge #9649: [doc] Remove unused clang format dev script

fa5137c [doc] Remove unused clang format dev script (MarcoFalke)
0.14
MarcoFalke 8 years ago
parent
commit
53ab12d931
No known key found for this signature in database
GPG Key ID: 2D7F2372E50FE137
  1. 6
      contrib/devtools/README.md
  2. 62
      contrib/devtools/clang-format.py
  3. 7
      doc/developer-notes.md
  4. 2
      src/.clang-format

6
contrib/devtools/README.md

@ -8,11 +8,6 @@ check-doc.py @@ -8,11 +8,6 @@ check-doc.py
Check if all command line args are documented. The return value indicates the
number of undocumented args.
clang-format.py
===============
A script to format cpp source code according to [.clang-format](../../src/.clang-format). This should only be applied to new files or files which are currently not actively developed on. Also, git subtrees are not subject to formatting.
clang-format-diff.py
===================
@ -24,6 +19,7 @@ the script should be called from the git root folder as follows. @@ -24,6 +19,7 @@ the script should be called from the git root folder as follows.
```
git diff -U0 HEAD~1.. | ./contrib/devtools/clang-format-diff.py -p1 -i -v
```
copyright\_header.py
====================

62
contrib/devtools/clang-format.py

@ -1,62 +0,0 @@ @@ -1,62 +0,0 @@
#!/usr/bin/env python
'''
Wrapper script for clang-format
Copyright (c) 2015 MarcoFalke
Copyright (c) 2015 The Bitcoin Core developers
Distributed under the MIT software license, see the accompanying
file COPYING or http://www.opensource.org/licenses/mit-license.php.
'''
import os
import sys
import subprocess
tested_versions = ['3.6.0', '3.6.1', '3.6.2'] # A set of versions known to produce the same output
accepted_file_extensions = ('.h', '.cpp') # Files to format
def check_clang_format_version(clang_format_exe):
try:
output = subprocess.check_output([clang_format_exe, '-version'])
for ver in tested_versions:
if ver in output:
print "Detected clang-format version " + ver
return
raise RuntimeError("Untested version: " + output)
except Exception as e:
print 'Could not verify version of ' + clang_format_exe + '.'
raise e
def check_command_line_args(argv):
required_args = ['{clang-format-exe}', '{files}']
example_args = ['clang-format-3.x', 'src/main.cpp', 'src/wallet/*']
if(len(argv) < len(required_args) + 1):
for word in (['Usage:', argv[0]] + required_args):
print word,
print ''
for word in (['E.g:', argv[0]] + example_args):
print word,
print ''
sys.exit(1)
def run_clang_format(clang_format_exe, files):
for target in files:
if os.path.isdir(target):
for path, dirs, files in os.walk(target):
run_clang_format(clang_format_exe, (os.path.join(path, f) for f in files))
elif target.endswith(accepted_file_extensions):
print "Format " + target
subprocess.check_call([clang_format_exe, '-i', '-style=file', target], stdout=open(os.devnull, 'wb'), stderr=subprocess.STDOUT)
else:
print "Skip " + target
def main(argv):
check_command_line_args(argv)
clang_format_exe = argv[1]
files = argv[2:]
check_clang_format_version(clang_format_exe)
run_clang_format(clang_format_exe, files)
if __name__ == "__main__":
main(sys.argv)

7
doc/developer-notes.md

@ -4,10 +4,11 @@ Developer Notes @@ -4,10 +4,11 @@ Developer Notes
Various coding styles have been used during the history of the codebase,
and the result is not very consistent. However, we're now trying to converge to
a single style, so please use it in new code. Old code will be converted
gradually.
gradually and you are encouraged to use the provided
[clang-format-diff script](/contrib/devtools/README.md#clang-format-diffpy)
to clean up the patch automatically before submitting a pull request.
- Basic rules specified in [src/.clang-format](/src/.clang-format).
Use a recent clang-format to format automatically using one of the [dev scripts]
(/contrib/devtools/README.md#clang-formatpy).
- Braces on new lines for namespaces, classes, functions, methods.
- Braces on the same line for everything else.
- 4 space indentation (no tabs) for every block except namespaces.

2
src/.clang-format

@ -6,7 +6,7 @@ AlignTrailingComments: true @@ -6,7 +6,7 @@ AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: false
AllowShortIfStatementsOnASingleLine: true
AllowShortLoopsOnASingleLine: false
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: true

Loading…
Cancel
Save