From 31ceb8495940553650b43034c4f4c31813d36ca4 Mon Sep 17 00:00:00 2001 From: Guanqun Lu Date: Wed, 12 Sep 2018 16:27:10 +0800 Subject: [PATCH 1/2] add a python script to show the dependencies --- scripts/runtime-dep.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 scripts/runtime-dep.py diff --git a/scripts/runtime-dep.py b/scripts/runtime-dep.py new file mode 100644 index 0000000000000..c6e28ff6cfe68 --- /dev/null +++ b/scripts/runtime-dep.py @@ -0,0 +1,32 @@ +# 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("}") From 9d2631c6af2b1c235d451db1d198c86d7b8eff2e Mon Sep 17 00:00:00 2001 From: Guanqun Lu Date: Wed, 12 Sep 2018 19:40:47 +0800 Subject: [PATCH 2/2] add the header line and modify the mod --- scripts/runtime-dep.py | 2 ++ 1 file changed, 2 insertions(+) mode change 100644 => 100755 scripts/runtime-dep.py diff --git a/scripts/runtime-dep.py b/scripts/runtime-dep.py old mode 100644 new mode 100755 index c6e28ff6cfe68..1d0c42b2f57e8 --- a/scripts/runtime-dep.py +++ b/scripts/runtime-dep.py @@ -1,3 +1,5 @@ +#!/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