diff options
-rw-r--r-- | mesonbuild/backend/backends.py | 4 | ||||
-rw-r--r-- | mesonbuild/backend/ninjabackend.py | 9 | ||||
-rw-r--r-- | mesonbuild/build.py | 10 | ||||
-rw-r--r-- | mesonbuild/compilers.py | 20 | ||||
-rw-r--r-- | mesonbuild/mesonmain.py | 4 | ||||
-rw-r--r-- | mesonbuild/mlog.py | 6 | ||||
-rw-r--r-- | mesonbuild/modules/gnome.py | 12 | ||||
-rw-r--r-- | mesonbuild/modules/pkgconfig.py | 4 | ||||
-rw-r--r-- | mesonbuild/modules/qt4.py | 6 | ||||
-rw-r--r-- | mesonbuild/modules/qt5.py | 6 | ||||
-rw-r--r-- | mesonbuild/modules/rpm.py | 15 | ||||
-rw-r--r-- | mesonbuild/scripts/scanbuild.py | 13 | ||||
-rw-r--r-- | mesonbuild/scripts/yelphelper.py | 2 | ||||
-rwxr-xr-x | run_project_tests.py | 2 | ||||
-rw-r--r-- | test cases/common/16 configure file/config.h | 1 | ||||
-rw-r--r-- | test cases/common/16 configure file/prog.c | 5 | ||||
-rw-r--r-- | test cases/common/16 configure file/prog2.c | 2 |
17 files changed, 71 insertions, 50 deletions
diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py index a4f2b51..bd75fdb 100644 --- a/mesonbuild/backend/backends.py +++ b/mesonbuild/backend/backends.py @@ -81,8 +81,8 @@ class Backend(): def get_target_filename(self, t): if isinstance(t, build.CustomTarget): if len(t.get_outputs()) != 1: - mlog.log(mlog.red('WARNING'), 'custom_target {!r} has more ' \ - 'than one output! Using the first one.'.format(t.name)) + mlog.warning('custom_target {!r} has more than one output! ' \ + 'Using the first one.'.format(t.name)) filename = t.get_outputs()[0] else: assert(isinstance(t, build.BuildTarget)) diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index 8329b59..63380bd 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -215,7 +215,7 @@ int dummy; with open(os.path.join(builddir, 'compile_commands.json'), 'wb') as f: f.write(jsondb) except Exception: - mlog.log(mlog.red('Warning:', 'Could not create compilation database.')) + mlog.warning('Could not create compilation database.') # Get all generated headers. Any source file might need them so # we need to add an order dependency to them. @@ -581,7 +581,7 @@ int dummy; elem.add_item('DESC', 'Generating HTML coverage report.') elem.write(outfile) if not added_rule: - mlog.log(mlog.red('Warning:'), 'coverage requested but neither gcovr nor lcov/genhtml found.') + mlog.warning('coverage requested but neither gcovr nor lcov/genhtml found.') def generate_install(self, outfile): install_data_file = os.path.join(self.environment.get_scratch_dir(), 'install.dat') @@ -1720,10 +1720,11 @@ rule FORTRAN_DEP_HACK # Add the root source and build directories as include dirs curdir = target.get_subdir() tmppath = os.path.normpath(os.path.join(self.build_to_src, curdir)) - commands += compiler.get_include_args(tmppath, False) + src_inc = compiler.get_include_args(tmppath, False) if curdir == '': curdir = '.' - commands += compiler.get_include_args(curdir, False) + build_inc = compiler.get_include_args(curdir, False) + commands += build_inc + src_inc # -I args work differently than other ones. In them the first found # directory is used whereas for other flags (such as -ffoo -fno-foo) the # latest one is used. Therefore put the internal include directories diff --git a/mesonbuild/build.py b/mesonbuild/build.py index c3867e0..d87d9a0 100644 --- a/mesonbuild/build.py +++ b/mesonbuild/build.py @@ -309,8 +309,8 @@ class BuildTarget(): if not k in known_kwargs: unknowns.append(k) if len(unknowns) > 0: - mlog.log(mlog.bold('Warning:'), 'Unknown keyword argument(s) in target %s: %s.' % - (self.name, ', '.join(unknowns))) + mlog.warning('Unknown keyword argument(s) in target %s: %s.' % + (self.name, ', '.join(unknowns))) def process_objectlist(self, objects): assert(isinstance(objects, list)) @@ -583,7 +583,7 @@ class BuildTarget(): if for_darwin(self.is_cross, self.environment) or for_windows(self.is_cross, self.environment): self.pic = True elif '-fPIC' in clist + cpplist: - mlog.log(mlog.red('WARNING:'), "Use the 'pic' kwarg instead of passing -fPIC manually to static library {!r}".format(self.name)) + mlog.warning("Use the 'pic' kwarg instead of passing -fPIC manually to static library {!r}".format(self.name)) self.pic = True else: self.pic = kwargs.get('pic', False) @@ -1139,8 +1139,8 @@ class CustomTarget: if k not in CustomTarget.known_kwargs: unknowns.append(k) if len(unknowns) > 0: - mlog.log(mlog.bold('Warning:'), 'Unknown keyword arguments in target %s: %s' % - (self.name, ', '.join(unknowns))) + mlog.warning('Unknown keyword arguments in target %s: %s' % + (self.name, ', '.join(unknowns))) def __repr__(self): repr_str = "<{0} {1}: {2}>" diff --git a/mesonbuild/compilers.py b/mesonbuild/compilers.py index 5953d04..2feae88 100644 --- a/mesonbuild/compilers.py +++ b/mesonbuild/compilers.py @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +import shutil import contextlib import subprocess, os.path import tempfile @@ -1299,11 +1300,20 @@ class JavaCompiler(Compiler): pc.wait() if pc.returncode != 0: raise EnvironmentException('Java compiler %s can not compile programs.' % self.name_string()) - cmdlist = [self.javarunner, obj] - pe = subprocess.Popen(cmdlist, cwd=work_dir) - pe.wait() - if pe.returncode != 0: - raise EnvironmentException('Executables created by Java compiler %s are not runnable.' % self.name_string()) + runner = shutil.which(self.javarunner) + if runner: + cmdlist = [runner, obj] + pe = subprocess.Popen(cmdlist, cwd=work_dir) + pe.wait() + if pe.returncode != 0: + raise EnvironmentException('Executables created by Java compiler %s are not runnable.' % self.name_string()) + else: + m = "Java Virtual Machine wasn't found, but it's needed by Meson. " \ + "Please install a JRE.\nIf you have specific needs where this " \ + "requirement doesn't make sense, please open a bug at " \ + "https://github.com/mesonbuild/meson/issues/new and tell us " \ + "all about it." + raise EnvironmentException(m) def needs_static_linker(self): return False diff --git a/mesonbuild/mesonmain.py b/mesonbuild/mesonmain.py index 943c087..500e5af 100644 --- a/mesonbuild/mesonmain.py +++ b/mesonbuild/mesonmain.py @@ -121,8 +121,8 @@ itself as required.''' def check_pkgconfig_envvar(self, env): curvar = os.environ.get('PKG_CONFIG_PATH', '') if curvar != env.coredata.pkgconf_envvar: - mlog.log(mlog.red("WARNING:"), 'PKG_CONFIG_PATH has changed between invocations from "%s" to "%s".' % - (env.coredata.pkgconf_envvar, curvar)) + mlog.warning('PKG_CONFIG_PATH has changed between invocations from "%s" to "%s".' % + (env.coredata.pkgconf_envvar, curvar)) env.coredata.pkgconf_envvar = curvar def generate(self): diff --git a/mesonbuild/mlog.py b/mesonbuild/mlog.py index dab51bd..cded2b0 100644 --- a/mesonbuild/mlog.py +++ b/mesonbuild/mlog.py @@ -53,6 +53,9 @@ def red(text): def green(text): return AnsiDecorator(text, "\033[1;32m") +def yellow(text): + return AnsiDecorator(text, "\033[1;33m") + def cyan(text): return AnsiDecorator(text, "\033[1;36m") @@ -81,3 +84,6 @@ def log(*args, **kwargs): if colorize_console: arr = process_markup(args, True) print(*arr, **kwargs) + +def warning(*args, **kwargs): + log(yellow('WARNING:'), *args, **kwargs) diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py index 27200ae..fa8aec4 100644 --- a/mesonbuild/modules/gnome.py +++ b/mesonbuild/modules/gnome.py @@ -44,10 +44,10 @@ class GnomeModule: global gresource_warning_printed if not gresource_warning_printed: if mesonlib.version_compare(self._get_native_glib_version(state), '< 2.50.0'): - mlog.log('Warning, GLib compiled dependencies do not work fully ' - 'with versions of GLib older than 2.50.0.\n' - 'See the following upstream issue:', - mlog.bold('https://bugzilla.gnome.org/show_bug.cgi?id=745754')) + mlog.warning('GLib compiled dependencies do not work fully ' + 'with versions of GLib older than 2.50.0.\n' + 'See the following upstream issue:', + mlog.bold('https://bugzilla.gnome.org/show_bug.cgi?id=745754')) gresource_warning_printed = True return [] @@ -136,7 +136,7 @@ class GnomeModule: cwd=state.environment.get_source_dir()) (stdout, _) = pc.communicate() if pc.returncode != 0: - mlog.log(mlog.bold('Warning:'), 'glib-compile-resources has failed to get the dependencies for {}'.format(cmd[1])) + mlog.warning('glib-compile-resources has failed to get the dependencies for {}'.format(cmd[1])) raise subprocess.CalledProcessError(pc.returncode, cmd) dep_files = stdout.split('\n')[:-1] @@ -297,7 +297,7 @@ class GnomeModule: except Exception: global girwarning_printed if not girwarning_printed: - mlog.log(mlog.bold('Warning:'), 'gobject-introspection dependency was not found, disabling gir generation.') + mlog.warning('gobject-introspection dependency was not found, disabling gir generation.') girwarning_printed = True return [] pkgargs = pkgstr.decode().strip().split() diff --git a/mesonbuild/modules/pkgconfig.py b/mesonbuild/modules/pkgconfig.py index 7556375..3ecb40d 100644 --- a/mesonbuild/modules/pkgconfig.py +++ b/mesonbuild/modules/pkgconfig.py @@ -34,7 +34,7 @@ class PkgConfigModule: return l.name # In other cases, we can't guarantee that the compiler will be able to # find the library via '-lfoo', so tell the user that. - mlog.log(mlog.red('WARNING:'), msg.format(l.name, 'name_prefix', l.name, pcfile)) + mlog.warning(msg.format(l.name, 'name_prefix', l.name, pcfile)) return l.name def generate_pkgconfig_file(self, state, libraries, subdirs, name, description, @@ -79,7 +79,7 @@ class PkgConfigModule: # If using a custom suffix, the compiler may not be able to # find the library if l.name_suffix_set: - mlog.log(mlog.red('WARNING:'), msg.format(l.name, 'name_suffix', lname, pcfile)) + mlog.warning(msg.format(l.name, 'name_suffix', lname, pcfile)) yield '-l%s' % lname if len(libraries) > 0: ofile.write('Libs: {}\n'.format(' '.join(generate_libs_flags(libraries)))) diff --git a/mesonbuild/modules/qt4.py b/mesonbuild/modules/qt4.py index 81a70fc..b1d951b 100644 --- a/mesonbuild/modules/qt4.py +++ b/mesonbuild/modules/qt4.py @@ -90,7 +90,7 @@ class Qt4Module(): result = [] for child in root[0]: if child.tag != 'file': - mlog.log("Warning, malformed rcc file: ", os.path.join(state.subdir, fname)) + mlog.warning("malformed rcc file: ", os.path.join(state.subdir, fname)) break else: result.append(os.path.join(state.subdir, relative_part, child.text)) @@ -150,6 +150,6 @@ class Qt4Module(): return sources def initialize(): - mlog.log('Warning, rcc dependencies will not work properly until this upstream issue is fixed:', - mlog.bold('https://bugreports.qt.io/browse/QTBUG-45460')) + mlog.warning('rcc dependencies will not work properly until this upstream issue is fixed:', + mlog.bold('https://bugreports.qt.io/browse/QTBUG-45460')) return Qt4Module() diff --git a/mesonbuild/modules/qt5.py b/mesonbuild/modules/qt5.py index 4f19b78..9fffcff 100644 --- a/mesonbuild/modules/qt5.py +++ b/mesonbuild/modules/qt5.py @@ -97,7 +97,7 @@ class Qt5Module(): result = [] for child in root[0]: if child.tag != 'file': - mlog.log("Warning, malformed rcc file: ", os.path.join(state.subdir, fname)) + mlog.warning("malformed rcc file: ", os.path.join(state.subdir, fname)) break else: result.append(os.path.join(state.subdir, relative_part, child.text)) @@ -160,6 +160,6 @@ class Qt5Module(): return sources def initialize(): - mlog.log('Warning, rcc dependencies will not work reliably until this upstream issue is fixed:', - mlog.bold('https://bugreports.qt.io/browse/QTBUG-45460')) + mlog.warning('rcc dependencies will not work reliably until this upstream issue is fixed:', + mlog.bold('https://bugreports.qt.io/browse/QTBUG-45460')) return Qt5Module() diff --git a/mesonbuild/modules/rpm.py b/mesonbuild/modules/rpm.py index 13aa20b..2c9ed57 100644 --- a/mesonbuild/modules/rpm.py +++ b/mesonbuild/modules/rpm.py @@ -63,8 +63,8 @@ class RPMModule: so_installed = True elif isinstance(target, build.StaticLibrary) and target.need_install: to_delete.add('%%{buildroot}%%{_libdir}/%s' % target.get_filename()) - mlog.log('Warning, removing', mlog.bold(target.get_filename()), - 'from package because packaging static libs not recommended') + mlog.warning('removing', mlog.bold(target.get_filename()), + 'from package because packaging static libs not recommended') elif isinstance(target, gnome.GirTarget) and target.should_install(): files_devel.add('%%{_datadir}/gir-1.0/%s' % target.get_filename()[0]) elif isinstance(target, gnome.TypelibTarget) and target.should_install(): @@ -94,14 +94,13 @@ class RPMModule: for compiler in compiler_deps: fn.write('BuildRequires: %s\n' % compiler) for dep in state.environment.coredata.deps: - fn.write('BuildRequires: pkgconfig(%s)\n' % dep) + fn.write('BuildRequires: pkgconfig(%s)\n' % dep[0]) for lib in state.environment.coredata.ext_libs.values(): fn.write('BuildRequires: %s # FIXME\n' % lib.fullpath) - mlog.log('Warning, replace', mlog.bold(lib.fullpath), - 'with real package.', - 'You can use following command to find package which ' - 'contains this lib:', - mlog.bold('dnf provides %s' % lib.fullpath)) + mlog.warning('replace', mlog.bold(lib.fullpath), 'with real package.', + 'You can use following command to find package which ' + 'contains this lib:', + mlog.bold('dnf provides %s' % lib.fullpath)) for prog in state.environment.coredata.ext_progs.values(): if not prog.found(): fn.write('BuildRequires: %{_bindir}/%s # FIXME\n' % diff --git a/mesonbuild/scripts/scanbuild.py b/mesonbuild/scripts/scanbuild.py index f13a1a4..dd74ce8 100644 --- a/mesonbuild/scripts/scanbuild.py +++ b/mesonbuild/scripts/scanbuild.py @@ -16,10 +16,10 @@ import subprocess import shutil import tempfile -def scanbuild(srcdir, blddir, privdir, logdir, args): +def scanbuild(exename, srcdir, blddir, privdir, logdir, args): with tempfile.TemporaryDirectory(dir=privdir) as scandir: - meson_cmd = ['scan-build'] + args - build_cmd = ['scan-build', '-o', logdir, 'ninja'] + meson_cmd = [exename] + args + build_cmd = [exename, '-o', logdir, 'ninja'] rc = subprocess.call(meson_cmd + [srcdir, scandir]) if rc != 0: return rc @@ -32,7 +32,8 @@ def run(args): privdir = os.path.join(blddir, 'meson-private') logdir = os.path.join(blddir, 'meson-logs/scanbuild') shutil.rmtree(logdir, ignore_errors=True) - if not shutil.which('scan-build'): - print('Scan-build not installed') + exename = os.environ.get('SCANBUILD', 'scan-build') + if not shutil.which(exename): + print('Scan-build not installed.') return 1 - return scanbuild(srcdir, blddir, privdir, logdir, meson_cmd) + return scanbuild(exename, srcdir, blddir, privdir, logdir, meson_cmd) diff --git a/mesonbuild/scripts/yelphelper.py b/mesonbuild/scripts/yelphelper.py index 00d713a..f33454d 100644 --- a/mesonbuild/scripts/yelphelper.py +++ b/mesonbuild/scripts/yelphelper.py @@ -75,7 +75,7 @@ def install_help(srcdir, blddir, sources, media, langs, install_dir, destdir, pr outfile = os.path.join(indir, m) if not os.path.exists(infile): if lang == 'C': - mlog.log(mlog.bold('Warning:'), 'Media file "%s" did not exist in C directory' %m) + mlog.warning('Media file "%s" did not exist in C directory' %m) elif symlinks: srcfile = os.path.join(c_install_dir, m) mlog.log('Symlinking %s to %s.' %(outfile, srcfile)) diff --git a/run_project_tests.py b/run_project_tests.py index 22e92b8..e373ffa 100755 --- a/run_project_tests.py +++ b/run_project_tests.py @@ -338,7 +338,7 @@ def detect_tests_to_run(): all_tests.append(('platform-windows', gather_tests('test cases/windows'), False if mesonlib.is_windows() else True)) all_tests.append(('platform-linux', gather_tests('test cases/linuxlike'), False if not (mesonlib.is_osx() or mesonlib.is_windows()) else True)) all_tests.append(('framework', gather_tests('test cases/frameworks'), False if not mesonlib.is_osx() and not mesonlib.is_windows() else True)) - all_tests.append(('java', gather_tests('test cases/java'), False if not mesonlib.is_osx() and shutil.which('javac') else True)) + all_tests.append(('java', gather_tests('test cases/java'), False if not mesonlib.is_osx() and shutil.which('javac') and shutil.which('java') else True)) all_tests.append(('C#', gather_tests('test cases/csharp'), False if shutil.which('mcs') else True)) all_tests.append(('vala', gather_tests('test cases/vala'), False if shutil.which('valac') else True)) all_tests.append(('rust', gather_tests('test cases/rust'), False if shutil.which('rustc') else True)) diff --git a/test cases/common/16 configure file/config.h b/test cases/common/16 configure file/config.h new file mode 100644 index 0000000..e85b634 --- /dev/null +++ b/test cases/common/16 configure file/config.h @@ -0,0 +1 @@ +#error "This file should not be included. Build dir must become before source dir in search order" diff --git a/test cases/common/16 configure file/prog.c b/test cases/common/16 configure file/prog.c index 718a402..89a718e 100644 --- a/test cases/common/16 configure file/prog.c +++ b/test cases/common/16 configure file/prog.c @@ -1,5 +1,8 @@ #include <string.h> -#include "config.h" +/* config.h must not be in quotes: + * https://gcc.gnu.org/onlinedocs/cpp/Search-Path.html + */ +#include <config.h> #ifdef SHOULD_BE_UNDEF #error "FAIL!" diff --git a/test cases/common/16 configure file/prog2.c b/test cases/common/16 configure file/prog2.c index be85033..a88c70f 100644 --- a/test cases/common/16 configure file/prog2.c +++ b/test cases/common/16 configure file/prog2.c @@ -1,4 +1,4 @@ -#include"config2.h" +#include<config2.h> int main(int argc, char **argv) { return ZERO_RESULT; |