minstall: Add version field to install data

And check the install data in the same way that mtest checks
serialisation data.

Fixes https://github.com/mesonbuild/meson/issues/2354
pull/7564/head
Nirbheek Chauhan 4 years ago committed by Nirbheek Chauhan
parent 8bb3f16f09
commit 9fb839687b
  1. 6
      mesonbuild/backend/backends.py
  2. 6
      mesonbuild/backend/ninjabackend.py
  3. 14
      mesonbuild/minstall.py

@ -74,7 +74,7 @@ class CleanTrees:
class InstallData:
def __init__(self, source_dir, build_dir, prefix, strip_bin,
install_umask, mesonintrospect):
install_umask, mesonintrospect, version):
self.source_dir = source_dir
self.build_dir = build_dir
self.prefix = prefix
@ -89,6 +89,7 @@ class InstallData:
self.install_scripts = []
self.install_subdirs = []
self.mesonintrospect = mesonintrospect
self.version = version
class TargetInstallData:
def __init__(self, fname, outdir, aliases, strip, install_name_mappings, rpath_dirs_to_remove, install_rpath, install_mode, optional=False):
@ -1158,7 +1159,8 @@ class Backend:
self.environment.get_prefix(),
strip_bin,
self.environment.coredata.get_builtin_option('install_umask'),
self.environment.get_build_command() + ['introspect'])
self.environment.get_build_command() + ['introspect'],
self.environment.coredata.version)
self.generate_depmf_install(d)
self.generate_target_install(d)
self.generate_header_install(d)

@ -3009,12 +3009,6 @@ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47485'''))
result += [i]
return result
def load(build_dir):
filename = os.path.join(build_dir, 'meson-private', 'install.dat')
with open(filename, 'rb') as f:
obj = pickle.load(f)
return obj
def _scan_fortran_file_deps(src: Path, srcdir: Path, dirname: Path, tdeps, compiler) -> T.List[str]:
"""

@ -20,6 +20,9 @@ from .scripts import depfixer
from .scripts import destdir_join
from .mesonlib import is_windows, Popen_safe
from .mtest import rebuild_all
from .backend.backends import InstallData
from .coredata import major_versions_differ, MesonVersionMismatchException
from .coredata import version as coredata_version
try:
from __main__ import __file__ as main_file
except ImportError:
@ -343,9 +346,18 @@ class Installer:
self.do_copyfile(abs_src, abs_dst)
set_mode(abs_dst, install_mode, data.install_umask)
@staticmethod
def check_installdata(obj: InstallData) -> InstallData:
if not isinstance(obj, InstallData) or not hasattr(obj, 'version'):
raise MesonVersionMismatchException('<unknown>', coredata_version)
if major_versions_differ(obj.version, coredata_version):
raise MesonVersionMismatchException(obj.version, coredata_version)
return obj
def do_install(self, datafilename):
with open(datafilename, 'rb') as ifile:
d = pickle.load(ifile)
d = self.check_installdata(pickle.load(ifile))
d.destdir = os.environ.get('DESTDIR', '')
d.fullprefix = destdir_join(d.destdir, d.prefix)

Loading…
Cancel
Save