diff options
author | Ting-Wei Lan <lantw@src.gnome.org> | 2019-09-19 21:24:04 +0800 |
---|---|---|
committer | Ting-Wei Lan <lantw@src.gnome.org> | 2019-09-29 00:11:15 +0800 |
commit | 0390b673f11cc2834b6a04e1fc5e58e4cb24afcb (patch) | |
tree | 86e28fd355a32a9ccec58f481e5af58a6f606086 /mesonbuild/scripts | |
parent | 08ce1fb541374fb1ddce1d7318ceb92459942e9e (diff) | |
download | meson-0390b673f11cc2834b6a04e1fc5e58e4cb24afcb.zip meson-0390b673f11cc2834b6a04e1fc5e58e4cb24afcb.tar.gz meson-0390b673f11cc2834b6a04e1fc5e58e4cb24afcb.tar.bz2 |
Find clang-format with alternative names
This is similar to what we currently do for scan-build except there is
no environment variable to choose a specific clang-format to run. If an
environment variable is needed for better control, we can add it later.
Diffstat (limited to 'mesonbuild/scripts')
-rw-r--r-- | mesonbuild/scripts/clangformat.py | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/mesonbuild/scripts/clangformat.py b/mesonbuild/scripts/clangformat.py index 351d06b..4b441de 100644 --- a/mesonbuild/scripts/clangformat.py +++ b/mesonbuild/scripts/clangformat.py @@ -16,9 +16,10 @@ import pathlib import subprocess from concurrent.futures import ThreadPoolExecutor +from ..environment import detect_clangformat from ..compilers import lang_suffixes -def clangformat(srcdir_name, builddir_name): +def clangformat(exelist, srcdir_name, builddir_name): srcdir = pathlib.Path(srcdir_name) suffixes = set(lang_suffixes['c']).union(set(lang_suffixes['cpp'])) suffixes.add('h') @@ -28,11 +29,17 @@ def clangformat(srcdir_name, builddir_name): strf = str(f) if strf.startswith(builddir_name): continue - futures.append(e.submit(subprocess.check_call, ['clang-format', '-style=file', '-i', strf])) + futures.append(e.submit(subprocess.check_call, exelist + ['-style=file', '-i', strf])) [x.result() for x in futures] return 0 def run(args): srcdir_name = args[0] builddir_name = args[1] - return clangformat(srcdir_name, builddir_name) + + exelist = detect_clangformat() + if not exelist: + print('Could not execute clang-format "%s"' % ' '.join(exelist)) + return 1 + + return clangformat(exelist, srcdir_name, builddir_name) |