Serialize CustomTargets with newlines in command.

pull/1657/head
Elliott Sales de Andrade 8 years ago
parent abd02b3eae
commit bbcf0c0550
  1. 13
      mesonbuild/backend/ninjabackend.py

@ -38,8 +38,11 @@ else:
rmfile_prefix = 'rm -f {} &&' rmfile_prefix = 'rm -f {} &&'
def ninja_quote(text): def ninja_quote(text):
for char in ('$', ' ', ':', '\n'): for char in ('$', ' ', ':'):
text = text.replace(char, '$' + char) text = text.replace(char, '$' + char)
if '\n' in text:
raise MesonException('Ninja does not support newlines in rules. '
'Please report this error with a test case to the Meson bug tracker.')
return text return text
@ -482,12 +485,16 @@ int dummy;
# If the target requires capturing stdout, then use the serialized # If the target requires capturing stdout, then use the serialized
# executable wrapper to capture that output and save it to a file. # executable wrapper to capture that output and save it to a file.
# #
# If the command line requires a newline, also use the wrapper, as
# ninja does not support them in its build rule syntax.
#
# Windows doesn't have -rpath, so for EXEs that need DLLs built within # Windows doesn't have -rpath, so for EXEs that need DLLs built within
# the project, we need to set PATH so the DLLs are found. We use # the project, we need to set PATH so the DLLs are found. We use
# a serialized executable wrapper for that and check if the # a serialized executable wrapper for that and check if the
# CustomTarget command needs extra paths first. # CustomTarget command needs extra paths first.
if target.capture or ((mesonlib.is_windows() or mesonlib.is_cygwin()) and if (target.capture or any('\n' in c for c in cmd) or
self.determine_windows_extra_paths(target.command[0])): ((mesonlib.is_windows() or mesonlib.is_cygwin()) and
self.determine_windows_extra_paths(target.command[0]))):
exe_data = self.serialize_executable(target.command[0], cmd[1:], exe_data = self.serialize_executable(target.command[0], cmd[1:],
# All targets are built from the build dir # All targets are built from the build dir
self.environment.get_build_dir(), self.environment.get_build_dir(),

Loading…
Cancel
Save