diff options
author | Xavier Claessens <xavier.claessens@collabora.com> | 2018-10-25 12:19:23 -0400 |
---|---|---|
committer | Xavier Claessens <xavier.claessens@collabora.com> | 2018-11-06 16:37:13 -0500 |
commit | 43101489cd7b310996badaef19638ec3adbec532 (patch) | |
tree | 80571c19bb3ff6c3b7cd42995555b875795cfe65 /mesonbuild/environment.py | |
parent | 11e3011a6bf0adeb51582c590c90b0f4dccb4df8 (diff) | |
download | meson-43101489cd7b310996badaef19638ec3adbec532.zip meson-43101489cd7b310996badaef19638ec3adbec532.tar.gz meson-43101489cd7b310996badaef19638ec3adbec532.tar.bz2 |
Recover when coredata cannot be loaded
Write command line options into a separate file to be able to
reconfigure from scatch in the case coredata cannot be loaded. The most
common case is when we are reconfiguring with a newer meson version.
This means that we should try as much as possible to maintain backward
compatibility for the cmd_line.txt file format.
The main difference with a normal reconfigure is it will use new
default options values and will read again environment variables like
CFLAGS, etc.
Diffstat (limited to 'mesonbuild/environment.py')
-rw-r--r-- | mesonbuild/environment.py | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py index a002aa1..8891b5c 100644 --- a/mesonbuild/environment.py +++ b/mesonbuild/environment.py @@ -17,7 +17,7 @@ import configparser, os, platform, re, sys, shlex, shutil, subprocess from . import coredata from .linkers import ArLinker, ArmarLinker, VisualStudioLinker, DLinker from . import mesonlib -from .mesonlib import EnvironmentException, PerMachine, Popen_safe +from .mesonlib import MesonException, EnvironmentException, PerMachine, Popen_safe from . import mlog from . import compilers @@ -317,13 +317,17 @@ class Environment: self.coredata = coredata.load(self.get_build_dir()) self.first_invocation = False except FileNotFoundError: - # WARNING: Don't use any values from coredata in __init__. It gets - # re-initialized with project options by the interpreter during - # build file parsing. - self.coredata = coredata.CoreData(options) - # Used by the regenchecker script, which runs meson - self.coredata.meson_command = mesonlib.meson_command - self.first_invocation = True + self.create_new_coredata(options) + except MesonException as e: + # If we stored previous command line options, we can recover from + # a broken/outdated coredata. + if os.path.isfile(coredata.get_cmd_line_file(self.build_dir)): + mlog.warning('Regenerating configuration from scratch.') + mlog.log('Reason:', mlog.red(str(e))) + coredata.read_cmd_line_file(self.build_dir, options) + self.create_new_coredata(options) + else: + raise e self.exe_wrapper = None self.machines = MachineInfos() @@ -389,6 +393,15 @@ class Environment: else: self.native_strip_bin = ['strip'] + def create_new_coredata(self, options): + # WARNING: Don't use any values from coredata in __init__. It gets + # re-initialized with project options by the interpreter during + # build file parsing. + self.coredata = coredata.CoreData(options) + # Used by the regenchecker script, which runs meson + self.coredata.meson_command = mesonlib.meson_command + self.first_invocation = True + def is_cross_build(self): return self.cross_info is not None |