backends: hide meson --internal exe cmdline from backends

Return the command line from serialize_executable, which is then
renamed to as_meson_exe_cmdline.  This avoids repeating code that
is common to custom targets and generators.
pull/5644/head
Paolo Bonzini 6 years ago
parent 28c93ce4af
commit 3ef7b23178
  1. 4
      mesonbuild/backend/backends.py
  2. 14
      mesonbuild/backend/ninjabackend.py
  3. 16
      mesonbuild/backend/vs2010backend.py

@ -323,7 +323,7 @@ class Backend:
raise MesonException('Unknown data type in object list.')
return obj_list
def serialize_executable(self, tname, exe, cmd_args, workdir, env=None,
def as_meson_exe_cmdline(self, tname, exe, cmd_args, workdir, env=None,
extra_paths=None, capture=None):
'''
Serialize an executable for running with a generator or a custom target
@ -376,7 +376,7 @@ class Backend:
extra_paths, capture,
self.environment.need_exe_wrapper())
pickle.dump(es, f)
return exe_data
return self.environment.get_build_command() + ['--internal', 'exe', exe_data]
def serialize_tests(self):
test_data = os.path.join(self.environment.get_scratch_dir(), 'meson_test_setup.dat')

@ -679,12 +679,11 @@ int dummy;
if extra_paths:
serialize = True
if serialize:
exe_data = self.serialize_executable(target.name, target.command[0], cmd[1:],
# All targets are built from the build dir
self.environment.get_build_dir(),
extra_paths=extra_paths,
capture=ofilenames[0] if target.capture else None)
cmd = self.environment.get_build_command() + ['--internal', 'exe', exe_data]
cmd = self.as_meson_exe_cmdline(target.name, target.command[0], cmd[1:],
# All targets are built from the build dir
self.environment.get_build_dir(),
extra_paths=extra_paths,
capture=ofilenames[0] if target.capture else None)
cmd_type = 'meson_exe.py custom'
else:
cmd_type = 'custom'
@ -1787,14 +1786,13 @@ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47485'''))
args = self.replace_paths(target, args, override_subdir=subdir)
cmdlist = exe_arr + self.replace_extra_args(args, genlist)
if generator.capture:
exe_data = self.serialize_executable(
cmd = self.as_meson_exe_cmdline(
'generator ' + cmdlist[0],
cmdlist[0],
cmdlist[1:],
self.environment.get_build_dir(),
capture=outfiles[0]
)
cmd = self.environment.get_build_command() + ['--internal', 'exe', exe_data]
abs_pdir = os.path.join(self.environment.get_build_dir(), self.get_target_dir(target))
os.makedirs(abs_pdir, exist_ok=True)
else:

@ -144,14 +144,13 @@ class Vs2010Backend(backends.Backend):
args = [x.replace('\\', '/') for x in args]
cmd = exe_arr + self.replace_extra_args(args, genlist)
if generator.capture:
exe_data = self.serialize_executable(
cmd = self.as_meson_exe_cmdline(
'generator ' + cmd[0],
cmd[0],
cmd[1:],
self.environment.get_build_dir(),
capture=outfiles[0]
)
cmd = self.environment.get_build_command() + ['--internal', 'exe', exe_data]
abs_pdir = os.path.join(self.environment.get_build_dir(), self.get_target_dir(target))
os.makedirs(abs_pdir, exist_ok=True)
cbs = ET.SubElement(idgroup, 'CustomBuild', Include=infilename)
@ -559,18 +558,17 @@ class Vs2010Backend(backends.Backend):
tdir_abs = os.path.join(self.environment.get_build_dir(), self.get_target_dir(target))
extra_bdeps = target.get_transitive_build_target_deps()
extra_paths = self.determine_windows_extra_paths(target.command[0], extra_bdeps)
exe_data = self.serialize_executable(target.name, target.command[0], cmd[1:],
# All targets run from the target dir
tdir_abs,
extra_paths=extra_paths,
capture=ofilenames[0] if target.capture else None)
wrapper_cmd = self.environment.get_build_command() + ['--internal', 'exe', exe_data]
wrapper_cmd = self.as_meson_exe_cmdline(target.name, target.command[0], cmd[1:],
# All targets run from the target dir
tdir_abs,
extra_paths=extra_paths,
capture=ofilenames[0] if target.capture else None)
if target.build_always_stale:
# Use a nonexistent file to always consider the target out-of-date.
ofilenames += [self.nonexistent_file(os.path.join(self.environment.get_scratch_dir(),
'outofdate.file'))]
self.add_custom_build(root, 'custom_target', ' '.join(self.quote_arguments(wrapper_cmd)),
deps=[exe_data] + srcs + depend_files, outputs=ofilenames)
deps=wrapper_cmd[-1:] + srcs + depend_files, outputs=ofilenames)
ET.SubElement(root, 'Import', Project=r'$(VCTargetsPath)\Microsoft.Cpp.targets')
self.generate_custom_generator_commands(target, root)
self.add_regen_dependency(root)

Loading…
Cancel
Save