| """Build step class for running partner build checks on source tree.""" |
| |
| from __future__ import absolute_import |
| import logging |
| import os |
| |
| from slave import base_step |
| |
| _PARTNER_BUILD_ERROR_MSG = ('Your change causes cast_shell to depend on ' |
| 'libcutil. This is not acceptable for partner ' |
| 'builds. Please rework your CL!') |
| |
| _READELF_FAILURE_MSG = ('readelf returned failure. Please make sure cast_shell' |
| 'is built and readelf is installed!') |
| |
| |
| class PartnerBuildCheckStep(base_step.BaseStep): |
| """Build step class for checking GN desc.""" |
| |
| def __init__(self, build_name, build_flavor, **kwargs): |
| """Creates a PartnerBuildCheckStep instance. |
| |
| This step requires ota build to be completed since it checks on cast_shell |
| executable. |
| |
| Args: |
| build_name: Name of build (e.g. pepperoni-eng, tvdefault-eng). |
| build_flavor: Flavor of build ('debug' or 'release'). |
| **kwargs: Any additional args to pass to BaseStep. |
| """ |
| base_step.BaseStep.__init__(self, name='partner build check', **kwargs) |
| |
| self._product = build_name.split('-')[0] |
| self._build_flavor = build_flavor |
| |
| def run(self): |
| """Runs gn desc on all changed GN files for the current commit. |
| |
| Sets a build property "review" with the output. |
| |
| Returns: |
| True iff there were no issues in partner build. |
| """ |
| cast_shell_path = os.path.join('chromium', 'src', |
| 'out_chromecast_' + self._product, |
| self._build_flavor, |
| 'cast_shell') |
| if not os.path.isfile(cast_shell_path): |
| logging.info('cast_shell is not built, cannot check partner build') |
| self.add_review({'message': 'Ota build did not complete'}) |
| return False |
| |
| command = ['readelf', |
| '-d', |
| cast_shell_path] |
| |
| returncode, stdout, _ = self.exec_subprocess(command) |
| |
| if returncode != 0: |
| self.add_review({'message': _READELF_FAILURE_MSG}) |
| return False |
| |
| if 'libcutil' in stdout: |
| self.add_review({'message': _PARTNER_BUILD_ERROR_MSG}) |
| return False |
| |
| return True |