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) |