Merge pull request #5939 from lantw44/move-the-list-of-llvm-versions-to-a-common-place

Move the list of LLVM versions to a common place
pull/5702/head
Jussi Pakkanen 5 years ago committed by GitHub
commit 1473fbc3f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      mesonbuild/backend/ninjabackend.py
  2. 21
      mesonbuild/dependencies/dev.py
  3. 60
      mesonbuild/environment.py
  4. 13
      mesonbuild/scripts/clangformat.py

@ -2657,9 +2657,8 @@ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47485'''))
self.create_target_alias('meson-scan-build')
def generate_clangformat(self):
import shutil
target_name = 'clang-format'
if shutil.which('clang-format') is None:
if not environment.detect_clangformat():
return
if not os.path.exists(os.path.join(self.environment.source_dir, '.clang-format')) and \
not os.path.exists(os.path.join(self.environment.source_dir, '_clang-format')):

@ -22,6 +22,7 @@ import re
from .. import mesonlib, mlog
from ..mesonlib import version_compare, stringlistify, extract_as_list, MachineChoice
from ..environment import get_llvm_tool_names
from .base import (
DependencyException, DependencyMethods, ExternalDependency, PkgConfigDependency,
strip_system_libdirs, ConfigToolDependency, CMakeDependency, HasNativeKwarg
@ -208,25 +209,7 @@ class LLVMDependencyConfigTool(ConfigToolDependency):
# before `super().__init__` is called.
HasNativeKwarg.__init__(self, kwargs)
# Ordered list of llvm-config binaries to try. Start with base, then try
# newest back to oldest (3.5 is arbitrary), and finally the devel version.
# Please note that llvm-config-6.0 is a development snapshot and it should
# not be moved to the beginning of the list.
self.tools = [
'llvm-config', # base
'llvm-config-8', 'llvm-config80',
'llvm-config-7', 'llvm-config70',
'llvm-config-6.0', 'llvm-config60',
'llvm-config-5.0', 'llvm-config50',
'llvm-config-4.0', 'llvm-config40',
'llvm-config-3.9', 'llvm-config39',
'llvm-config-3.8', 'llvm-config38',
'llvm-config-3.7', 'llvm-config37',
'llvm-config-3.6', 'llvm-config36',
'llvm-config-3.5', 'llvm-config35',
'llvm-config-9', # Debian development snapshot
'llvm-config-devel', # FreeBSD development snapshot
]
self.tools = get_llvm_tool_names('llvm-config')
# Fedora starting with Fedora 30 adds a suffix of the number
# of bits in the isa that llvm targets, for example, on x86_64

@ -163,7 +163,34 @@ def detect_ninja(version: str = '1.5', log: bool = False) -> str:
mlog.log('Found {}-{} at {}'.format(name, found, quote_arg(n)))
return n
def detect_scanbuild():
def get_llvm_tool_names(tool: str) -> typing.List[str]:
# Ordered list of possible suffixes of LLVM executables to try. Start with
# base, then try newest back to oldest (3.5 is arbitrary), and finally the
# devel version. Please note that the development snapshot in Debian does
# not have a distinct name. Do not move it to the beginning of the list
# unless it becomes a stable release.
suffixes = [
'', # base (no suffix)
'-9', '90',
'-8', '80',
'-7', '70',
'-6.0', '60',
'-5.0', '50',
'-4.0', '40',
'-3.9', '39',
'-3.8', '38',
'-3.7', '37',
'-3.6', '36',
'-3.5', '35',
'-10', # Debian development snapshot
'-devel', # FreeBSD development snapshot
]
names = []
for suffix in suffixes:
names.append(tool + suffix)
return names
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
@ -182,20 +209,7 @@ def detect_scanbuild():
exelist = split_args(os.environ['SCANBUILD'])
else:
tools = [
'scan-build', # base
'scan-build-8', 'scan-build80',
'scan-build-7', 'scan-build70',
'scan-build-6.0', 'scan-build60',
'scan-build-5.0', 'scan-build50',
'scan-build-4.0', 'scan-build40',
'scan-build-3.9', 'scan-build39',
'scan-build-3.8', 'scan-build38',
'scan-build-3.7', 'scan-build37',
'scan-build-3.6', 'scan-build36',
'scan-build-3.5', 'scan-build35',
'scan-build-9', 'scan-build-devel', # development snapshot
]
tools = get_llvm_tool_names('scan-build')
for tool in tools:
if shutil.which(tool) is not None:
exelist = [shutil.which(tool)]
@ -207,6 +221,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

@ -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)

Loading…
Cancel
Save