Index: tools/cr/cr/actions/ninja.py |
diff --git a/tools/cr/cr/actions/ninja.py b/tools/cr/cr/actions/ninja.py |
index 404e6caea26e11360bf1b874e72c8de38f3fd697..651bca96df3a4fb780b3d04497c3af2d2cab25f4 100644 |
--- a/tools/cr/cr/actions/ninja.py |
+++ b/tools/cr/cr/actions/ninja.py |
@@ -20,7 +20,12 @@ class NinjaBuilder(cr.Builder): |
NINJA_BINARY=os.path.join('{DEPOT_TOOLS}', 'ninja'), |
NINJA_JOBS=200, |
NINJA_PROCESSORS=12, |
+ NINJA_BUILD_FILE=os.path.join('{CR_BUILD_DIR}', 'build.ninja'), |
GOMA_DIR=os.path.join('{GOOGLE_CODE}', 'goma'), |
+ # Don't rename to GOMA_* or Goma will complain: "unkown GOMA_ parameter". |
+ NINJA_GOMA_CTL=os.path.join('{GOMA_DIR}', 'goma_ctl.py'), |
+ NINJA_GOMA_CC=os.path.join('{GOMA_DIR}', 'gomacc'), |
+ NINJA_GOMA_LINE='cc = {NINJA_GOMA_CC} $', |
) |
# A placeholder for the system detected configuration |
DETECTED = cr.Config('DETECTED') |
@@ -30,6 +35,20 @@ class NinjaBuilder(cr.Builder): |
self._targets = [] |
def Build(self, context, targets, arguments): |
+ # Make sure Goma is started if Ninja is set to use it. |
+ # This may be redundant, but it currently improves reliability. |
+ try: |
+ with open(context.Get('NINJA_BUILD_FILE'), 'r') as f: |
+ if f.readline().rstrip('\n') == context.Get('NINJA_GOMA_LINE'): |
+ # Goma is active, so make sure it's started. |
+ cr.Host.ExecuteSilently( |
+ context, |
+ '{NINJA_GOMA_CTL}', |
+ 'ensure_start' |
+ ) |
+ except IOError: |
+ pass |
+ |
build_arguments = [target.build_target for target in targets] |
build_arguments.extend(arguments) |
cr.Host.Execute( |