diff options
24 files changed, 105 insertions, 110 deletions
diff --git a/docs/markdown/Getting-meson.md b/docs/markdown/Getting-meson.md index e0e5722..3568dfc 100644 --- a/docs/markdown/Getting-meson.md +++ b/docs/markdown/Getting-meson.md @@ -23,12 +23,17 @@ a pull-request process that runs CI and tests several platforms. ## Installing Meson with pip Meson is available in the [Python Package Index] and can be installed with -`pip3 install meson` which requires root and will install it system-wide. +`sudo pip3 install meson` which requires root and will install it system-wide. + +If you have downloaded a copy of the meson sources already, you can install it +with `sudo pip3 install path/to/source/root/`. Alternatively, you can use `pip3 install --user meson` which will install it for your user and does not require any special privileges. This will install the package in `~/.local/`, so you will have to add `~/.local/bin` to your -`PATH`. +`PATH`, and `sudo meson install` will be completely broken since the +program will not be available to root. Only use a user copy of meson if you +do not care about installing projects as root. ## Installing Meson and Ninja with the MSI installer diff --git a/docs/markdown/Tutorial.md b/docs/markdown/Tutorial.md index bf337ba..85e345a 100644 --- a/docs/markdown/Tutorial.md +++ b/docs/markdown/Tutorial.md @@ -29,8 +29,11 @@ example. First we create a file `main.c` which holds the source. It looks like this. ```c -#include<stdio.h> +#include <stdio.h> +// +// main is where all program execution starts +// int main(int argc, char **argv) { printf("Hello there.\n"); return 0; @@ -53,7 +56,7 @@ to initialize the build by going into the source directory and issuing the following commands. ```console -$ meson builddir +$ meson setup builddir ``` We create a separate build directory to hold all of the compiler @@ -110,17 +113,40 @@ create a graphical window instead. We'll use the use GTK+. The new version looks like this. ```c -#include<gtk/gtk.h> -int main(int argc, char **argv) { - GtkWidget *win; - gtk_init(&argc, &argv); - win = gtk_window_new(GTK_WINDOW_TOPLEVEL); - gtk_window_set_title(GTK_WINDOW(win), "Hello there"); - g_signal_connect(win, "destroy", G_CALLBACK(gtk_main_quit), NULL); - gtk_widget_show(win); - gtk_main(); -} +#include <gtk/gtk.h> + +// +// Should provided the active view for a GTK application +// +static void activate(GtkApplication* app, gpointer user_data) +{ + GtkWidget *window; + GtkWidget *label; + + window = gtk_application_window_new (app); + label = gtk_label_new("Hello GNOME!"); + gtk_container_add (GTK_CONTAINER (window), label); + gtk_window_set_title(GTK_WINDOW (window), "Welcome to GNOME"); + gtk_window_set_default_size(GTK_WINDOW (window), 200, 100); + gtk_widget_show_all(window); +} // end of function activate + +// +// main is where all program execution starts +// +int main(int argc, char **argv) +{ + GtkApplication *app; + int status; + + app = gtk_application_new(NULL, G_APPLICATION_FLAGS_NONE); + g_signal_connect(app, "activate", G_CALLBACK(activate), NULL); + status = g_application_run(G_APPLICATION(app), argc, argv); + g_object_unref(app); + + return status; +} // end of function main ``` Then we edit the Meson file, instructing it to find and use the GTK+ diff --git a/docs/markdown/snippets/thinlto.md b/docs/markdown/snippets/thinlto.md deleted file mode 100644 index 44bc972..0000000 --- a/docs/markdown/snippets/thinlto.md +++ /dev/null @@ -1,27 +0,0 @@ -## Add support for thin LTO - -The `b_lto` option has been updated and now can be set to the value -`thin`. This enables [thin -LTO](https://clang.llvm.org/docs/ThinLTO.html) on all compilers where -it is supported. At the time of writing this means only Clang. - -This change is potentially backwards incompatible. If you have -examined the value of `b_lto` in your build file, note that its type -has changed from a boolean to a string. Thus comparisons like this: - -```meson -if get_option('b_lto') -... -endif -``` - -need to be changed to something like this instead: - -```meson -if get_option('b_lto') == 'true' -... -endif -``` - -This should not affect any command line invocations as configuring LTO -with `-Db_lto=true` still works and behaves the same way as before. diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index c3c5705..15218c1 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -359,9 +359,9 @@ class NinjaBuildElement: rulename = self.rulename line = 'build {}{}: {} {}'.format(outs, implicit_outs, rulename, ins) if len(self.deps) > 0: - line += ' | ' + ' '.join([ninja_quote(x, True) for x in self.deps]) + line += ' | ' + ' '.join([ninja_quote(x, True) for x in sorted(self.deps)]) if len(self.orderdeps) > 0: - line += ' || ' + ' '.join([ninja_quote(x, True) for x in self.orderdeps]) + line += ' || ' + ' '.join([ninja_quote(x, True) for x in sorted(self.orderdeps)]) line += '\n' # This is the only way I could find to make this work on all # platforms including Windows command shell. Slash is a dir separator diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py index 81d48d2..4e9b86b 100644 --- a/mesonbuild/compilers/compilers.py +++ b/mesonbuild/compilers/compilers.py @@ -266,9 +266,7 @@ clike_debug_args = {False: [], True: ['-g']} # type: T.Dict[bool, T.List[str]] base_options = {'b_pch': coredata.UserBooleanOption('Use precompiled headers', True), - 'b_lto': coredata.UserComboOption('Use link time optimization', - ['false', 'true', 'thin'], - 'false'), + 'b_lto': coredata.UserBooleanOption('Use link time optimization', False), 'b_sanitize': coredata.UserComboOption('Code sanitizer to use', ['none', 'address', 'thread', 'undefined', 'memory', 'address,undefined'], 'none'), @@ -309,7 +307,8 @@ def option_enabled(boptions: T.List[str], options: 'OptionDictType', def get_base_compile_args(options: 'OptionDictType', compiler: 'Compiler') -> T.List[str]: args = [] # type T.List[str] try: - args.extend(compiler.get_lto_compile_args(options['b_lto'].value)) + if options['b_lto'].value: + args.extend(compiler.get_lto_compile_args()) except KeyError: pass try: @@ -358,7 +357,8 @@ def get_base_link_args(options: 'OptionDictType', linker: 'Compiler', is_shared_module: bool) -> T.List[str]: args = [] # type: T.List[str] try: - args.extend(linker.get_lto_link_args(options['b_lto'].value)) + if options['b_lto'].value: + args.extend(linker.get_lto_link_args()) except KeyError: pass try: @@ -940,11 +940,11 @@ class Compiler(metaclass=abc.ABCMeta): ret.append(arg) return ret - def get_lto_compile_args(self, lto_type: str) -> T.List[str]: + def get_lto_compile_args(self) -> T.List[str]: return [] - def get_lto_link_args(self, lto_type: str) -> T.List[str]: - return self.linker.get_lto_args(lto_type) + def get_lto_link_args(self) -> T.List[str]: + return self.linker.get_lto_args() def sanitizer_compile_args(self, value: str) -> T.List[str]: return [] diff --git a/mesonbuild/compilers/mixins/clang.py b/mesonbuild/compilers/mixins/clang.py index 773d9dc..acdb352 100644 --- a/mesonbuild/compilers/mixins/clang.py +++ b/mesonbuild/compilers/mixins/clang.py @@ -77,13 +77,6 @@ class ClangCompiler(GnuLikeCompiler): # so it might change semantics at any time. return ['-include-pch', os.path.join(pch_dir, self.get_pch_name(header))] - def get_lto_compile_args(self, lto_type: str) -> T.List[str]: - if lto_type == 'thin': - return ['-flto=thin'] - if lto_type == 'true': - return ['-flto'] - return [] - def get_compiler_check_args(self, mode: CompileCheckMode) -> T.List[str]: myargs = [] # type: T.List[str] if mode is CompileCheckMode.COMPILE: diff --git a/mesonbuild/compilers/mixins/gnu.py b/mesonbuild/compilers/mixins/gnu.py index 5771ad8..bb1fc66 100644 --- a/mesonbuild/compilers/mixins/gnu.py +++ b/mesonbuild/compilers/mixins/gnu.py @@ -295,10 +295,8 @@ class GnuLikeCompiler(Compiler, metaclass=abc.ABCMeta): return self._split_fetch_real_dirs(line.split('=', 1)[1]) return [] - def get_lto_compile_args(self, lto_type: str) -> T.List[str]: - if lto_type != 'false': - return ['-flto'] - return [] + def get_lto_compile_args(self) -> T.List[str]: + return ['-flto'] def sanitizer_compile_args(self, value: str) -> T.List[str]: if value == 'none': diff --git a/mesonbuild/compilers/mixins/islinker.py b/mesonbuild/compilers/mixins/islinker.py index 67ac497..2445eec 100644 --- a/mesonbuild/compilers/mixins/islinker.py +++ b/mesonbuild/compilers/mixins/islinker.py @@ -48,7 +48,7 @@ class BasicLinkerIsCompilerMixin(Compiler): def sanitizer_link_args(self, value: str) -> T.List[str]: return [] - def get_lto_link_args(self, lto_type: str) -> T.List[str]: + def get_lto_link_args(self) -> T.List[str]: return [] def can_linker_accept_rsp(self) -> bool: diff --git a/mesonbuild/depfile.py b/mesonbuild/depfile.py index 7a896cd..62cbe81 100644 --- a/mesonbuild/depfile.py +++ b/mesonbuild/depfile.py @@ -82,4 +82,4 @@ class DepFile: deps.update(target.deps) for dep in target.deps: deps.update(self.get_all_dependencies(dep, visited)) - return deps + return sorted(deps) diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index 138f6f8..6896a4d 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -4656,6 +4656,9 @@ different subdirectory. elif arg in optargs: mlog.warning('Consider using the built-in optimization level instead of using "{}".'.format(arg), location=self.current_node) + elif arg == '-Werror': + mlog.warning('Consider using the built-in werror option instead of using "{}".'.format(arg), + location=self.current_node) elif arg == '-g': mlog.warning('Consider using the built-in debug option instead of using "{}".'.format(arg), location=self.current_node) diff --git a/mesonbuild/interpreterbase.py b/mesonbuild/interpreterbase.py index d3f8181..e57580b 100644 --- a/mesonbuild/interpreterbase.py +++ b/mesonbuild/interpreterbase.py @@ -823,7 +823,7 @@ The result of this is undefined and will become a hard error in a future Meson r elif isinstance(items, dict): if len(node.varnames) != 2: raise InvalidArguments('Foreach on dict unpacks key and value') - for key, value in items.items(): + for key, value in sorted(items.items()): self.set_variable(node.varnames[0], key) self.set_variable(node.varnames[1], value) try: @@ -1166,7 +1166,7 @@ The result of this is undefined and will become a hard error in a future Meson r if method_name == 'keys': if len(posargs) != 0: raise InterpreterException('keys() takes no arguments.') - return list(obj.keys()) + return sorted(obj.keys()) raise InterpreterException('Dictionaries do not have a method called "%s".' % method_name) diff --git a/mesonbuild/linkers.py b/mesonbuild/linkers.py index cc3db5f..589945c 100644 --- a/mesonbuild/linkers.py +++ b/mesonbuild/linkers.py @@ -411,7 +411,7 @@ class DynamicLinker(LinkerEnvVarsMixin, metaclass=abc.ABCMeta): m = 'Linker {} does not support position-independent executable' raise mesonlib.EnvironmentException(m.format(self.id)) - def get_lto_args(self, lto_type: str) -> T.List[str]: + def get_lto_args(self) -> T.List[str]: return [] def sanitizer_args(self, value: str) -> T.List[str]: @@ -550,10 +550,8 @@ class GnuLikeDynamicLinkerMixin: def get_allow_undefined_args(self) -> T.List[str]: return self._apply_prefix('--allow-shlib-undefined') - def get_lto_args(self, lto_type: str) -> T.List[str]: - if lto_type != 'false': - return ['-flto'] - return [] + def get_lto_args(self) -> T.List[str]: + return ['-flto'] def sanitizer_args(self, value: str) -> T.List[str]: if value == 'none': diff --git a/mesonbuild/mlog.py b/mesonbuild/mlog.py index eefb308..46e2de1 100644 --- a/mesonbuild/mlog.py +++ b/mesonbuild/mlog.py @@ -124,7 +124,7 @@ class AnsiDecorator: def get_text(self, with_codes: bool) -> str: text = self.text - if with_codes: + if with_codes and self.code: text = self.code + self.text + AnsiDecorator.plain_code if self.quoted: text = '"{}"'.format(text) @@ -133,6 +133,9 @@ class AnsiDecorator: def bold(text: str, quoted: bool = False) -> AnsiDecorator: return AnsiDecorator(text, "\033[1m", quoted=quoted) +def plain(text: str) -> AnsiDecorator: + return AnsiDecorator(text, "") + def red(text: str) -> AnsiDecorator: return AnsiDecorator(text, "\033[1;31m") diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py index 9fd31c7..547aff1 100644 --- a/mesonbuild/modules/gnome.py +++ b/mesonbuild/modules/gnome.py @@ -1430,7 +1430,7 @@ class GnomeModule(ExtensionModule): GType %s@enum_name@_get_type (void) { - static volatile gsize gtype_id = 0; + static gsize gtype_id = 0; static const G@Type@Value values[] = {''' % func_prefix c_file_kwargs['vprod'] = ' { C_@TYPE@(@VALUENAME@), "@VALUENAME@", "@valuenick@" },' diff --git a/mesonbuild/modules/sourceset.py b/mesonbuild/modules/sourceset.py index e23e12e..e49a548 100644 --- a/mesonbuild/modules/sourceset.py +++ b/mesonbuild/modules/sourceset.py @@ -14,7 +14,7 @@ from collections import namedtuple from .. import mesonlib -from ..mesonlib import listify +from ..mesonlib import listify, OrderedSet from . import ExtensionModule from ..interpreterbase import ( noPosargs, noKwargs, permittedKwargs, @@ -111,7 +111,7 @@ class SourceSetHolder(MutableInterpreterObject, ObjectHolder): def collect(self, enabled_fn, all_sources, into=None): if not into: - into = SourceFiles(set(), set()) + into = SourceFiles(OrderedSet(), OrderedSet()) for entry in self.held_object: if all(x.found() for x in entry.dependencies) and \ all(enabled_fn(key) for key in entry.keys): diff --git a/mesonbuild/mtest.py b/mesonbuild/mtest.py index 92d02b3..5804303 100644 --- a/mesonbuild/mtest.py +++ b/mesonbuild/mtest.py @@ -957,20 +957,15 @@ class TestHarness: dur=result.duration) if result.res is TestResult.FAIL: result_str += ' ' + returncode_to_status(result.returncode) + if result.res in bad_statuses: + self.collected_failures.append(result_str) if not self.options.quiet or result.res not in ok_statuses: - if result.res not in ok_statuses: - self.collected_failures.append(result_str) - if mlog.colorize_console(): - if result.res in bad_statuses: - self.collected_failures.append(result_str) - decorator = mlog.red - elif result.res is TestResult.SKIP: - decorator = mlog.yellow - else: - sys.exit('Unreachable code was ... well ... reached.') - print(decorator(result_str).get_text(True)) - else: - print(result_str) + decorator = mlog.plain + if result.res in bad_statuses: + decorator = mlog.red + elif result.res is TestResult.SKIP: + decorator = mlog.yellow + print(decorator(result_str).get_text(mlog.colorize_console())) result_str += "\n\n" + result.get_log() if result.res in bad_statuses: if self.options.print_errorlogs: diff --git a/mesonbuild/scripts/clangformat.py b/mesonbuild/scripts/clangformat.py index e7a3ff8..062cb43 100644 --- a/mesonbuild/scripts/clangformat.py +++ b/mesonbuild/scripts/clangformat.py @@ -25,6 +25,7 @@ def clangformat(exelist: T.List[str], srcdir_name: str, builddir_name: str) -> i 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(): @@ -32,9 +33,9 @@ def clangformat(exelist: T.List[str], srcdir_name: str, builddir_name: str) -> i strf = str(f) if strf.startswith(builddir_name): continue - futures.append(e.submit(subprocess.check_call, exelist + ['-style=file', '-i', strf])) - [x.result() for x in futures] - return 0 + futures.append(e.submit(subprocess.run, exelist + ['-style=file', '-i', strf])) + returncode = max([x.result().returncode for x in futures]) + return returncode def run(args: T.List[str]) -> int: srcdir_name = args[0] diff --git a/mesonbuild/scripts/clangtidy.py b/mesonbuild/scripts/clangtidy.py index f920126..8d366c8 100644 --- a/mesonbuild/scripts/clangtidy.py +++ b/mesonbuild/scripts/clangtidy.py @@ -36,7 +36,7 @@ def manual_clangtidy(srcdir_name: str, builddir_name: str) -> int: if strf.startswith(builddir_name): continue futures.append(e.submit(subprocess.run, ['clang-tidy', '-p', builddir_name, strf])) - [max(returncode, x.result().returncode) for x in futures] + returncode = max([x.result().returncode for x in futures]) return returncode def clangtidy(srcdir_name: str, builddir_name: str) -> int: diff --git a/run_unittests.py b/run_unittests.py index 7f7df36..9815058 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -1187,7 +1187,7 @@ class InternalTests(unittest.TestCase): ]: d = mesonbuild.depfile.DepFile(f) deps = d.get_all_dependencies(target) - self.assertEqual(deps, expdeps) + self.assertEqual(sorted(deps), sorted(expdeps)) def test_log_once(self): f = io.StringIO() diff --git a/test cases/common/41 options/meson.build b/test cases/common/41 options/meson.build index 4b38c6f..2eccef7 100644 --- a/test cases/common/41 options/meson.build +++ b/test cases/common/41 options/meson.build @@ -18,7 +18,7 @@ if get_option('array_opt') != ['one', 'two'] endif # If the default changes, update test cases/unit/13 reconfigure -if get_option('b_lto') != 'false' +if get_option('b_lto') != false error('Incorrect value in base option.') endif diff --git a/test cases/frameworks/7 gnome/mkenums/enums.c.in b/test cases/frameworks/7 gnome/mkenums/enums.c.in index 62e1adc..1c19d8f 100644 --- a/test cases/frameworks/7 gnome/mkenums/enums.c.in +++ b/test cases/frameworks/7 gnome/mkenums/enums.c.in @@ -13,9 +13,9 @@ /*** BEGIN value-header ***/ GType @enum_name@_get_type(void) { - static volatile gsize g_define_type_id__volatile = 0; + static gsize static_g_define_type_id = 0; - if(g_once_init_enter(&g_define_type_id__volatile)) { + if(g_once_init_enter(&static_g_define_type_id)) { static const G@Type@Value values [] = { /*** END value-header ***/ @@ -29,10 +29,10 @@ GType GType g_define_type_id = g_@type@_register_static(g_intern_static_string("@EnumName@"), values); - g_once_init_leave(&g_define_type_id__volatile, g_define_type_id); + g_once_init_leave(&static_g_define_type_id, g_define_type_id); } - return g_define_type_id__volatile; + return static_g_define_type_id; } /*** END value-tail ***/ diff --git a/test cases/frameworks/7 gnome/mkenums/enums2.c.in b/test cases/frameworks/7 gnome/mkenums/enums2.c.in index 62e1adc..1c19d8f 100644 --- a/test cases/frameworks/7 gnome/mkenums/enums2.c.in +++ b/test cases/frameworks/7 gnome/mkenums/enums2.c.in @@ -13,9 +13,9 @@ /*** BEGIN value-header ***/ GType @enum_name@_get_type(void) { - static volatile gsize g_define_type_id__volatile = 0; + static gsize static_g_define_type_id = 0; - if(g_once_init_enter(&g_define_type_id__volatile)) { + if(g_once_init_enter(&static_g_define_type_id)) { static const G@Type@Value values [] = { /*** END value-header ***/ @@ -29,10 +29,10 @@ GType GType g_define_type_id = g_@type@_register_static(g_intern_static_string("@EnumName@"), values); - g_once_init_leave(&g_define_type_id__volatile, g_define_type_id); + g_once_init_leave(&static_g_define_type_id, g_define_type_id); } - return g_define_type_id__volatile; + return static_g_define_type_id; } /*** END value-tail ***/ diff --git a/test cases/frameworks/7 gnome/mkenums/meson.build b/test cases/frameworks/7 gnome/mkenums/meson.build index 3d7adf0..8ff05ba 100644 --- a/test cases/frameworks/7 gnome/mkenums/meson.build +++ b/test cases/frameworks/7 gnome/mkenums/meson.build @@ -89,9 +89,9 @@ enums_c3 = gnome.mkenums('enums3.c', vhead : ''' GType @enum_name@_get_type(void) { - static volatile gsize g_define_type_id__volatile = 0; + static gsize static_g_define_type_id = 0; - if(g_once_init_enter(&g_define_type_id__volatile)) { + if(g_once_init_enter(&static_g_define_type_id)) { static const G@Type@Value values [] = { ''', vprod : ''' { @VALUENAME@, "@VALUENAME@", "@valuenick@" },''', @@ -100,10 +100,10 @@ GType GType g_define_type_id = g_@type@_register_static(g_intern_static_string("@EnumName@"), values); - g_once_init_leave(&g_define_type_id__volatile, g_define_type_id); + g_once_init_leave(&static_g_define_type_id, g_define_type_id); } - return g_define_type_id__volatile; + return static_g_define_type_id; } ''') diff --git a/test cases/vala/8 generated sources/dependency-generated/enum-types.c.template b/test cases/vala/8 generated sources/dependency-generated/enum-types.c.template index 5ecdd2d..85d74d1 100644 --- a/test cases/vala/8 generated sources/dependency-generated/enum-types.c.template +++ b/test cases/vala/8 generated sources/dependency-generated/enum-types.c.template @@ -14,9 +14,9 @@ GType @enum_name@_get_type (void) { - static volatile gsize g_define_type_id__volatile = 0; + static gsize static_g_define_type_id = 0; - if (g_once_init_enter (&g_define_type_id__volatile)) { + if (g_once_init_enter (&static_g_define_type_id)) { static const G@Type@Value values[] = { /*** END value-header ***/ @@ -30,10 +30,10 @@ GType GType g_define_type_id = g_@type@_register_static (g_intern_static_string ("@EnumName@"), values); - g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); + g_once_init_leave (&static_g_define_type_id, g_define_type_id); } - return g_define_type_id__volatile; + return static_g_define_type_id; } /*** END value-tail ***/ |