From f2223fcf541e6e5d6d384c54ca3f911716f86c60 Mon Sep 17 00:00:00 2001 From: Robert Bragg Date: Wed, 2 Jan 2019 16:32:56 +0000 Subject: [PATCH] ninjabackend: Adding missing shell quotes for compiler arguments Since trying to cross compile for Windows from Linux (WSL) and having paths like this: '-L/mnt/c/Program Files (x86)/Microsoft Visual Studio/2017/\ Community/VC/Tools/MSVC/14.15.26726/lib/x64' I found that the spaces and brackets in the paths weren't properly escaped by the Ninja backend. --- mesonbuild/backend/ninjabackend.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index 3688f294d..debb4fbcf 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -1473,7 +1473,7 @@ int dummy; command_template = ' command = {executable} $ARGS {output_args} $in $LINK_ARGS {cross_args} $aliasing\n' command = command_template.format( executable=' '.join(compiler.get_linker_exelist()), - cross_args=' '.join(cross_args), + cross_args=' '.join([quote_func(i) for i in cross_args]), output_args=' '.join(compiler.get_linker_output_args('$out')) ) description = ' description = Linking target $out.\n' @@ -1601,7 +1601,7 @@ rule FORTRAN_DEP_HACK%s command_template = ' command = {executable} $ARGS {cross_args} {output_args} {compile_only_args} $in\n' command = command_template.format( executable=' '.join([ninja_quote(i) for i in compiler.get_exelist()]), - cross_args=' '.join(compiler.get_cross_extra_flags(self.environment, False)) if is_cross else '', + cross_args=' '.join([quote_func(i) for i in compiler.get_cross_extra_flags(self.environment, False)]) if is_cross else '', output_args=' '.join(compiler.get_output_args('$out')), compile_only_args=' '.join(compiler.get_compile_only_args()) ) @@ -1659,7 +1659,7 @@ rule FORTRAN_DEP_HACK%s command_template = ' command = {executable} $ARGS {cross_args} {dep_args} {output_args} {compile_only_args} $in\n' command = command_template.format( executable=' '.join([ninja_quote(i) for i in compiler.get_exelist()]), - cross_args=' '.join(cross_args), + cross_args=' '.join([quote_func(i) for i in cross_args]), dep_args=' '.join(quoted_depargs), output_args=' '.join(compiler.get_output_args('$out')), compile_only_args=' '.join(compiler.get_compile_only_args()) @@ -1703,7 +1703,7 @@ rule FORTRAN_DEP_HACK%s output = ' '.join(compiler.get_output_args('$out')) command = " command = {executable} $ARGS {cross_args} {dep_args} {output_args} {compile_only_args} $in\n".format( executable=' '.join(compiler.get_exelist()), - cross_args=' '.join(cross_args), + cross_args=' '.join([quote_func(i) for i in cross_args]), dep_args=' '.join(quoted_depargs), output_args=output, compile_only_args=' '.join(compiler.get_compile_only_args())