diff options
-rw-r--r-- | data/syntax-highlighting/vim/syntax/meson.vim | 1 | ||||
-rw-r--r-- | docs/markdown/Users.md | 2 | ||||
-rwxr-xr-x | meson.py | 11 | ||||
-rw-r--r-- | mesonbuild/backend/backends.py | 10 | ||||
-rw-r--r-- | mesonbuild/interpreter.py | 2 | ||||
-rw-r--r-- | mesonbuild/mesonlib.py | 29 |
6 files changed, 41 insertions, 14 deletions
diff --git a/data/syntax-highlighting/vim/syntax/meson.vim b/data/syntax-highlighting/vim/syntax/meson.vim index 49921c1..e06b2df 100644 --- a/data/syntax-highlighting/vim/syntax/meson.vim +++ b/data/syntax-highlighting/vim/syntax/meson.vim @@ -112,6 +112,7 @@ syn keyword mesonBuiltin \ target_machine \ test \ vcs_tag + \ warning if exists("meson_space_error_highlight") " trailing whitespace diff --git a/docs/markdown/Users.md b/docs/markdown/Users.md index bd9f313..959eac6 100644 --- a/docs/markdown/Users.md +++ b/docs/markdown/Users.md @@ -38,7 +38,7 @@ If you have a project that uses Meson that you want to add to this list, let us - [Pitivi](http://pitivi.org/), a nonlinear video editor - [Polari](https://git.gnome.org/browse/polari), an IRC client - [Sysprof](https://wiki.gnome.org/Apps/Sysprof), a profiling tool - - [systemd](https://github.com/systemd/systemd/pull/5704), the init system (not the default yet) + - [systemd](https://github.com/systemd/systemd), the init system - [Xorg](https://cgit.freedesktop.org/xorg/xserver/) the X.org display server (not the default yet) - [Valum](https://github.com/valum-framework/valum), a micro web framework written in Vala - [Wayland and Weston](https://lists.freedesktop.org/archives/wayland-devel/2016-November/031984.html), a next generation display server (not merged yet) @@ -18,17 +18,6 @@ from mesonbuild import mesonmain, mesonlib import sys, os, locale def main(): - # Warn if the locale is not UTF-8. This can cause various unfixable issues - # such as os.stat not being able to decode filenames with unicode in them. - # There is no way to reset both the preferred encoding and the filesystem - # encoding, so we can just warn about it. - e = locale.getpreferredencoding() - if e.upper() != 'UTF-8' and not mesonlib.is_windows(): - print('Warning: You are using {!r} which is not a Unicode-compatible ' - 'locale.'.format(e), file=sys.stderr) - print('You might see errors if you use UTF-8 strings as ' - 'filenames, as strings, or as file contents.', file=sys.stderr) - print('Please switch to a UTF-8 locale for your platform.', file=sys.stderr) # Always resolve the command path so Ninja can find it for regen, tests, etc. launcher = os.path.realpath(sys.argv[0]) return mesonmain.run(sys.argv[1:], launcher) diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py index 3f1e4ce..5a5db22 100644 --- a/mesonbuild/backend/backends.py +++ b/mesonbuild/backend/backends.py @@ -346,6 +346,11 @@ class Backend: assert isinstance(source, mesonlib.File) build_dir = self.environment.get_build_dir() rel_src = source.rel_to_builddir(self.build_to_src) + + if (not self.environment.is_source(rel_src) or + self.environment.is_header(rel_src)) and not is_unity: + return None + # foo.vala files compile down to foo.c and then foo.c.o, not foo.vala.o if rel_src.endswith(('.vala', '.gs')): # See description in generate_vala_compile for this logic. @@ -393,8 +398,9 @@ class Backend: return [objpath] for osrc in extobj.srclist: objname = self.object_filename_from_source(extobj.target, osrc, False) - objpath = os.path.join(proj_dir_to_build_root, targetdir, objname) - result.append(objpath) + if objname: + objpath = os.path.join(proj_dir_to_build_root, targetdir, objname) + result.append(objpath) return result def get_pch_include_args(self, compiler, target): diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index f33d437..cbf1413 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -2503,6 +2503,7 @@ to directly access options of other subprojects.''') @permittedKwargs(permitted_kwargs['subdir']) def func_subdir(self, node, args, kwargs): self.validate_arguments(args, 1, [str]) + mesonlib.check_direntry_issues(args) if '..' in args[0]: raise InvalidArguments('Subdir contains ..') if self.subdir == '' and args[0] == self.subproject_dir: @@ -2912,6 +2913,7 @@ different subdirectory. def source_strings_to_files(self, sources): results = [] + mesonlib.check_direntry_issues(sources) for s in sources: if isinstance(s, (mesonlib.File, GeneratedListHolder, CustomTargetHolder, CustomTargetIndexHolder)): diff --git a/mesonbuild/mesonlib.py b/mesonbuild/mesonlib.py index f10a138..9ad0668 100644 --- a/mesonbuild/mesonlib.py +++ b/mesonbuild/mesonlib.py @@ -19,6 +19,7 @@ import stat import time import platform, subprocess, operator, os, shutil, re import collections +from mesonbuild import mlog from glob import glob @@ -59,6 +60,34 @@ else: python_command = [sys.executable] meson_command = python_command + [detect_meson_py_location()] +def is_ascii_string(astring): + try: + if isinstance(astring, str): + astring.encode('ascii') + if isinstance(astring, bytes): + astring.decode('ascii') + except UnicodeDecodeError: + return False + return True + +def check_direntry_issues(direntry_array): + import locale + # Warn if the locale is not UTF-8. This can cause various unfixable issues + # such as os.stat not being able to decode filenames with unicode in them. + # There is no way to reset both the preferred encoding and the filesystem + # encoding, so we can just warn about it. + e = locale.getpreferredencoding() + if e.upper() != 'UTF-8' and not is_windows(): + if not isinstance(direntry_array, list): + direntry_array = [direntry_array] + for de in direntry_array: + if is_ascii_string(de): + continue + mlog.warning('''You are using {!r} which is not a Unicode-compatible ' +locale but you are trying to access a file system entry called {!r} which is +not pure ASCII. This may cause problems. +'''.format(e, de), file=sys.stderr) + # Put this in objects that should not get dumped to pickle files # by accident. import threading |