| # Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file |
| # for details. All rights reserved. Use of this source code is governed by a |
| # BSD-style license that can be found in the LICENSE file. |
| |
| from recipe_engine import recipe_api |
| |
| class BuildApi(recipe_api.RecipeApi): |
| """Recipe module for building the Dart SDK with and without RBE.""" |
| |
| def __init__(self, properties, *args, **kwargs): |
| super(BuildApi, self).__init__(*args, **kwargs) |
| self._timeout = properties.timeout or 50 * 60 # 50 minutes |
| self._rbe_enabled = not properties.disable_goma |
| |
| def build(self, name='build dart', args=None): |
| """Builds dart using the specified args""" |
| if not args: # pragma: no cover |
| args = [] |
| if not self._use_rbe and '--no-goma' not in args: |
| args = args + ['--no-goma'] |
| with self.m.depot_tools.on_path(), self.m.context( |
| cwd=self.m.path['checkout'], infra_steps=False, env=self._build_env): |
| build_py = self.m.path['checkout'].join('tools', 'build.py') |
| self.m.step( |
| name, ['python3', '-u', build_py] + args, timeout=self._timeout) |
| |
| def gn(self, name='gn', args=None): |
| """Runs gn.py using the specified args""" |
| with self.m.context(env=self._build_env): |
| if not self._use_rbe and '--no-goma' not in args: |
| args = args + ['--no-goma'] |
| gn_py = self.m.path['checkout'].join('tools', 'gn.py') |
| self.m.step(name, ['python3', '-u', gn_py] + args) |
| |
| @property |
| def _use_rbe(self): |
| return self._rbe_enabled and self.m.path.exists( |
| self.m.path['checkout'].join('buildtools').join('reclient')) |
| |
| @property |
| def _build_env(self): |
| return {} if not self._use_rbe else { |
| 'RBE': '1', |
| 'RBE_proxy_log_dir': self.m.path['cleanup'], |
| } |