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

Unified Diff: scripts/slave/recipe_modules/goma/api.py

Issue 2480193002: Stop to use contextmanager for goma.build_with_goma (Closed)
Patch Set: update Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: scripts/slave/recipe_modules/goma/api.py
diff --git a/scripts/slave/recipe_modules/goma/api.py b/scripts/slave/recipe_modules/goma/api.py
index ca0934597f11dcf24806afe7a49d83cd87b0ea80..3c4374d14b1716ad4590e9706ea30d30d7719ad9 100644
--- a/scripts/slave/recipe_modules/goma/api.py
+++ b/scripts/slave/recipe_modules/goma/api.py
@@ -85,7 +85,11 @@ print jobs
Args:
command: List of command line arg.
+
+ Returns:
+ list(string): Command line args parallel option removed.
"""
+ command = command[:]
parallel_flag_regexp = re.compile('-j\d*')
for i in range(len(command)):
if (isinstance(command[i], str) and
@@ -93,7 +97,8 @@ print jobs
if command[i] == '-j':
command.pop(i + 1)
command.pop(i)
- return
+ break
+ return command
def ensure_goma(self, canary=False):
with self.m.step.nest('ensure_goma'):
@@ -314,42 +319,48 @@ print jobs
@contextmanager
def build_with_goma(self, ninja_log_outdir=None, ninja_log_compiler=None,
- ninja_log_command=None, env=None,
+ ninja_command=None, env=None,
allow_build_without_goma=False):
"""Make context wrapping goma start/stop.
- Args ninja_log_* are NOT used to run actual build in this context.
- These args are only used to collect log and upload them.
-
Args:
ninja_log_outdir: Directory of ninja log. (e.g. "out/Release")
ninja_log_compiler: Compiler used in ninja. (e.g. "clang")
- ninja_log_command: Command used for build.
- This is used only to be sent as part of log,
- NOT used to run actual build.
- (e.g. ['ninja', '-C', 'out/Release', '-j', '100'])
+ ninja_command: Command used for build.
+ This is used to be sent as part of log.
+ This function does NOT run actual build.
ukai 2016/11/10 02:47:02 it returns this, and if goma is available add -j o
tikuta 2016/11/11 08:14:55 Done.
+ (e.g. ['ninja', '-C', 'out/Release'])
env: Environment controlling goma behavior.
This should be used for ninja if allow_build_without_goma is True.
Otherwise, only used for goma behavior control.
allow_build_without_goma (bool):
If this is not True, goma starting failure is ignored.
- This argument should be used with env.
- If starting goma fails, env and ninja_log_command are modified.
+ Use returned env_update and ninja_command for the cases.
+
+ Returns:
+ (env_update, ninja_command):
+ Please use env_update and ninja_command
+ for ninja in build_with_goma context
+ (e.g. ninja_env.update(env_update)).
+ Appropriate values are set depends on goma status.
Raises:
StepFailure or InfraFailure if it fails to build.
"""
ninja_log_exit_status = 0
+ if ninja_log_command is None:
+ ninja_log_command = []
+ ninja_command = self.remove_j_flag(ninja_log_command)
if allow_build_without_goma:
assert(env is not None)
+ env = env.copy()
+
try:
self.start(env)
except:
- env['GOMA_DISABLED'] = 'true'
- self.remove_j_flag(ninja_log_command)
try:
- yield
+ yield ({'GOMA_DISABLED':'true'}, ninja_command)
except self.m.step.StepFailure as e: # pragma: no cover
ninja_log_exit_status = e.retcode
raise e
@@ -359,15 +370,17 @@ print jobs
finally:
self._upload_logs(ninja_log_outdir=ninja_log_outdir,
ninja_log_compiler=ninja_log_compiler,
- ninja_log_command=ninja_log_command,
+ ninja_log_command=ninja_command,
ninja_log_exit_status=ninja_log_exit_status,
name='upload log goma start failed')
return
else:
self.start(env)
+ ninja_command.extend(['-j', self.recommended_goma_jobs])
ukai 2016/11/10 02:47:02 prefer -j option before targets on command line.
tikuta 2016/11/11 08:14:55 Done.
+
try:
- yield
+ yield ({}, ninja_command)
except self.m.step.StepFailure as e: # pragma: no cover
ninja_log_exit_status = e.retcode
raise e
@@ -377,5 +390,5 @@ print jobs
finally:
self.stop(ninja_log_outdir=ninja_log_outdir,
ninja_log_compiler=ninja_log_compiler,
- ninja_log_command=ninja_log_command,
+ ninja_log_command=ninja_command,
ninja_log_exit_status=ninja_log_exit_status)

Powered by Google App Engine
This is Rietveld 408576698