From 85c75025906ac77b4f7979896985119dfb8dca1b Mon Sep 17 00:00:00 2001 From: Bruce Dawson Date: Tue, 17 Apr 2018 17:49:06 -0700 Subject: [PATCH] Teach autoninja.py to support GOMA_DISABLED env var When GOMA_DISABLED is set goma will use the local compiler. Autoninja needs to understand this in order to avoid requesting too much parallelism. Change-Id: Ic124893dd583a401d0d9ad7fbd27ee9b6715fcfe Reviewed-on: https://chromium-review.googlesource.com/1015402 Commit-Queue: Bruce Dawson Reviewed-by: Dirk Pranke --- autoninja.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/autoninja.py b/autoninja.py index 7e994c9cdd..01dcc30b73 100755 --- a/autoninja.py +++ b/autoninja.py @@ -41,12 +41,20 @@ for index, arg in enumerate(input_args[1:]): use_goma = False try: - 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 - m = re.match('^\s*use_goma\s*=\s*true(\s*$|\s*#.*$)', line) - if m: - use_goma = True + # 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' not in os.environ: + 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 + m = re.match('^\s*use_goma\s*=\s*true(\s*$|\s*#.*$)', line) + if m: + use_goma = True except IOError: pass