summaryrefslogtreecommitdiff
path: root/mesonbuild/coredata.py
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2018-07-18 22:47:58 +0300
committerJussi Pakkanen <jpakkane@gmail.com>2018-07-18 22:52:22 +0300
commite3b0145e73b266a7fc3c1e5a494dbdd9cc1f0114 (patch)
tree49fdabd2e89638a1bdab95f3d5f1a426cc536fd6 /mesonbuild/coredata.py
parentefba19387292054b0c9c72d9e445992a4e3e473c (diff)
downloadmeson-builddirupgrade.tar.gz
Can upgrade build directory from an old version.builddirupgrade
Diffstat (limited to 'mesonbuild/coredata.py')
-rw-r--r--mesonbuild/coredata.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/mesonbuild/coredata.py b/mesonbuild/coredata.py
index b26516c98..0d6676ee2 100644
--- a/mesonbuild/coredata.py
+++ b/mesonbuild/coredata.py
@@ -410,9 +410,16 @@ class CoreData:
sub = 'In subproject {}: '.format(subproject) if subproject else ''
mlog.warning('{}Unknown options: "{}"'.format(sub, unknown_options))
+ def get_all_option_classes(self):
+ return (self.backend_options,
+ self.user_options,
+ self.compiler_options,
+ self.base_options)
+
def load(build_dir):
filename = os.path.join(build_dir, 'meson-private', 'coredata.dat')
load_fail_msg = 'Coredata file {!r} is corrupted. Try with a fresh build tree.'.format(filename)
+ state_file_exists = os.path.isfile(os.path.join(build_dir, 'meson-private', 'upgrade_state.json'))
try:
with open(filename, 'rb') as f:
obj = pickle.load(f)
@@ -421,8 +428,12 @@ def load(build_dir):
if not isinstance(obj, CoreData):
raise MesonException(load_fail_msg)
if obj.version != version:
- raise MesonException('Build directory has been generated with Meson version %s, which is incompatible with current version %s.\nPlease delete this build directory AND create a new one.' %
- (obj.version, version))
+ msg = 'Build directory has been generated with Meson version %s, which is incompatible with current version %s.\n'
+ if state_file_exists:
+ msg += 'Upgrade the build directory by invoking the "upgrade-builddir" target.'
+ else:
+ msg += 'Please delete this build directory AND create a new one.'
+ raise MesonException(msg % (obj.version, version))
return obj
def save(obj, build_dir):