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

Unified Diff: recipe_engine/depgraph.py

Issue 1829403003: Add recipes to the depgraph command. (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/recipes-py@master
Patch Set: Created 4 years, 9 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
« no previous file with comments | « no previous file | recipes.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: recipe_engine/depgraph.py
diff --git a/recipe_engine/depgraph.py b/recipe_engine/depgraph.py
index e12ac38c37b5353bf2d227c8c2a1dd43e47d47f8..0aa5195ab7a7bb068394b7761b9291c34e0e0d85 100644
--- a/recipe_engine/depgraph.py
+++ b/recipe_engine/depgraph.py
@@ -20,29 +20,64 @@ _GRAPH_FOOTER = """}
"""
-def main(universe, ignore_packages, stdout):
- packages = {}
+def main(universe, own_package, ignore_packages, stdout):
+ modulify = lambda dep: 'module_' + clean(dep)
+ clean = lambda x: x.replace('.', '_dot_').replace('/', '_slash_').replace(
+ ':', '_colon_').replace('-', '_dash')
+
module_to_package = {}
edges = []
for package, module_name in universe.loop_over_recipe_modules():
mod = universe.load(package, module_name)
for dep in mod.LOADED_DEPS:
- edges.append((mod.NAME, dep))
- packages.setdefault(package.name, []).append(mod.NAME)
+ edges.append(((True, mod.NAME), (True, dep)))
Paweł Hajdan Jr. 2016/03/30 09:21:58 It's not clear what's the meaning of True here - c
module_to_package[mod.NAME] = package.name
+ recipe_to_package = {}
+ universe_view = loader.UniverseView(universe, own_package)
+ for path, recipe_name in universe_view.loop_over_recipes():
+ if 'example' in recipe_name:
Paweł Hajdan Jr. 2016/03/30 09:21:57 These are hacks. Can we just add command-line argu
+ continue
+
+ if 'clank' not in recipe_name:
+ continue
+ recipe = universe_view.load_recipe(recipe_name)
+ for dep in recipe.LOADED_DEPS:
+ edges.append(((False, recipe_name), (True, dep)))
Paweł Hajdan Jr. 2016/03/30 09:21:57 IMO recipes in the graph should be optional. I'd p
+ recipe_to_package[recipe_name] = package
+
print(_GRAPH_HEADER, file=stdout)
for edge in edges:
- if (module_to_package[edge[0]] in ignore_packages or
- module_to_package[edge[1]] in ignore_packages):
+ (first_mod, first_name), (second_mod, second_name) = edge
+
+ if first_mod:
+ if module_to_package[first_name] in ignore_packages:
+ continue
+ first_name = modulify(first_name)
Paweł Hajdan Jr. 2016/03/30 09:21:58 Why do we need calls to modulify? That's probably
+ else:
+ if recipe_to_package[first_name] in ignore_packages:
+ continue
+
+ if module_to_package[second_name] in ignore_packages:
continue
- print(' %s -> %s' % (edge[0], edge[1]), file=stdout)
+ second_name = modulify(second_name)
+
+ print(' %s -> %s' % (clean(first_name), second_name), file=stdout)
+
+ packages = {}
+ for module, package in module_to_package.iteritems():
+ packages.setdefault(package, []).append(module)
for package, modules in packages.iteritems():
if package in ignore_packages:
continue
# The "cluster_" prefix has magic meaning for graphviz and makes it
# draw a box around the subgraph.
print(' subgraph "cluster_%s" { label="%s"; %s; }' % (
- package, package, '; '.join(modules)), file=stdout)
+ package, package, '; '.join(
+ modulify(x) for x in modules)), file=stdout)
+
+ recipe_names = [clean(name) for name in recipe_to_package.keys()]
+ print(' subgraph "cluster_recipes" { label="recipes"; %s; }' % (
+ '; '.join(recipe_names)), file=stdout)
print(_GRAPH_FOOTER, file=stdout)
« no previous file with comments | « no previous file | recipes.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698