Commit 43a35d29 authored by Yoshisato Yanagisawa's avatar Yoshisato Yanagisawa Committed by Commit Bot

autoninja: quote the arguments when needed.

On Windows, without quote, whole return value would be treated as
a command, and the execution would fail.
On Linux and Mac, without quote, if depot_tools is settled under
directories with ' ', command execution would fail because paths are
separated in a wrong way.

To make such a return value work on Linux and Mac, the shell script
started to use eval.

Bug: 902930
Change-Id: I9bb74585294af565988c0b844b6b113a5c685530
Reviewed-on: https://chromium-review.googlesource.com/c/1325249Reviewed-by: 's avatarDirk Pranke <dpranke@chromium.org>
Commit-Queue: Yoshisato Yanagisawa <yyanagisawa@chromium.org>
parent f66e5510
......@@ -11,7 +11,7 @@ export AUTONINJA_BUILD_ID="$(python -c "import uuid; print uuid.uuid4()")"
# Also print it to reassure that the right settings are being used.
command=$(python $(dirname -- "$0")/autoninja.py "$@")
echo $command
$command
eval $command
if [ $? -eq 0 ]; then
if [ "$NINJA_SUMMARIZE_BUILD" == "1" ]; then
python $(dirname -- "$0")/post_build_ninja_summary.py $@
......
......@@ -69,14 +69,8 @@ except IOError:
# Specify ninja.exe on Windows so that ninja.bat can call autoninja and not
# be called back.
ninja_exe = 'ninja.exe' if sys.platform.startswith('win') else 'ninja'
ninja_exe_path = os.path.join(SCRIPT_DIR, ninja_exe)
# On Windows, fully quote the path so that the command processor doesn't think
# the whole output is the command.
if sys.platform.startswith('win'):
ninja_exe_path = '"' + ninja_exe_path + '"'
# Use absolute path for ninja path,
# or fail to execute ninja if depot_tools is not in PATH.
args = [ninja_exe_path] + input_args[1:]
......@@ -94,4 +88,14 @@ if not j_specified and not t_specified:
args.append('-j')
args.append('%d' % (num_cores + core_addition))
# On Windows, fully quote the path so that the command processor doesn't think
# the whole output is the command.
# On Linux and Mac, if people put depot_tools in directories with ' ',
# shell would misunderstand ' ' as a path separation.
# TODO(yyanagisawa): provide proper quating for Windows.
# see https://cs.chromium.org/chromium/src/tools/mb/mb.py
for i in range(len(args)):
if (i == 0 and sys.platform.startswith('win')) or ' ' in args[i]:
args[i] = '"%s"' % args[i].replace('"', '\\"')
print ' '.join(args)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment