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/environment.py | |
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/environment.py')
-rw-r--r-- | mesonbuild/environment.py | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py index 7c10825..0fec347 100644 --- a/mesonbuild/environment.py +++ b/mesonbuild/environment.py @@ -189,7 +189,7 @@ def get_llvm_tool_names(tool: str) -> typing.List[str]: names.append(tool + suffix) return names -def detect_scanbuild(): +def detect_scanbuild() -> typing.List[str]: """ Look for scan-build binary on build platform First, if a SCANBUILD env variable has been provided, give it precedence @@ -220,6 +220,22 @@ def detect_scanbuild(): return [tool] return [] +def detect_clangformat() -> typing.List[str]: + """ Look for clang-format binary on build platform + + Do the same thing as detect_scanbuild to find clang-format except it + currently does not check the environment variable. + + Return: a single-element list of the found clang-format binary ready to be + passed to Popen() + """ + tools = get_llvm_tool_names('clang-format') + for tool in tools: + path = shutil.which(tool) + if path is not None: + return [path] + return [] + def detect_native_windows_arch(): """ The architecture of Windows itself: x86, amd64 or arm64 |