forked from paritytech/substrate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
runtime-dep.py
executable file
·34 lines (23 loc) · 933 Bytes
/
runtime-dep.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env python3
# To run this script, you need to install the 'toml' python package and install the 'graphviz' package:
# pip install toml
# sudo apt-get install graphviz
# the first parameter is the runtime folder
# python ./scripts/runtime-dep.py ./substrate/runtime | dot -Tpng -o output.png
import sys
import os
import toml
if len(sys.argv) != 2:
print("needs the runtime folder.")
sys.exit(-1)
runtime_dir = sys.argv[1]
files = [os.path.join(runtime_dir, f, 'Cargo.toml') for f in os.listdir(runtime_dir) if os.path.isfile(os.path.join(runtime_dir, f, 'Cargo.toml')) and f != 'example']
print("digraph G {")
PREFIX = "substrate-runtime-"
for f in files:
manifest = toml.load(f)
package_name = manifest['package']['name']
deps = [d for d in manifest['dependencies'].keys() if d.startswith(PREFIX)]
for d in deps:
print(" \"{}\" -> \"{}\";".format(package_name, d))
print("}")