Index: recipe_modules/gclient/api.py |
diff --git a/recipe_modules/gclient/api.py b/recipe_modules/gclient/api.py |
index 2d9ed949f5f72d6c78cd16552648245fc63fce81..41d7e14e8855f5083137f3b33b6620ca8e833f0c 100644 |
--- a/recipe_modules/gclient/api.py |
+++ b/recipe_modules/gclient/api.py |
@@ -336,3 +336,28 @@ class GclientApi(recipe_api.RecipeApi): |
args=[self.m.path['slave_build']], |
infra_step=True, |
) |
+ |
+ def calculate_patch_root(self, patch_project, gclient_config=None): |
+ """Returns path where a patch should be applied to based patch_project. |
+ |
+ Maps "patch_project" to a path of directories relative to checkout's root, |
+ which describe where to place the patch. |
+ |
+ For now, considers only first solution (c.solutions[0]), but in theory can |
+ be extended to all of them. |
+ |
+ See patch_projects solution config property. |
+ |
+ Returns: |
+ Relative path, including solution's root. |
+ If patch_project is not given or not recognized, it'll be just first |
+ solution root. |
+ """ |
+ cfg = gclient_config or self.c |
+ root, _ = cfg.solutions[0].patch_projects.get(patch_project, ('', '')) |
Michael Achenbach
2016/04/25 09:32:42
solutions[0] goes away when making the dict global
tandrii(chromium)
2016/04/25 11:39:50
Done.
|
+ if root: |
+ # Note, that c.solutions[i].patch_projects contains patch roots as |
+ # /-separated path, which are roots of the respective project repos. |
+ return self.m.path.join(*root.split('/')) |
+ # Default case - assume patch is for first solution. |
+ return cfg.solutions[0].name |