diff options
author | Xavier Claessens <xavier.claessens@collabora.com> | 2023-01-19 10:38:38 -0500 |
---|---|---|
committer | Xavier Claessens <xclaesse@gmail.com> | 2023-03-16 21:02:23 -0400 |
commit | 72cd2a395a240f050b6225b9aed876ee214ecd8c (patch) | |
tree | b95e7dd296d355638ab85926b8e4c75a5dfe333c | |
parent | adb619db6110d14e8f56366dbc2ce271abc4558c (diff) | |
download | meson-72cd2a395a240f050b6225b9aed876ee214ecd8c.zip meson-72cd2a395a240f050b6225b9aed876ee214ecd8c.tar.gz meson-72cd2a395a240f050b6225b9aed876ee214ecd8c.tar.bz2 |
coredata: Do not pickle it twice
Exclude coredata from build.dat because it gets pickled separately
already.
-rw-r--r-- | mesonbuild/build.py | 17 | ||||
-rw-r--r-- | mesonbuild/mcompile.py | 3 | ||||
-rw-r--r-- | mesonbuild/mconf.py | 2 |
3 files changed, 16 insertions, 6 deletions
diff --git a/mesonbuild/build.py b/mesonbuild/build.py index 7d1f1d0..82992cd 100644 --- a/mesonbuild/build.py +++ b/mesonbuild/build.py @@ -26,6 +26,7 @@ import re import textwrap import typing as T +from . import coredata from . import environment from . import dependencies from . import mlog @@ -235,6 +236,7 @@ class Build: """ def __init__(self, environment: environment.Environment): + self.version = coredata.version self.project_name = 'name of master project' self.project_version = None self.environment = environment @@ -2980,11 +2982,20 @@ def get_sources_string_names(sources, backend): def load(build_dir: str) -> Build: filename = os.path.join(build_dir, 'meson-private', 'build.dat') try: - return pickle_load(filename, 'Build data', Build) + b = pickle_load(filename, 'Build data', Build) + # We excluded coredata when saving Build object, load it separately + b.environment.coredata = coredata.load(build_dir) + return b except FileNotFoundError: raise MesonException(f'No such build data file as {filename!r}.') def save(obj: Build, filename: str) -> None: - with open(filename, 'wb') as f: - pickle.dump(obj, f) + # Exclude coredata because we pickle it separately already + cdata = obj.environment.coredata + obj.environment.coredata = None + try: + with open(filename, 'wb') as f: + pickle.dump(obj, f) + finally: + obj.environment.coredata = cdata diff --git a/mesonbuild/mcompile.py b/mesonbuild/mcompile.py index e14f9e9..ce002bd 100644 --- a/mesonbuild/mcompile.py +++ b/mesonbuild/mcompile.py @@ -26,7 +26,6 @@ from pathlib import Path from . import mlog from . import mesonlib -from . import coredata from .mesonlib import MesonException, RealPathAction, join_args, setup_vsenv from mesonbuild.environment import detect_ninja from mesonbuild.coredata import UserArrayOption @@ -331,8 +330,8 @@ def run(options: 'argparse.Namespace') -> int: if options.targets and options.clean: raise MesonException('`TARGET` and `--clean` can\'t be used simultaneously') - cdata = coredata.load(options.wd) b = build.load(options.wd) + cdata = b.environment.coredata vsenv_active = setup_vsenv(b.need_vsenv) if vsenv_active: mlog.log(mlog.green('INFO:'), 'automatically activated MSVC compiler environment') diff --git a/mesonbuild/mconf.py b/mesonbuild/mconf.py index 35e862f..7182941 100644 --- a/mesonbuild/mconf.py +++ b/mesonbuild/mconf.py @@ -72,7 +72,7 @@ class Conf: if os.path.isdir(os.path.join(self.build_dir, 'meson-private')): self.build = build.load(self.build_dir) self.source_dir = self.build.environment.get_source_dir() - self.coredata = coredata.load(self.build_dir) + self.coredata = self.build.environment.coredata self.default_values_only = False elif os.path.isfile(os.path.join(self.build_dir, environment.build_filename)): # Make sure that log entries in other parts of meson don't interfere with the JSON output |