Commit 3a96d620 authored by Sam Clegg's avatar Sam Clegg Committed by Commit Bot

autoninja: Support cmake-based builds

On the wasm team we build several CMake-based projects with ninja
(LLVM, binaryen, etc), and its useful for us (me at least) to be able
to use autoninja with these project too.

Change-Id: I7e213448dbbe95ffe3d249c9c6a3d4baa41f50d1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1682742Reviewed-by: 's avatarBruce Dawson <brucedawson@chromium.org>
Commit-Queue: Sam Clegg <sbc@chromium.org>
parent fedbb7dc
......@@ -59,19 +59,15 @@ for index, arg in enumerate(input_args[1:]):
use_goma = False
use_jumbo_build = False
try:
# If GOMA_DISABLED is set (to anything) then gomacc will use the local
# compiler instead of doing a goma compile. This is convenient if you want
# to briefly disable goma. It avoids having to rebuild the world when
# transitioning between goma/non-goma builds. However, it is not as fast as
# doing a "normal" non-goma build because an extra process is created for each
# compile step. Checking this environment variable ensures that autoninja uses
# an appropriate -j value in this situation.
# Attempt to auto-detect goma usage. We support gn-based builds, where we
# look for args.gn in the build tree, and cmake-based builds where we look for
# rules.ninja.
if os.path.exists(os.path.join(output_dir, 'args.gn')):
with open(os.path.join(output_dir, 'args.gn')) as file_handle:
for line in file_handle:
# This regex pattern copied from create_installer_archive.py
match_use_goma = re.match(r'^\s*use_goma\s*=\s*true(\s*$|\s*#.*$)', line)
if match_use_goma and 'GOMA_DISABLED' not in os.environ:
if re.match(r'^\s*use_goma\s*=\s*true(\s*$|\s*#.*$)', line):
use_goma = True
continue
match_use_jumbo_build = re.match(
......@@ -79,8 +75,22 @@ try:
if match_use_jumbo_build:
use_jumbo_build = True
continue
except IOError:
pass
elif os.path.exists(os.path.join(output_dir, 'rules.ninja')):
with open(os.path.join(output_dir, 'rules.ninja')) as file_handle:
for line in file_handle:
if re.match(r'^\s*command\s*=\s*\S+gomacc', line):
use_goma = True
break
# If GOMA_DISABLED is set (to anything) then gomacc will use the local
# compiler instead of doing a goma compile. This is convenient if you want
# to briefly disable goma. It avoids having to rebuild the world when
# transitioning between goma/non-goma builds. However, it is not as fast as
# doing a "normal" non-goma build because an extra process is created for each
# compile step. Checking this environment variable ensures that autoninja uses
# an appropriate -j value in this situation.
if 'GOMA_DISABLED' in os.environ:
use_goma = False
# Specify ninja.exe on Windows so that ninja.bat can call autoninja and not
# be called back.
......
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