diff options
author | Martin Bligh <mbligh@mongodb.com> | 2015-06-26 08:24:54 -0400 |
---|---|---|
committer | Martin Bligh <mbligh@mongodb.com> | 2015-06-26 08:25:48 -0400 |
commit | 0a9a207be302c2deb23311659cad158f84f3a9bf (patch) | |
tree | 1e4ba38ece39d6b77e25a0fbd714bb44cccde74c /buildscripts/clang_format.py | |
parent | 3fa33903f4707e80a05b6e1a29d82f595ddb8531 (diff) | |
download | mongo-0a9a207be302c2deb23311659cad158f84f3a9bf.tar.gz |
SERVER-19070: Fix various clang-format issues
Diffstat (limited to 'buildscripts/clang_format.py')
-rwxr-xr-x | buildscripts/clang_format.py | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/buildscripts/clang_format.py b/buildscripts/clang_format.py index 07371f09f15..3e4b16707b7 100755 --- a/buildscripts/clang_format.py +++ b/buildscripts/clang_format.py @@ -29,7 +29,7 @@ from multiprocessing import cpu_count # Get relative imports to work when the package is not installed on the PYTHONPATH. if __name__ == "__main__" and __package__ is None: - sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) + sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(os.path.realpath(__file__))))) from buildscripts.resmokelib.utils import globstar from buildscripts import moduleconfig @@ -189,7 +189,10 @@ class ClangFormat(object): and linting/formating an individual file """ def __init__(self, path, cache_dir): - clang_format_progname = CLANG_FORMAT_PROGNAME + if os.path.exists('/usr/bin/clang-format-3.6'): + clang_format_progname = 'clang-format-3.6' + else: + clang_format_progname = CLANG_FORMAT_PROGNAME # Initialize clang-format configuration information if sys.platform.startswith("linux"): @@ -315,7 +318,7 @@ def parallel_process(items, func): except NotImplementedError: cpus = 1 - print("Running across %d cpus" % (cpus)) + # print("Running across %d cpus" % (cpus)) task_queue = Queue.Queue() @@ -379,9 +382,11 @@ def get_base_dir(): This script assumes that it is running in buildscripts/, and uses that to find the base directory. """ - script_path = os.path.dirname(os.path.realpath(__file__)) - - return os.path.dirname(script_path) + try: + return subprocess.check_output(['git', 'rev-parse', '--show-toplevel']).rstrip() + except: + # We are not in a valid git directory. Use the script path instead. + return os.path.dirname(os.path.dirname(os.path.realpath(__file__))) def get_repos(): """Get a list of Repos to check clang-format for |