From 4b49707cb5caf3c05e5a3449319e98c29b84ac02 Mon Sep 17 00:00:00 2001 From: Yoshisato Yanagisawa Date: Wed, 7 Nov 2018 02:52:33 +0000 Subject: [PATCH] autoninja: use ninja in the autoninja.py directory When people execute autoninja, I believe people would expect ninja in the autoninja directory would be used. However, the original code find ninja from PATH, and ninja in other directory could be used. People usually do not notice this because having depot_tools in PATH is recommended for Chromium developers. However, in some environments, an old version ninja is pre-installed, and unexpected version ninja could be used upon PATH environment. Also, in most of bots, depot_tools directory is not included in PATH. Autoninja execution would fail there because the system cannot find ninja. Bug: b/77176746 Change-Id: Iad8bd952dc1e34a9d303fd5b493c555156369a17 Reviewed-on: https://chromium-review.googlesource.com/c/1319489 Reviewed-by: Dirk Pranke Reviewed-by: Bruce Dawson Reviewed-by: Fumitoshi Ukai Reviewed-by: Shinya Kawanaka Commit-Queue: Yoshisato Yanagisawa Auto-Submit: Yoshisato Yanagisawa --- autoninja.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/autoninja.py b/autoninja.py index 2c1cc9b7b4..e927ec027e 100755 --- a/autoninja.py +++ b/autoninja.py @@ -15,6 +15,8 @@ import os import re import sys +SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__)) + # The -t tools are incompatible with -j t_specified = False j_specified = False @@ -61,12 +63,13 @@ try: except IOError: pass -if sys.platform.startswith('win'): - # Specify ninja.exe on Windows so that ninja.bat can call autoninja and not - # be called back. - args = ['ninja.exe'] + input_args[1:] -else: - args = ['ninja'] + input_args[1:] +# 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' + +# Use absolute path for ninja path, +# or fail to execute ninja if depot_tools is not in PATH. +args = [os.path.join(SCRIPT_DIR, ninja_exe)] + input_args[1:] num_cores = multiprocessing.cpu_count() if not j_specified and not t_specified: