coredata: Do not pickle it twice
Exclude coredata from build.dat because it gets pickled separately already.
This commit is contained in:
parent
adb619db61
commit
72cd2a395a
|
@ -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
|
||||
|
|
|
@ -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')
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue