Chromium Code Reviews| 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..047ba4350d91b41bc4290c62a5f33769e7c33fdf 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) |
|
shinyak
2016/11/14 08:14:08
I didn't notice before, but `ninja -j` could cause
tikuta
2016/11/14 11:22:02
If there is no arg after '-j' option, IndexError i
|
| command.pop(i) |
| - return |
| + break |
| + return command |
| def ensure_goma(self, canary=False): |
| with self.m.step.nest('ensure_goma'): |
| @@ -314,42 +319,50 @@ 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. |
| + ninja_command with -j option is returned |
| + if goma starts successfully. |
| + (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 |
|
Paweł Hajdan Jr.
2016/11/14 09:33:23
Some changes in this patch don't seem to follow th
tikuta
2016/11/14 11:22:02
When I made build_with_goma, I thought we need to
tikuta
2016/11/15 07:07:10
Hmm, there is a recipe that does not use ninja.
ht
|
| + 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_command is None: |
|
shinyak
2016/11/14 08:14:08
Can we generate meaningful value when ninja_comman
tikuta
2016/11/15 07:07:10
There is a recipe not using ninja, so ninja_comman
shinyak
2016/11/15 07:27:19
Then ninja_command in L386 could be ['-j', '50'] o
tikuta
2016/11/16 06:51:51
I'm not sure what is the best way to handle such c
|
| + ninja_command = [] |
| + ninja_command = self.remove_j_flag(ninja_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 +372,18 @@ 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, args = ninja_command[:1], ninja_command[1:] |
| + ninja_command = ninja + ['-j', self.recommended_goma_jobs] + args |
| + |
| 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 +393,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) |