Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
add a python script to show the runtime packages' dependencies (#725)
Browse files Browse the repository at this point in the history
* add a python script to show the dependencies

* add the header line and modify the mod
  • Loading branch information
Guanqun Lu authored and gavofyork committed Sep 12, 2018
1 parent 7c52d44 commit b9849fe
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions scripts/runtime-dep.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,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("}")

0 comments on commit b9849fe

Please sign in to comment.