blob: 3ca5071581dd0af287c124a60f6a91439ceb2e2b [file]
# 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, checkout_dir, 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=checkout_dir, infra_steps=False, env=self._build_env):
build_py = checkout_dir / 'tools/build.py'
self.m.step(
name, ['python3', '-u', build_py] + args, timeout=self._timeout)
def gn(self, checkout_dir, name='gn', args=None):
"""Runs gn.py using the specified args"""
with self.m.context(env=self._build_env):
gn_py = checkout_dir / 'tools/gn.py'
self.m.step(name, ['python3', '-u', gn_py] + args)
@property
def _build_env(self):
return {} if not self._rbe_enabled else {
'RBE': '1',
'RBE_exec_strategy': 'remote_local_fallback',
'RBE_proxy_log_dir': self.m.path.cleanup_dir,
'RBE_use_gce_credentials': 'true',
'RBE_use_application_default_credentials': 'false',
}