Commit a5193d3a authored by Andrew Grieve's avatar Andrew Grieve Committed by Commit Bot

autotest.py: Use autoninja from PATH. Make -C optional

Use autoninja from PATH so that it matches the version used when
building explicitly (allows for devs that are using a custom-built
version of ninja).

Allow omitting -C when script is run from within the output directory.
This matches ninja's behavior.

Bug: None
Change-Id: I55763f178e2cf85892efbb4397a7ec81ed054aa5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2419608
Auto-Submit: Andrew Grieve <agrieve@chromium.org>
Reviewed-by: default avatarMichael Thiessen <mthiesse@chromium.org>
Commit-Queue: Michael Thiessen <mthiesse@chromium.org>
Cr-Commit-Position: refs/heads/master@{#808875}
parent ce7abc81
......@@ -117,7 +117,8 @@ def RunCommand(cmd, **kwargs):
def BuildTestTargetsWithNinja(out_dir, targets, dry_run):
"""Builds the specified targets with ninja"""
ninja_path = os.path.join(DEPOT_TOOLS_DIR, 'autoninja')
# Use autoninja from PATH to match version used for manual builds.
ninja_path = 'autoninja'
if sys.platform.startswith('win32'):
ninja_path += '.bat'
cmd = [ninja_path, '-C', out_dir] + targets
......@@ -349,12 +350,10 @@ def BuildTestFilter(filenames, line):
def main():
parser = argparse.ArgumentParser(
description=__doc__, formatter_class=argparse.RawTextHelpFormatter)
parser.add_argument(
'--out-dir',
'-C',
metavar='OUT_DIR',
help='output directory of the build',
required=True)
parser.add_argument('--out-dir',
'-C',
metavar='OUT_DIR',
help='output directory of the build')
parser.add_argument(
'--run-all',
action='store_true',
......@@ -375,6 +374,10 @@ def main():
args, _extras = parser.parse_known_args()
# Use CWD as out_dir when build.ninja exists.
if not args.out_dir and os.path.exists('build.ninja'):
args.out_dir = '.'
if not os.path.isdir(args.out_dir):
parser.error(f'OUT_DIR "{args.out_dir}" does not exist.')
target_cache = TargetCache(args.out_dir)
......
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