Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(104)

Side by Side Diff: tools/cr/cr/actions/ninja.py

Issue 131543004: Make cr build run goma_ctl.py ensure_start before building. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | tools/cr/cr/base/host.py » ('j') | tools/cr/cr/base/host.py » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """A module to add ninja support to cr.""" 5 """A module to add ninja support to cr."""
6 6
7 import os 7 import os
8 8
9 import cr 9 import cr
10 10
(...skipping 12 matching lines...) Expand all
23 GOMA_DIR=os.path.join('{GOOGLE_CODE}', 'goma'), 23 GOMA_DIR=os.path.join('{GOOGLE_CODE}', 'goma'),
24 ) 24 )
25 # A placeholder for the system detected configuration 25 # A placeholder for the system detected configuration
26 DETECTED = cr.Config('DETECTED') 26 DETECTED = cr.Config('DETECTED')
27 27
28 def __init__(self): 28 def __init__(self):
29 super(NinjaBuilder, self).__init__() 29 super(NinjaBuilder, self).__init__()
30 self._targets = [] 30 self._targets = []
31 31
32 def Build(self, context, targets, arguments): 32 def Build(self, context, targets, arguments):
33 # Make sure Goma is started, if Ninja is set to use it.
34 # This may be redundant, but it currently improves reliability.
35 try:
ian_cottrell 2014/01/09 17:00:21 I would change how you build paths. Use NINJA_BU
johnme 2014/01/09 19:06:11 Done.
36 goma_dir = context.Get('GOMA_DIR', raise_errors=True)
37 build_dir = context.Get('CR_BUILD_DIR', raise_errors=True)
38 build_ninja = os.path.join(build_dir, 'build.ninja')
39 if os.path.exists(build_ninja):
40 goma_cc = 'cc = {} $\n'.format(os.path.join(goma_dir, 'gomacc'))
41 with open(build_ninja, 'r') as f:
ian_cottrell 2014/01/09 17:00:21 This is vile, but I don't have a better suggestion
42 if f.readline() == goma_cc:
43 # Goma is active, so make sure it's started.
44 cr.Host.ExecuteSilently(
45 context,
46 os.path.join('{GOMA_DIR}', 'goma_ctl.py'),
47 'ensure_start'
48 )
49 except KeyError:
50 pass
51
52
33 build_arguments = [target.build_target for target in targets] 53 build_arguments = [target.build_target for target in targets]
34 build_arguments.extend(arguments) 54 build_arguments.extend(arguments)
35 cr.Host.Execute( 55 cr.Host.Execute(
36 context, 56 context,
37 '{NINJA_BINARY}', 57 '{NINJA_BINARY}',
38 '-C{CR_BUILD_DIR}', 58 '-C{CR_BUILD_DIR}',
39 '-j{NINJA_JOBS}', 59 '-j{NINJA_JOBS}',
40 '-l{NINJA_PROCESSORS}', 60 '-l{NINJA_PROCESSORS}',
41 *build_arguments 61 *build_arguments
42 ) 62 )
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 return self._targets 97 return self._targets
78 98
79 @classmethod 99 @classmethod
80 def DetectNinja(cls): 100 def DetectNinja(cls):
81 # TODO(iancottrell): If we can't detect ninja, we should be disabled. 101 # TODO(iancottrell): If we can't detect ninja, we should be disabled.
82 ninja_binaries = cr.Host.SearchPath('ninja') 102 ninja_binaries = cr.Host.SearchPath('ninja')
83 if ninja_binaries: 103 if ninja_binaries:
84 cls.DETECTED.Set(NINJA_BINARY=ninja_binaries[0]) 104 cls.DETECTED.Set(NINJA_BINARY=ninja_binaries[0])
85 105
86 NinjaBuilder.DetectNinja() 106 NinjaBuilder.DetectNinja()
OLDNEW
« no previous file with comments | « no previous file | tools/cr/cr/base/host.py » ('j') | tools/cr/cr/base/host.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698