Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(541)

Unified Diff: scripts/slave/recipe_modules/chromium_checkout/api.py

Issue 2243853002: Drop unwanted dependencies on chromium_tests recipe module (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/build.git@master
Patch Set: TODO Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: scripts/slave/recipe_modules/chromium_checkout/api.py
diff --git a/scripts/slave/recipe_modules/chromium_checkout/api.py b/scripts/slave/recipe_modules/chromium_checkout/api.py
new file mode 100644
index 0000000000000000000000000000000000000000..2dda6654bc03c145c470b769f305670f8320b3b0
--- /dev/null
+++ b/scripts/slave/recipe_modules/chromium_checkout/api.py
@@ -0,0 +1,79 @@
+# Copyright 2016 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+from recipe_engine import recipe_api
+
+
+class ChromiumCheckoutApi(recipe_api.RecipeApi):
+ def __init__(self, *args, **kwargs):
+ super(ChromiumCheckoutApi, self).__init__(*args, **kwargs)
+ # Keep track of working directory (which contains the checkout).
+ # None means "default value".
+ self._working_dir = None
+
+ @property
+ def working_dir(self):
+ """Returns parent directory of the checkout.
+
+ Requires |ensure_checkout| to be called first.
+ """
+ # TODO(phajdan.jr): assert ensure_checkout has been called.
+ return self._working_dir
+
+ def get_checkout_dir(self, bot_config):
+ """Returns directory where checkout can be created.
+
+ None means to use default checkout directory.
+ """
+ try:
+ builder_cache = self.m.path['builder_cache']
+ except KeyError: # no-op if builder cache is not set up.
+ return None
+ else:
+ sanitized_buildername = ''.join(
+ c if c.isalnum() else '_' for c in self.m.properties['buildername'])
+ checkout_dir = builder_cache.join(
+ bot_config.get('checkout_dir', sanitized_buildername))
+ self.m.shutil.makedirs('checkout path', checkout_dir)
+ return checkout_dir
+
+ def get_files_affected_by_patch(self, relative_to='src/', cwd=None):
+ """Returns list of POSIX paths of files affected by patch for "analyze".
+
+ Paths are relative to `relative_to` which for analyze should be 'src/'.
+ """
+ patch_root = self.m.gclient.calculate_patch_root(
+ self.m.properties.get('patch_project'))
+ if not cwd and self.working_dir:
+ cwd = self.working_dir.join(patch_root)
+ files = self.m.tryserver.get_files_affected_by_patch(patch_root, cwd=cwd)
+ for i, path in enumerate(files):
+ path = str(path)
+ assert path.startswith(relative_to)
+ files[i] = path[len(relative_to):]
+ return files
+
+ def ensure_checkout(self, bot_config, root_solution_revision=None,
+ force=False):
+ """Wrapper for bot_update.ensure_checkout with chromium-specific additions.
+ """
+ if self.m.platform.is_win:
+ self.m.chromium.taskkill()
+
+ kwargs = {}
+ self._working_dir = self.get_checkout_dir(bot_config)
+ if self._working_dir:
+ kwargs['cwd'] = self._working_dir
+
+ # Bot Update re-uses the gclient configs.
+ update_step = self.m.bot_update.ensure_checkout(
+ patch_root=bot_config.get('patch_root'),
+ root_solution_revision=root_solution_revision,
+ clobber=bot_config.get('clobber', False),
+ force=force, **kwargs)
+ assert update_step.json.output['did_run']
+ # HACK(dnj): Remove after 'crbug.com/398105' has landed
+ self.m.chromium.set_build_properties(update_step.json.output['properties'])
+
+ return update_step
« no previous file with comments | « scripts/slave/recipe_modules/chromium_checkout/__init__.py ('k') | scripts/slave/recipe_modules/chromium_tests/__init__.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698