backends: Always use the command returned by as_meson_exe_cmdline()

Even if the command is not wrapped by meson, it could have been modified
to add java/mono interpreters. This fix potential inconsistency between
wrapped and unwrapped commands.
pull/8324/head
Xavier Claessens 4 years ago committed by Jussi Pakkanen
parent ba770d1877
commit a155935d24
  1. 8
      mesonbuild/backend/backends.py
  2. 19
      mesonbuild/backend/ninjabackend.py

@ -457,10 +457,10 @@ class Backend:
if workdir: if workdir:
reasons.append('to set workdir') reasons.append('to set workdir')
if any('\n' in c for c in cmd_args): if any('\n' in c for c in es.cmd_args):
reasons.append('because command contains newlines') reasons.append('because command contains newlines')
if env and env.varnames: if es.env and es.env.varnames:
reasons.append('to set env') reasons.append('to set env')
force_serialize = force_serialize or bool(reasons) force_serialize = force_serialize or bool(reasons)
@ -470,7 +470,7 @@ class Backend:
if not force_serialize: if not force_serialize:
if not capture: if not capture:
return None, '' return es.cmd_args, ''
return ((self.environment.get_build_command() + return ((self.environment.get_build_command() +
['--internal', 'exe', '--capture', capture, '--'] + es.cmd_args), ['--internal', 'exe', '--capture', capture, '--'] + es.cmd_args),
', '.join(reasons)) ', '.join(reasons))
@ -487,7 +487,7 @@ class Backend:
# Take a digest of the cmd args, env, workdir, and capture. This avoids # Take a digest of the cmd args, env, workdir, and capture. This avoids
# collisions and also makes the name deterministic over regenerations # collisions and also makes the name deterministic over regenerations
# which avoids a rebuild by Ninja because the cmdline stays the same. # which avoids a rebuild by Ninja because the cmdline stays the same.
data = bytes(str(env) + str(cmd_args) + str(es.workdir) + str(capture), data = bytes(str(es.env) + str(es.cmd_args) + str(es.workdir) + str(capture),
encoding='utf-8') encoding='utf-8')
digest = hashlib.sha1(data).hexdigest() digest = hashlib.sha1(data).hexdigest()
scratch_file = 'meson_exe_{0}_{1}.dat'.format(basename, digest) scratch_file = 'meson_exe_{0}_{1}.dat'.format(basename, digest)

@ -956,12 +956,11 @@ int dummy;
for output in d.get_outputs(): for output in d.get_outputs():
elem.add_dep(os.path.join(self.get_target_dir(d), output)) elem.add_dep(os.path.join(self.get_target_dir(d), output))
meson_exe_cmd, reason = self.as_meson_exe_cmdline(target.name, target.command[0], cmd[1:], cmd, reason = self.as_meson_exe_cmdline(target.name, target.command[0], cmd[1:],
extra_bdeps=target.get_transitive_build_target_deps(), extra_bdeps=target.get_transitive_build_target_deps(),
capture=ofilenames[0] if target.capture else None, capture=ofilenames[0] if target.capture else None,
env=target.env) env=target.env)
if meson_exe_cmd: if reason:
cmd = meson_exe_cmd
cmd_type = ' (wrapped by meson {})'.format(reason) cmd_type = ' (wrapped by meson {})'.format(reason)
else: else:
cmd_type = '' cmd_type = ''
@ -2101,11 +2100,9 @@ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47485'''))
outfilelist = outfilelist[len(generator.outputs):] outfilelist = outfilelist[len(generator.outputs):]
args = self.replace_paths(target, args, override_subdir=subdir) args = self.replace_paths(target, args, override_subdir=subdir)
cmdlist = exe_arr + self.replace_extra_args(args, genlist) cmdlist = exe_arr + self.replace_extra_args(args, genlist)
meson_exe_cmd, reason = self.as_meson_exe_cmdline('generator ' + cmdlist[0], cmdlist, reason = self.as_meson_exe_cmdline('generator ' + cmdlist[0],
cmdlist[0], cmdlist[1:], cmdlist[0], cmdlist[1:],
capture=outfiles[0] if generator.capture else None) capture=outfiles[0] if generator.capture else None)
if meson_exe_cmd:
cmdlist = meson_exe_cmd
abs_pdir = os.path.join(self.environment.get_build_dir(), self.get_target_dir(target)) abs_pdir = os.path.join(self.environment.get_build_dir(), self.get_target_dir(target))
os.makedirs(abs_pdir, exist_ok=True) os.makedirs(abs_pdir, exist_ok=True)

Loading…
Cancel
Save