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.
pull/4745/head
Robert Bragg 6 years ago committed by Jussi Pakkanen
parent 6c76b92dff
commit f2223fcf54
  1. 8
      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_template = ' command = {executable} $ARGS {output_args} $in $LINK_ARGS {cross_args} $aliasing\n'
command = command_template.format( command = command_template.format(
executable=' '.join(compiler.get_linker_exelist()), 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')) output_args=' '.join(compiler.get_linker_output_args('$out'))
) )
description = ' description = Linking target $out.\n' 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_template = ' command = {executable} $ARGS {cross_args} {output_args} {compile_only_args} $in\n'
command = command_template.format( command = command_template.format(
executable=' '.join([ninja_quote(i) for i in compiler.get_exelist()]), 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')), output_args=' '.join(compiler.get_output_args('$out')),
compile_only_args=' '.join(compiler.get_compile_only_args()) 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_template = ' command = {executable} $ARGS {cross_args} {dep_args} {output_args} {compile_only_args} $in\n'
command = command_template.format( command = command_template.format(
executable=' '.join([ninja_quote(i) for i in compiler.get_exelist()]), 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), dep_args=' '.join(quoted_depargs),
output_args=' '.join(compiler.get_output_args('$out')), output_args=' '.join(compiler.get_output_args('$out')),
compile_only_args=' '.join(compiler.get_compile_only_args()) 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')) output = ' '.join(compiler.get_output_args('$out'))
command = " command = {executable} $ARGS {cross_args} {dep_args} {output_args} {compile_only_args} $in\n".format( command = " command = {executable} $ARGS {cross_args} {dep_args} {output_args} {compile_only_args} $in\n".format(
executable=' '.join(compiler.get_exelist()), 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), dep_args=' '.join(quoted_depargs),
output_args=output, output_args=output,
compile_only_args=' '.join(compiler.get_compile_only_args()) compile_only_args=' '.join(compiler.get_compile_only_args())

Loading…
Cancel
Save