Commit 3a5538f4 authored by johnme@chromium.org's avatar johnme@chromium.org

Make cr build run goma_ctl.py ensure_start before building.

Review URL: https://codereview.chromium.org/131543004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@244185 0039d316-1c4b-4281-b951-d872f2087c98
parent b03890ff
...@@ -20,7 +20,12 @@ class NinjaBuilder(cr.Builder): ...@@ -20,7 +20,12 @@ class NinjaBuilder(cr.Builder):
NINJA_BINARY=os.path.join('{DEPOT_TOOLS}', 'ninja'), NINJA_BINARY=os.path.join('{DEPOT_TOOLS}', 'ninja'),
NINJA_JOBS=200, NINJA_JOBS=200,
NINJA_PROCESSORS=12, NINJA_PROCESSORS=12,
NINJA_BUILD_FILE=os.path.join('{CR_BUILD_DIR}', 'build.ninja'),
GOMA_DIR=os.path.join('{GOOGLE_CODE}', 'goma'), 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 # A placeholder for the system detected configuration
DETECTED = cr.Config('DETECTED') DETECTED = cr.Config('DETECTED')
...@@ -30,6 +35,20 @@ class NinjaBuilder(cr.Builder): ...@@ -30,6 +35,20 @@ class NinjaBuilder(cr.Builder):
self._targets = [] self._targets = []
def Build(self, context, targets, arguments): 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 = [target.build_target for target in targets]
build_arguments.extend(arguments) build_arguments.extend(arguments)
cr.Host.Execute( cr.Host.Execute(
......
...@@ -41,8 +41,8 @@ class Host(cr.Plugin, cr.Plugin.Type): ...@@ -41,8 +41,8 @@ class Host(cr.Plugin, cr.Plugin.Type):
return host return host
def _Execute(self, context, command, def _Execute(self, context, command,
shell=False, capture=False, ignore_dry_run=False, shell=False, capture=False, silent=False,
return_status=False): ignore_dry_run=False, return_status=False):
"""This is the only method that launches external programs. """This is the only method that launches external programs.
It is a thin wrapper around subprocess.Popen that handles cr specific It is a thin wrapper around subprocess.Popen that handles cr specific
...@@ -78,6 +78,8 @@ class Host(cr.Plugin, cr.Plugin.Type): ...@@ -78,6 +78,8 @@ class Host(cr.Plugin, cr.Plugin.Type):
out = None out = None
if capture: if capture:
out = subprocess.PIPE out = subprocess.PIPE
elif silent:
out = open(os.devnull, "w")
try: try:
p = subprocess.Popen( p = subprocess.Popen(
command, shell=shell, command, shell=shell,
...@@ -97,6 +99,9 @@ class Host(cr.Plugin, cr.Plugin.Type): ...@@ -97,6 +99,9 @@ class Host(cr.Plugin, cr.Plugin.Type):
p.terminate() p.terminate()
p.wait() p.wait()
exit(1) exit(1)
finally:
if silent:
out.close()
if return_status: if return_status:
return p.returncode return p.returncode
if p.returncode != 0: if p.returncode != 0:
...@@ -114,6 +119,10 @@ class Host(cr.Plugin, cr.Plugin.Type): ...@@ -114,6 +119,10 @@ class Host(cr.Plugin, cr.Plugin.Type):
def Execute(self, context, *command): def Execute(self, context, *command):
return self._Execute(context, command, shell=False) return self._Execute(context, command, shell=False)
@cr.Plugin.activemethod
def ExecuteSilently(self, context, *command):
return self._Execute(context, command, shell=False, silent=True)
@cr.Plugin.activemethod @cr.Plugin.activemethod
def CaptureShell(self, context, *command): def CaptureShell(self, context, *command):
return self._Execute(context, command, return self._Execute(context, command,
......
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