blob: 6a2c07eb9d7c9f67e47e556f43c2ef2037d5f07a [file] [log] [blame]
# 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_rbe
def build(self, name='build dart', args=None):
"""Builds dart using the specified args"""
if not args: # pragma: no cover
args = []
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):
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_exec_strategy': 'remote',
'RBE_proxy_log_dir': self.m.path['cleanup'],
'RBE_use_gce_credentials': 'true',
'RBE_use_application_default_credentials': 'false',
}