aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/markdown/Dependencies.md2
-rw-r--r--docs/markdown/Users.md1
-rw-r--r--mesonbuild/backend/ninjabackend.py2
-rw-r--r--mesonbuild/compilers/cpp.py25
-rw-r--r--mesonbuild/dependencies/dev.py4
-rw-r--r--mesonbuild/interpreter/interpreter.py2
-rw-r--r--mesonbuild/scripts/clangformat.py55
-rw-r--r--mesonbuild/scripts/clangtidy.py53
-rw-r--r--mesonbuild/scripts/run_tool.py65
-rw-r--r--test cases/common/221 zlib/meson.build4
10 files changed, 105 insertions, 108 deletions
diff --git a/docs/markdown/Dependencies.md b/docs/markdown/Dependencies.md
index db8623a..86084ea 100644
--- a/docs/markdown/Dependencies.md
+++ b/docs/markdown/Dependencies.md
@@ -711,7 +711,7 @@ $ wx-config --libs std stc
## Zlib
Zlib ships with pkg-config and cmake support, but on some operating
-systems (windows, macOs, FreeBSD, dragonflybsd), it is provided as
+systems (windows, macOs, FreeBSD, dragonflybsd, android), it is provided as
part of the base operating system without pkg-config support. The new
System finder can be used on these OSes to link with the bundled
version.
diff --git a/docs/markdown/Users.md b/docs/markdown/Users.md
index 032ec1e..bd146d7 100644
--- a/docs/markdown/Users.md
+++ b/docs/markdown/Users.md
@@ -96,6 +96,7 @@ format files
- [Marker](https://github.com/fabiocolacio/Marker), a GTK-3 markdown editor
- [Mesa](https://gitlab.freedesktop.org/mesa/mesa/), an open source graphics driver project
- [MiracleCast](https://github.com/albfan/miraclecast), connect external monitors to your system via Wifi-Display specification aka Miracast
+ - [mpv](https://github.com/mpv-player/mpv), a free, open source, and cross-platform media player
- [mrsh](https://github.com/emersion/mrsh), a minimal POSIX shell
- [Nautilus](https://gitlab.gnome.org/GNOME/nautilus), the GNOME file manager
- [Nemo](https://github.com/linuxmint/nemo), the file manager for the Cinnamon desktop environment
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py
index 2ababd2..a1d3e50 100644
--- a/mesonbuild/backend/ninjabackend.py
+++ b/mesonbuild/backend/ninjabackend.py
@@ -1402,7 +1402,7 @@ class NinjaBackend(backends.Backend):
for i in dep.sources:
if hasattr(i, 'fname'):
i = i.fname
- if i.endswith('vala'):
+ if i.split('.')[-1] in compilers.lang_suffixes['vala']:
vapiname = dep.vala_vapi
fullname = os.path.join(self.get_target_dir(dep), vapiname)
result.add(fullname)
diff --git a/mesonbuild/compilers/cpp.py b/mesonbuild/compilers/cpp.py
index 50e91a3..8bc013f 100644
--- a/mesonbuild/compilers/cpp.py
+++ b/mesonbuild/compilers/cpp.py
@@ -838,20 +838,21 @@ class C2000CPPCompiler(C2000Compiler, CPPCompiler):
opts[key].choices = ['none', 'c++03']
return opts
- def get_always_args(self) -> T.List[str]:
- return ['-nologo', '-lang=cpp']
-
def get_option_compile_args(self, options: 'KeyedOptionDictType') -> T.List[str]:
- return []
+ args = []
+ key = OptionKey('std', machine=self.for_machine, lang=self.language)
+ std = options[key]
+ if std.value != 'none':
+ args.append('--' + std.value)
+ return args
- def get_compile_only_args(self) -> T.List[str]:
- return []
+ def get_no_optimization_args(self) -> T.List[str]:
+ return ['-Ooff']
def get_output_args(self, target: str) -> T.List[str]:
- return [f'-output=obj={target}']
-
- def get_option_link_args(self, options: 'KeyedOptionDictType') -> T.List[str]:
- return []
+ return [f'--output_file={target}']
- def get_compiler_check_args(self, mode: CompileCheckMode) -> T.List[str]:
- return []
+ def get_include_args(self, path: str, is_system: bool) -> T.List[str]:
+ if path == '':
+ path = '.'
+ return ['--include_path=' + path]
diff --git a/mesonbuild/dependencies/dev.py b/mesonbuild/dependencies/dev.py
index 0df8685..016cf92 100644
--- a/mesonbuild/dependencies/dev.py
+++ b/mesonbuild/dependencies/dev.py
@@ -466,7 +466,7 @@ class ZlibSystemDependency(SystemDependency):
# I'm not sure this is entirely correct. What if we're cross compiling
# from something to macOS?
if ((m.is_darwin() and isinstance(self.clib_compiler, (AppleClangCCompiler, AppleClangCPPCompiler))) or
- m.is_freebsd() or m.is_dragonflybsd()):
+ m.is_freebsd() or m.is_dragonflybsd() or m.is_android()):
# No need to set includes,
# on macos xcode/clang will do that for us.
# on freebsd zlib.h is in /usr/include
@@ -474,7 +474,7 @@ class ZlibSystemDependency(SystemDependency):
self.is_found = True
self.link_args = ['-lz']
elif m.is_windows():
- # Without a clib_compiler we can't find zlib, s just give up.
+ # Without a clib_compiler we can't find zlib, so just give up.
if self.clib_compiler is None:
self.is_found = False
return
diff --git a/mesonbuild/interpreter/interpreter.py b/mesonbuild/interpreter/interpreter.py
index fc1db8b..2eb7a0a 100644
--- a/mesonbuild/interpreter/interpreter.py
+++ b/mesonbuild/interpreter/interpreter.py
@@ -2316,7 +2316,7 @@ This will become a hard error in the future.''', location=self.current_node)
mlog.warning('include_directories sandbox violation!')
print(textwrap.dedent(f'''\
The project is trying to access the directory {a} which belongs to a different
- subproject. This is a problem as it hardcodes the relative paths of these two projeccts.
+ subproject. This is a problem as it hardcodes the relative paths of these two projects.
This makes it impossible to compile the project in any other directory layout and also
prevents the subproject from changing its own directory layout.
diff --git a/mesonbuild/scripts/clangformat.py b/mesonbuild/scripts/clangformat.py
index ff0304a..9dc5466 100644
--- a/mesonbuild/scripts/clangformat.py
+++ b/mesonbuild/scripts/clangformat.py
@@ -14,34 +14,17 @@
import argparse
import subprocess
-import itertools
-import fnmatch
from pathlib import Path
-from concurrent.futures import ThreadPoolExecutor
+from .run_tool import run_tool
from ..environment import detect_clangformat
-from ..compilers import lang_suffixes
-from ..mesonlib import Popen_safe
import typing as T
-def parse_pattern_file(fname: Path) -> T.List[str]:
- patterns = []
- try:
- with fname.open(encoding='utf-8') as f:
- for line in f:
- pattern = line.strip()
- if pattern and not pattern.startswith('#'):
- patterns.append(pattern)
- except FileNotFoundError:
- pass
- return patterns
-
-def run_clang_format(exelist: T.List[str], fname: Path, check: bool) -> subprocess.CompletedProcess:
+def run_clang_format(fname: Path, exelist: T.List[str], check: bool) -> subprocess.CompletedProcess:
if check:
original = fname.read_bytes()
before = fname.stat().st_mtime
- args = ['-style=file', '-i', str(fname)]
- ret = subprocess.run(exelist + args)
+ ret = subprocess.run(exelist + ['-style=file', '-i', str(fname)])
after = fname.stat().st_mtime
if before != after:
print('File reformatted: ', fname)
@@ -51,36 +34,6 @@ def run_clang_format(exelist: T.List[str], fname: Path, check: bool) -> subproce
ret.returncode = 1
return ret
-def clangformat(exelist: T.List[str], srcdir: Path, builddir: Path, check: bool) -> int:
- patterns = parse_pattern_file(srcdir / '.clang-format-include')
- globs: T.Union[T.List[T.List[Path]], T.List[T.Generator[Path, None, None]]]
- if patterns:
- globs = [srcdir.glob(p) for p in patterns]
- else:
- p, o, _ = Popen_safe(['git', 'ls-files'], cwd=srcdir)
- if p.returncode == 0:
- globs = [[Path(srcdir, f) for f in o.splitlines()]]
- else:
- globs = [srcdir.glob('**/*')]
- patterns = parse_pattern_file(srcdir / '.clang-format-ignore')
- ignore = [str(builddir / '*')]
- ignore.extend([str(srcdir / p) for p in patterns])
- suffixes = set(lang_suffixes['c']).union(set(lang_suffixes['cpp']))
- suffixes.add('h')
- suffixes = {f'.{s}' for s in suffixes}
- futures = []
- returncode = 0
- with ThreadPoolExecutor() as e:
- for f in itertools.chain(*globs):
- strf = str(f)
- if f.is_dir() or f.suffix not in suffixes or \
- any(fnmatch.fnmatch(strf, i) for i in ignore):
- continue
- futures.append(e.submit(run_clang_format, exelist, f, check))
- if futures:
- returncode = max(x.result().returncode for x in futures)
- return returncode
-
def run(args: T.List[str]) -> int:
parser = argparse.ArgumentParser()
parser.add_argument('--check', action='store_true')
@@ -96,4 +49,4 @@ def run(args: T.List[str]) -> int:
print('Could not execute clang-format "%s"' % ' '.join(exelist))
return 1
- return clangformat(exelist, srcdir, builddir, options.check)
+ return run_tool('clang-format', srcdir, builddir, run_clang_format, exelist, options.check)
diff --git a/mesonbuild/scripts/clangtidy.py b/mesonbuild/scripts/clangtidy.py
index 9f48942..7364e27 100644
--- a/mesonbuild/scripts/clangtidy.py
+++ b/mesonbuild/scripts/clangtidy.py
@@ -12,46 +12,23 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-import pathlib
+import argparse
import subprocess
-import shutil
-import os
-import re
-from concurrent.futures import ThreadPoolExecutor
+from pathlib import Path
+
+from .run_tool import run_tool
import typing as T
-from ..compilers import lang_suffixes
-
-def manual_clangtidy(srcdir_name: str, builddir_name: str) -> int:
- srcdir = pathlib.Path(srcdir_name)
- suffixes = set(lang_suffixes['c']).union(set(lang_suffixes['cpp']))
- suffixes.add('h')
- futures = []
- returncode = 0
- with ThreadPoolExecutor() as e:
- for f in (x for suff in suffixes for x in srcdir.glob('**/*.' + suff)):
- if f.is_dir():
- continue
- strf = str(f)
- if strf.startswith(builddir_name):
- continue
- futures.append(e.submit(subprocess.run, ['clang-tidy', '-p', builddir_name, strf]))
- returncode = max(x.result().returncode for x in futures)
- return returncode
-
-def clangtidy(srcdir_name: str, builddir_name: str) -> int:
- run_clang_tidy = None
- for rct in ('run-clang-tidy', 'run-clang-tidy.py'):
- if shutil.which(rct):
- run_clang_tidy = rct
- break
- if run_clang_tidy:
- return subprocess.run([run_clang_tidy, '-p', builddir_name, '^(?!' + re.escape(builddir_name + os.path.sep) + ').*$']).returncode
- else:
- print('Could not find run-clang-tidy, running checks manually.')
- return manual_clangtidy(srcdir_name, builddir_name)
+def run_clang_tidy(fname: Path, builddir: Path) -> subprocess.CompletedProcess:
+ return subprocess.run(['clang-tidy', '-p', str(builddir), str(fname)])
def run(args: T.List[str]) -> int:
- srcdir_name = args[0]
- builddir_name = args[1]
- return clangtidy(srcdir_name, builddir_name)
+ parser = argparse.ArgumentParser()
+ parser.add_argument('sourcedir')
+ parser.add_argument('builddir')
+ options = parser.parse_args(args)
+
+ srcdir = Path(options.sourcedir)
+ builddir = Path(options.builddir)
+
+ return run_tool('clang-tidy', srcdir, builddir, run_clang_tidy, builddir)
diff --git a/mesonbuild/scripts/run_tool.py b/mesonbuild/scripts/run_tool.py
new file mode 100644
index 0000000..700f459
--- /dev/null
+++ b/mesonbuild/scripts/run_tool.py
@@ -0,0 +1,65 @@
+# Copyright 2018 The Meson development team
+
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+
+# http://www.apache.org/licenses/LICENSE-2.0
+
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import subprocess
+import itertools
+import fnmatch
+from pathlib import Path
+from concurrent.futures import ThreadPoolExecutor
+
+from ..compilers import lang_suffixes
+from ..mesonlib import Popen_safe
+import typing as T
+
+def parse_pattern_file(fname: Path) -> T.List[str]:
+ patterns = []
+ try:
+ with fname.open(encoding='utf-8') as f:
+ for line in f:
+ pattern = line.strip()
+ if pattern and not pattern.startswith('#'):
+ patterns.append(pattern)
+ except FileNotFoundError:
+ pass
+ return patterns
+
+def run_tool(name: str, srcdir: Path, builddir: Path, fn: T.Callable[..., subprocess.CompletedProcess], *args: T.Any) -> int:
+ patterns = parse_pattern_file(srcdir / f'.{name}-include')
+ globs: T.Union[T.List[T.List[Path]], T.List[T.Generator[Path, None, None]]]
+ if patterns:
+ globs = [srcdir.glob(p) for p in patterns]
+ else:
+ p, o, _ = Popen_safe(['git', 'ls-files'], cwd=srcdir)
+ if p.returncode == 0:
+ globs = [[Path(srcdir, f) for f in o.splitlines()]]
+ else:
+ globs = [srcdir.glob('**/*')]
+ patterns = parse_pattern_file(srcdir / f'.{name}-ignore')
+ ignore = [str(builddir / '*')]
+ ignore.extend([str(srcdir / p) for p in patterns])
+ suffixes = set(lang_suffixes['c']).union(set(lang_suffixes['cpp']))
+ suffixes.add('h')
+ suffixes = {f'.{s}' for s in suffixes}
+ futures = []
+ returncode = 0
+ with ThreadPoolExecutor() as e:
+ for f in itertools.chain(*globs):
+ strf = str(f)
+ if f.is_dir() or f.suffix not in suffixes or \
+ any(fnmatch.fnmatch(strf, i) for i in ignore):
+ continue
+ futures.append(e.submit(fn, f, *args))
+ if futures:
+ returncode = max(x.result().returncode for x in futures)
+ return returncode
diff --git a/test cases/common/221 zlib/meson.build b/test cases/common/221 zlib/meson.build
index c53f71e..b5b813c 100644
--- a/test cases/common/221 zlib/meson.build
+++ b/test cases/common/221 zlib/meson.build
@@ -1,7 +1,7 @@
project('zlib system dependency', 'c')
-if not ['darwin', 'freebsd', 'dragonfly', 'windows'].contains(host_machine.system())
- error('MESON_SKIP_TEST only applicable on macOS, FreeBSD, DragonflyBSD, and Windows.')
+if not ['darwin', 'freebsd', 'dragonfly', 'windows', 'android'].contains(host_machine.system())
+ error('MESON_SKIP_TEST only applicable on macOS, FreeBSD, DragonflyBSD, Windows, and Android.')
endif
cc = meson.get_compiler('c')