diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2021-01-12 21:51:19 +0200 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2021-01-19 20:25:55 +0000 |
commit | 8133a7b9a4b8f0686fbc479aa2d64e41c85a979b (patch) | |
tree | 6d92574c0b8518e01e5447b3883a8fe3c5d00990 /mesonbuild | |
parent | c64d4070763b2daf82a50a7b4f5b130b2bb91062 (diff) | |
download | meson-8133a7b9a4b8f0686fbc479aa2d64e41c85a979b.zip meson-8133a7b9a4b8f0686fbc479aa2d64e41c85a979b.tar.gz meson-8133a7b9a4b8f0686fbc479aa2d64e41c85a979b.tar.bz2 |
Keep buildtype the same even if user changes debug and/or optimization.
Diffstat (limited to 'mesonbuild')
-rw-r--r-- | mesonbuild/coredata.py | 48 | ||||
-rw-r--r-- | mesonbuild/mconf.py | 11 |
2 files changed, 40 insertions, 19 deletions
diff --git a/mesonbuild/coredata.py b/mesonbuild/coredata.py index 39da863..211efec 100644 --- a/mesonbuild/coredata.py +++ b/mesonbuild/coredata.py @@ -582,8 +582,35 @@ class CoreData: if key.name == 'buildtype': self._set_others_from_buildtype(value) - elif key.name in {'debug', 'optimization'}: - self._set_buildtype_from_others() + + def get_nondefault_buildtype_args(self): + result= [] + value = self.options[OptionKey('buildtype')].value + if value == 'plain': + opt = '0' + debug = False + elif value == 'debug': + opt = '0' + debug = True + elif value == 'debugoptimized': + opt = '2' + debug = True + elif value == 'release': + opt = '3' + debug = False + elif value == 'minsize': + opt = 's' + debug = True + else: + assert(value == 'custom') + return [] + actual_opt = self.options[OptionKey('optimization')].value + actual_debug = self.options[OptionKey('debug')].value + if actual_opt != opt: + result.append(('optimization', actual_opt, opt)) + if actual_debug != debug: + result.append(('debug', actual_debug, debug)) + return result def _set_others_from_buildtype(self, value: str) -> None: if value == 'plain': @@ -607,23 +634,6 @@ class CoreData: self.options[OptionKey('optimization')].set_value(opt) self.options[OptionKey('debug')].set_value(debug) - def _set_buildtype_from_others(self) -> None: - opt = self.options[OptionKey('optimization')].value - debug = self.options[OptionKey('debug')].value - if opt == '0' and not debug: - mode = 'plain' - elif opt == '0' and debug: - mode = 'debug' - elif opt == '2' and debug: - mode = 'debugoptimized' - elif opt == '3' and not debug: - mode = 'release' - elif opt == 's' and debug: - mode = 'minsize' - else: - mode = 'custom' - self.options[OptionKey('buildtype')].set_value(mode) - @staticmethod def is_per_machine_option(optname: OptionKey) -> bool: if optname.name in BUILTIN_OPTIONS_PER_MACHINE: diff --git a/mesonbuild/mconf.py b/mesonbuild/mconf.py index 686a336..5233d88 100644 --- a/mesonbuild/mconf.py +++ b/mesonbuild/mconf.py @@ -243,6 +243,17 @@ class Conf: print('') print_default_values_warning() + self.print_nondefault_buildtype_options() + + def print_nondefault_buildtype_options(self): + mismatching = self.coredata.get_nondefault_buildtype_args() + if not mismatching: + return + print("\nThe following option(s) have a different value than the build type default\n") + print(f' current default') + for m in mismatching: + print(f'{m[0]:21}{m[1]:10}{m[2]:10}') + def run(options): coredata.parse_cmd_line_options(options) builddir = os.path.abspath(os.path.realpath(options.builddir)) |