Serialize CustomTargets with newlines in command.
@@ -38,8 +38,11 @@ else:
rmfile_prefix = 'rm -f {} &&'
def ninja_quote(text):
- for char in ('$', ' ', ':', '\n'):
+ for char in ('$', ' ', ':'):
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
@@ -482,12 +485,16 @@ int dummy;
# If the target requires capturing stdout, then use the serialized
# 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
# the project, we need to set PATH so the DLLs are found. We use
# a serialized executable wrapper for that and check if the
# CustomTarget command needs extra paths first.
- if target.capture or ((mesonlib.is_windows() or mesonlib.is_cygwin()) and
- self.determine_windows_extra_paths(target.command[0])):
+ if (target.capture or any('\n' in c for c in cmd) or
+ ((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:],
# All targets are built from the build dir
self.environment.get_build_dir(),
