Skip to content
Browse files

Merge pull request #6790

8c15f33 [trivial] Update contrib/devtools/ (MarcoFalke)
338f62f [devtools] add (MarcoFalke)
  • Loading branch information
laanwj committed Oct 23, 2015
2 parents b2b173a + 8c15f33 commit fa1d252e82a8ea76fd6691955eae5cae6ec8bc5a
Showing with 82 additions and 6 deletions.
  1. +20 −6 contrib/devtools/
  2. +62 −0 contrib/devtools/
@@ -1,9 +1,14 @@
This directory contains tools for developers working on this repository.

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.

A small script to automate merging pull-requests securely and sign them with GPG.

@@ -37,23 +42,31 @@ Configuring the github-merge tool for the bitcoin repository is done in the foll
git config --global user.signingkey mykeyid (if you want to GPG sign)

Every year newly updated files need to have its copyright headers updated to reflect the current year.
If you run this script from src/ it will automatically update the year on the copyright header for all
.cpp and .h files if these have a git commit from the current year.

For example a file changed in 2014 (with 2014 being the current year):

```// Copyright (c) 2009-2013 The Bitcoin Core developers```
would be changed to:
```// Copyright (c) 2009-2014 The Bitcoin Core developers```
A script to optimize png files in the bitcoin
repository (requires pngcrush).
A script to check that the (Linux) executables produced by gitian only contain
allowed gcc, glibc and libstdc++ version symbols. This makes sure they are
allowed gcc, glibc and libstdc++ version symbols. This makes sure they are
still compatible with the minimum supported Linux distribution versions.
Example usage after a gitian build:
@@ -70,7 +83,7 @@ If there are 'unsupported' symbols, the return value will be 1 a list like this
.../64/test_bitcoin: symbol _ZNSt8__detail15_List_nod from unsupported version GLIBCXX_3.4.15
Run this script from the root of the repository to update all translations from transifex.
It will do the following automatically:
@@ -93,4 +106,5 @@ maintained:
* for sec/leveldb: (branch bitcoin-fork)
COMMIT may be omitted, in which case HEAD is used.
@@ -0,0 +1,62 @@
#!/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

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):
output = subprocess.check_output([clang_format_exe, '-version'])
for ver in tested_versions:
if ver in output:
print "Detected clang-format version " + ver
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 ''

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)
print "Skip " + target

def main(argv):
clang_format_exe = argv[1]
files = argv[2:]
run_clang_format(clang_format_exe, files)

if __name__ == "__main__":

0 comments on commit fa1d252

Please sign in to comment.
You can’t perform that action at this time.