| """Make clean step.""" |
| |
| from __future__ import absolute_import |
| import logging |
| |
| from helpers import branch_utils |
| from slave import base_step |
| |
| |
| class MakeCleanStep(base_step.BaseStep): |
| """Make clean step class.""" |
| |
| def __init__(self, clean_dir=None, **kwargs): |
| """Creates a MakeCleanStep instance. |
| |
| Args: |
| clean_dir: Dir where to run make clean |
| **kwargs: Any additional args to pass to BaseStep. |
| """ |
| self._clean_dir = clean_dir |
| base_step.BaseStep.__init__(self, name='clean', **kwargs) |
| |
| def run(self): |
| # Do all the cleaning. |
| command = ['make', 'clean'] |
| returncode, _, _ = self.exec_subprocess(command, cwd=self._clean_dir) |
| |
| return returncode == 0 |
| |
| |
| class MakeDistCleanStep(base_step.BaseStep): |
| """Make clean step class.""" |
| |
| def __init__(self, **kwargs): |
| """Creates a MakeCleanStep instance. |
| |
| Args: |
| **kwargs: Any additional args to pass to BaseStep. |
| """ |
| base_step.BaseStep.__init__(self, name='distclean', **kwargs) |
| self._clean_project = self.get_property('make_distclean_project') |
| self._min_branch = self.get_property('make_distclean_min_branch') |
| |
| def run(self): |
| # Do all the cleaning. |
| command = ['make', 'distclean'] |
| |
| if not branch_utils.is_branch_equal_to_or_later_than( |
| self.manifest_branch, self._min_branch): |
| logging.info('Branch is older than %s, nothing to do.', self._min_branch) |
| return True |
| |
| if self._clean_project: |
| clean_dir = self.get_project_path(self._clean_project) |
| else: |
| clean_dir = None |
| returncode, _, _ = self.exec_subprocess( |
| command, |
| cwd=clean_dir, |
| env={"VERBOSE": "1"}) |
| |
| return returncode == 0 |