diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2020-08-03 11:14:52 +0200 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2020-08-04 17:15:37 +0300 |
commit | 6006987ce5081534a129ee2d9d55d993c7a76b29 (patch) | |
tree | 2fd7fc8455336f6c6a8286dd2e0fcb073426e0d1 /mesonbuild | |
parent | 2d218c289a6e95790c21106fe00655aa9f947f55 (diff) | |
download | meson-6006987ce5081534a129ee2d9d55d993c7a76b29.zip meson-6006987ce5081534a129ee2d9d55d993c7a76b29.tar.gz meson-6006987ce5081534a129ee2d9d55d993c7a76b29.tar.bz2 |
"Downgrade" warning when regenerating after version bump
There is nothing to "warn" about, this is a completely routine
occurence. OTOH, when something is corrupted, we should warn. Keep
the red color and "WARNING:" prefix in that case.
Example output:
$ ninja -C build
Regenerating configuration from scratch: Build directory has been generated with Meson version 0.55.999, which is incompatible with current version 0.56.0.
The Meson build system
Version: 0.56.0
...
Diffstat (limited to 'mesonbuild')
-rw-r--r-- | mesonbuild/coredata.py | 14 | ||||
-rw-r--r-- | mesonbuild/environment.py | 5 |
2 files changed, 16 insertions, 3 deletions
diff --git a/mesonbuild/coredata.py b/mesonbuild/coredata.py index cf418bb..ce03fbc 100644 --- a/mesonbuild/coredata.py +++ b/mesonbuild/coredata.py @@ -45,6 +45,16 @@ default_yielding = False # Can't bind this near the class method it seems, sadly. _T = T.TypeVar('_T') +class MesonVersionMismatchException(MesonException): + '''Build directory generated with Meson version incompatible with current version''' + def __init__(self, old_version, current_version): + super().__init__('Build directory has been generated with Meson version {}, ' + 'which is incompatible with current version {}.' + .format(old_version, current_version)) + self.old_version = old_version + self.current_version = current_version + + class UserOption(T.Generic[_T]): def __init__(self, description, choices, yielding): super().__init__() @@ -982,9 +992,7 @@ def load(build_dir): if not isinstance(obj, CoreData): raise MesonException(load_fail_msg) if major_versions_differ(obj.version, version): - raise MesonException('Build directory has been generated with Meson version %s, ' - 'which is incompatible with current version %s.\n' % - (obj.version, version)) + raise MesonVersionMismatchException(obj.version, version) return obj def save(obj, build_dir): diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py index 01fc8e4..6987863 100644 --- a/mesonbuild/environment.py +++ b/mesonbuild/environment.py @@ -523,6 +523,11 @@ class Environment: self.first_invocation = False except FileNotFoundError: self.create_new_coredata(options) + except coredata.MesonVersionMismatchException as e: + # This is routine, but tell the user the update happened + mlog.log('Regenerating configuration from scratch:', str(e)) + coredata.read_cmd_line_file(self.build_dir, options) + self.create_new_coredata(options) except MesonException as e: # If we stored previous command line options, we can recover from # a broken/outdated coredata. |