| """Recipe for building gotham.""" |
| import os |
| |
| from slave import base_recipe |
| from slave.step import gotham_build_step |
| from slave.step import make_clean_step |
| from slave.step import py_env_setup_step |
| from slave.test import test_generator |
| |
| |
| # When adding new boards they also need to be added to: |
| # - build_specs.json |
| # - build_details.protoascii (Staging & Prod) |
| # - build_rules.protoascii (Staging & Prod) |
| # - run 'cq/scripts/tools/recipes_test.py --train' to |
| # generate recipe_expectation/*.json |
| |
| BUILD_CONFIGS = { |
| # Legacy naming convention. |
| 'gotham_bootloader': { |
| 'build_name': 'bootloader', |
| 'board': 'gotham_bootloader', |
| }, |
| 'gotham_bootloader_16mb': { |
| 'build_name': 'bootloader', |
| 'board': 'gotham_bootloader_16mb', |
| }, |
| 'gotham_eng': { |
| 'build_name': 'eng', |
| 'board': '', |
| }, |
| 'gotham_eng-arkham2': { |
| 'build_name': 'eng', |
| 'board': 'arkham2', |
| }, |
| 'gotham_eng-gotham_evt': { |
| 'build_name': 'eng', |
| 'board': 'gotham_evt', |
| }, |
| 'gotham_eng-gotham_p2': { |
| 'build_name': 'eng', |
| 'board': 'gotham_p2', |
| }, |
| 'gotham_factory': { |
| 'build_name': 'factory', |
| 'board': '', |
| }, |
| 'gotham_factory-arkham2': { |
| 'build_name': 'factory', |
| 'board': 'arkham2', |
| }, |
| 'gotham_factory-gotham_evt': { |
| 'build_name': 'factory', |
| 'board': 'gotham_evt', |
| }, |
| 'gotham_factory-gotham_p2': { |
| 'build_name': 'factory', |
| 'board': 'gotham_p2', |
| }, |
| 'gotham_test': { |
| 'build_name': 'test', |
| 'board': '', |
| }, |
| 'gotham_test-arkham2': { |
| 'build_name': 'test', |
| 'board': 'arkham2', |
| }, |
| 'gotham_test-gotham_evt': { |
| 'build_name': 'test', |
| 'board': 'gotham_evt', |
| }, |
| 'gotham_test-gotham_p2': { |
| 'build_name': 'test', |
| 'board': 'gotham_p2', |
| }, |
| 'gotham_test-host': { |
| 'build_name': 'test', |
| 'board': 'host', |
| }, |
| |
| # Current naming convention. |
| 'gotham_mcu-bootloader-eng': { |
| 'build_name': 'bootloader-eng', |
| 'board': '', |
| }, |
| 'gotham_mcu-bootloader-user': { |
| 'build_name': 'bootloader-user', |
| 'board': '', |
| }, |
| 'gotham_mcu-eng': { |
| 'build_name': 'eng', |
| 'board': '', |
| }, |
| 'gotham_mcu-eng-gotham_dvt': { |
| 'build_name': 'eng', |
| 'board': 'gotham_dvt', |
| }, |
| 'gotham_mcu-eng-metrics-gotham_dvt': { |
| 'build_name': 'metrics', |
| 'board': '', |
| }, |
| 'gotham_mcu-eng-gotham_evt': { |
| 'build_name': 'eng', |
| 'board': 'gotham_evt', |
| }, |
| 'gotham_mcu-user': { |
| 'build_name': 'user', |
| 'board': '', |
| }, |
| 'gotham_mcu-user-gotham_dvt': { |
| 'build_name': 'user', |
| 'board': 'gotham_dvt', |
| }, |
| 'gotham_mcu-user-gotham_evt': { |
| 'build_name': 'user', |
| 'board': 'gotham_evt', |
| }, |
| 'gotham_mcu-fsi-eng': { |
| 'build_name': 'fsi-eng', |
| 'board': '', |
| }, |
| 'gotham_mcu-fsi-eng-gotham_dvt': { |
| 'build_name': 'fsi-eng', |
| 'board': 'gotham_dvt', |
| }, |
| 'gotham_mcu-fsi-eng-gothm_evt': { |
| 'build_name': 'fsi-eng', |
| 'board': 'gothm_evt', |
| }, |
| 'gotham_mcu-fsi-user': { |
| 'build_name': 'fsi-user', |
| 'board': '', |
| }, |
| 'gotham_mcu-fsi-user-gotham_dvt': { |
| 'build_name': 'fsi-user', |
| 'board': 'gotham_dvt', |
| }, |
| 'gotham_mcu-fsi-user-gotham_evt': { |
| 'build_name': 'fsi-user', |
| 'board': 'gotham_evt', |
| }, |
| 'gotham_mcu-factory': { |
| 'build_name': 'factory', |
| 'board': '', |
| }, |
| 'gotham_mcu-factory-arkham2': { |
| 'build_name': 'factory', |
| 'board': 'arkham2', |
| }, |
| 'gotham_mcu-factory-gotham_dvt': { |
| 'build_name': 'factory', |
| 'board': 'gotham_dvt', |
| }, |
| 'gotham_mcu-factory-gotham_evt': { |
| 'build_name': 'factory', |
| 'board': 'gotham_evt', |
| }, |
| 'gotham_mcu-rma-unlock': { |
| 'build_name': 'rma-unlock', |
| 'board': '', |
| }, |
| 'gotham_mcu-test': { |
| 'build_name': 'test', |
| 'board': '', |
| }, |
| 'gotham_mcu-test-gotham_dvt': { |
| 'build_name': 'test', |
| 'board': 'gotham_dvt', |
| }, |
| 'gotham_mcu-test-gotham_evt': { |
| 'build_name': 'test', |
| 'board': 'gotham_evt', |
| }, |
| 'gotham_mcu-test-host': { |
| 'build_name': 'test', |
| 'board': 'host', |
| }, |
| 'gotham_linux_x64': { |
| 'build_name': 'linux', |
| 'board': '', |
| }, |
| 'gotham_mcu-dynamic-analysis': { |
| 'build_name': 'dynamic-analysis', |
| 'board': '', |
| } |
| } |
| |
| |
| def GetValidBuildNames(): |
| return list(BUILD_CONFIGS.keys()) |
| |
| |
| def CreateRecipe(build_name: str, **kwargs): |
| return GothamRecipe(build_name, **kwargs) |
| |
| |
| class GothamRecipe(base_recipe.BaseRecipe): |
| """Recipe to build gotham using the build_gotham.""" |
| |
| def __init__(self, build_name, **kwargs): |
| prop = kwargs.get('properties', {}) |
| prop['skip_gclient'] = True |
| if 'properties' not in kwargs: |
| kwargs['properties'] = prop |
| self._executor = kwargs['executor'] |
| base_recipe.BaseRecipe.__init__(self, **kwargs) |
| |
| self._build_name = BUILD_CONFIGS[build_name]['build_name'] |
| self._board = BUILD_CONFIGS[build_name]['board'] |
| |
| def _get_clean_dir(self): |
| if 'bootloader' in self._build_name: |
| return 'gotham/source/bootloader' |
| if 'factory' in self._build_name: |
| return 'gotham/source/fct' |
| if 'rma-unlock' in self._build_name: |
| return 'gotham/source/rma_unlock' |
| return 'gotham/source/app' |
| |
| def get_steps(self): |
| clean_dir = self._get_clean_dir() |
| requirements_path = os.path.join('tools/build_tools/', 'requires.txt') |
| gotham_python_packages = 'team-gotham/python_packages' |
| |
| steps = [] |
| |
| # TODO(b/147378899, b/147672428) include landmine support |
| if self.build_system == 'catabuilder': |
| steps.append(make_clean_step.MakeCleanStep( |
| clean_dir=clean_dir, **self._step_kwargs)) |
| |
| steps.extend([ |
| py_env_setup_step.PyEnvSetupStep( |
| local_packages_dir=gotham_python_packages, |
| py3=True, |
| requirements_path=requirements_path, |
| requirements_project='gotham-cr/gotham', |
| **self._step_kwargs), |
| gotham_build_step.GothamBuildStep( |
| build_name=self._build_name, |
| board=self._board, |
| name='build', |
| cwd='gotham/tools/buildbot/', |
| **self._step_kwargs) |
| ]) |
| |
| return steps |
| |