| """Build step class for CCStudio build.""" |
| |
| from __future__ import absolute_import |
| import os |
| |
| from slave import base_step |
| |
| class CCStudioStep(base_step.BaseStep): |
| """Build step class for CCStudio build.""" |
| |
| def __init__(self, build_name, name='ccstudio build', **kwargs): |
| """Create a CCStudioStep instance. |
| |
| Args: |
| build_name: Name of build (e.g. abbey-eng). |
| name: User-visible name of this step. |
| **kwargs: Any additional args to pass to BaseStep. |
| """ |
| base_step.BaseStep.__init__(self, name=name, **kwargs) |
| self._build_name = build_name |
| |
| def _build(self): |
| """Build |build_name| image by CCStudioStep. |
| |
| Returns: |
| True if image was built successfully; False if failed. |
| """ |
| venv_root = self.get_step_data('virtual_env_root', '/usr') |
| python_path = os.path.join(venv_root, 'bin') |
| ccs_dir = os.path.expanduser('~/ccstudio/ccs/eclipse') |
| src_dir = self.get_project_path('abbey') |
| dist_dir = self.get_gcs_dir() |
| command = [ |
| os.path.join(src_dir, 'build', 'build.sh'), |
| '--python_path={python_path}'.format(python_path=python_path), |
| '--ccs_dir={ccs_dir}'.format(ccs_dir=ccs_dir), |
| '--src_dir={src_dir}'.format(src_dir=src_dir), |
| '--dist_dir={dist_dir}'.format(dist_dir=dist_dir), |
| '--build_name={build_name}'.format(build_name=self._build_name), |
| ] |
| returncode, stdout, stderr = self.exec_subprocess(command) |
| if returncode != 0: |
| self._error_processor(stdout, stderr) |
| return False |
| return True |
| |
| def run(self): |
| """Build images. |
| |
| Returns: |
| True if there were no errors. |
| """ |
| return self._build() |
| |
| def _error_processor(self, stdout, stderr): |
| # TODO(b/141637066): Improve error handling |
| if stdout: |
| self.add_review({'message': stdout}) |
| if stderr: |
| self.add_review({'message': stderr}) |