OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
| 5 import contextlib |
| 6 import json |
5 import os | 7 import os |
6 import re | 8 import re |
7 | 9 |
8 from recipe_engine import recipe_api | 10 from recipe_engine import recipe_api |
| 11 from recipe_engine import util as recipe_util |
9 | 12 |
10 class FilterApi(recipe_api.RecipeApi): | 13 class FilterApi(recipe_api.RecipeApi): |
11 def __init__(self, **kwargs): | 14 def __init__(self, **kwargs): |
12 super(FilterApi, self).__init__(**kwargs) | 15 super(FilterApi, self).__init__(**kwargs) |
13 self._test_targets = [] | 16 self._test_targets = [] |
14 self._compile_targets = [] | 17 self._compile_targets = [] |
15 self._paths = [] | 18 self._paths = [] |
16 | 19 |
17 def __is_path_in_regex_list(self, path, regexes): | 20 def __is_path_in_regex_list(self, path, regexes): |
18 """Returns true if |path| matches any of the regular expressions in | 21 """Returns true if |path| matches any of the regular expressions in |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 # TODO(dpranke) crbug.com/557505 - we need to not prune meta | 232 # TODO(dpranke) crbug.com/557505 - we need to not prune meta |
230 # targets that are part of 'test_targets', because otherwise | 233 # targets that are part of 'test_targets', because otherwise |
231 # we might not actually build all of the binaries needed for | 234 # we might not actually build all of the binaries needed for |
232 # a given test, even if they aren't affected by the patch. | 235 # a given test, even if they aren't affected by the patch. |
233 # Until the GYP code is updated, we will merge the returned | 236 # Until the GYP code is updated, we will merge the returned |
234 # test_targets into compile_targets to be safe. | 237 # test_targets into compile_targets to be safe. |
235 self._compile_targets = sorted(set(self._compile_targets + | 238 self._compile_targets = sorted(set(self._compile_targets + |
236 self._test_targets)) | 239 self._test_targets)) |
237 else: | 240 else: |
238 step_result.presentation.step_text = 'No compile necessary' | 241 step_result.presentation.step_text = 'No compile necessary' |
| 242 |
| 243 # TODO(phajdan.jr): Merge with does_patch_require_compile. |
| 244 def analyze(self, affected_files, test_targets, additional_compile_targets, |
| 245 config_file_name, mb_mastername=None, mb_buildername=None, |
| 246 additional_names=None): |
| 247 """Runs "analyze" step to determine targets affected by the patch. |
| 248 |
| 249 Returns a tuple of: |
| 250 - list of targets that are needed to run tests (see filter recipe module) |
| 251 - list of targets that need to be compiled (see filter recipe module)""" |
| 252 |
| 253 if additional_names is None: |
| 254 additional_names = ['chromium'] |
| 255 |
| 256 use_mb = (self.m.chromium.c.project_generator.tool == 'mb') |
| 257 build_output_dir = '//out/%s' % self.m.chromium.c.build_config_fs |
| 258 self.does_patch_require_compile( |
| 259 affected_files, |
| 260 test_targets=test_targets, |
| 261 additional_compile_targets=additional_compile_targets, |
| 262 additional_names=additional_names, |
| 263 config_file_name=config_file_name, |
| 264 use_mb=use_mb, |
| 265 mb_mastername=mb_mastername, |
| 266 mb_buildername=mb_buildername, |
| 267 build_output_dir=build_output_dir, |
| 268 cros_board=self.m.chromium.c.TARGET_CROS_BOARD) |
| 269 |
| 270 compile_targets = self.compile_targets[:] |
| 271 |
| 272 # Emit more detailed output useful for debugging. |
| 273 analyze_details = { |
| 274 'test_targets': test_targets, |
| 275 'additional_compile_targets': additional_compile_targets, |
| 276 'self.m.filter.compile_targets': self.compile_targets, |
| 277 'self.m.filter.test_targets': self.test_targets, |
| 278 'compile_targets': compile_targets, |
| 279 } |
| 280 with contextlib.closing(recipe_util.StringListIO()) as listio: |
| 281 json.dump(analyze_details, listio, indent=2, sort_keys=True) |
| 282 step_result = self.m.step.active_result |
| 283 step_result.presentation.logs['analyze_details'] = listio.lines |
| 284 |
| 285 return self.test_targets, compile_targets |
OLD | NEW |