backends: remove unnecessary fields from ExecutableSerialisation

"exe.is_cross and exe.needs_exe_wrapper" is the same condition under which
meson chooses whether to include the exe_wrapper.  meson_exe has an assertion
for that, but now that meson_exe does not need anymore exe.is_cross,
we can simplify the code if we just "trust" meson to do the right thing.

Remove both fields from ExecutableSerialisation and just test the presence
of the wrapper, and also remove the executable basename which is only
used to "beautify" an assertion failure.
pull/5644/head
Paolo Bonzini 5 years ago
parent ed348b7da8
commit b4d313b058
  1. 14
      mesonbuild/backend/backends.py
  2. 13
      mesonbuild/scripts/meson_exe.py

@ -69,17 +69,14 @@ class TargetInstallData:
self.optional = optional
class ExecutableSerialisation:
def __init__(self, name, fname, cmd_args, env=None, is_cross=False, exe_wrapper=None,
workdir=None, extra_paths=None, capture=None, needs_exe_wrapper: bool = False):
self.name = name
def __init__(self, fname, cmd_args, env=None, exe_wrapper=None,
workdir=None, extra_paths=None, capture=None):
self.fname = fname
self.cmd_args = cmd_args
self.env = env or {}
self.is_cross = is_cross
if exe_wrapper is not None:
assert(isinstance(exe_wrapper, dependencies.ExternalProgram))
self.exe_runner = exe_wrapper
self.needs_exe_wrapper = needs_exe_wrapper
self.workdir = workdir
self.extra_paths = extra_paths
self.capture = capture
@ -387,10 +384,9 @@ class Backend:
scratch_file = 'meson_exe_{0}_{1}.dat'.format(basename, digest)
exe_data = os.path.join(self.environment.get_scratch_dir(), scratch_file)
with open(exe_data, 'wb') as f:
es = ExecutableSerialisation(basename, exe_cmd, cmd_args, env,
is_cross_built, exe_wrapper, workdir,
extra_paths, capture,
self.environment.need_exe_wrapper())
es = ExecutableSerialisation(exe_cmd, cmd_args, env,
exe_wrapper, workdir,
extra_paths, capture)
pickle.dump(es, f)
return self.environment.get_build_command() + ['--internal', 'exe', '--unpickle', exe_data]

@ -39,14 +39,10 @@ def is_cygwin():
return 'cygwin' in platname
def run_exe(exe):
if exe.is_cross and exe.needs_exe_wrapper:
if exe.exe_runner is None:
raise AssertionError('BUG: Can\'t run cross-compiled exe {!r} '
'with no wrapper'.format(exe.name))
elif not exe.exe_runner.found():
if exe.exe_runner:
if not exe.exe_runner.found():
raise AssertionError('BUG: Can\'t run cross-compiled exe {!r} with not-found '
'wrapper {!r}'.format(exe.name, exe.exe_runner.get_path()))
else:
'wrapper {!r}'.format(exe.fname[0], exe.exe_runner.get_path()))
cmd = exe.exe_runner.get_command() + exe.fname
else:
cmd = exe.fname
@ -109,8 +105,7 @@ def run(args):
else:
exe_cmd = cmd_args[0]
cmd_args = cmd_args[1:]
basename = os.path.basename(exe_cmd)
exe = ExecutableSerialisation(basename, [exe_cmd], cmd_args,
exe = ExecutableSerialisation([exe_cmd], cmd_args,
capture=options.capture)
return run_exe(exe)

Loading…
Cancel
Save