Graph scope options.
This commit is contained in:
parent
db9b3f25f9
commit
38d3e28527
|
@ -39,7 +39,9 @@ def runCmd(args: Args):
|
||||||
if componentSpec is None:
|
if componentSpec is None:
|
||||||
raise Exception("Component not specified")
|
raise Exception("Component not specified")
|
||||||
|
|
||||||
builder.build(componentSpec, targetSpec)
|
exe = builder.build(componentSpec, targetSpec)
|
||||||
|
|
||||||
|
shell.exec(exe)
|
||||||
|
|
||||||
|
|
||||||
cmds += [Cmd("r", "run", "Run the target", runCmd)]
|
cmds += [Cmd("r", "run", "Run the target", runCmd)]
|
||||||
|
@ -141,9 +143,12 @@ def graphCmd(args: Args):
|
||||||
targetSpec = cast(str, args.consumeOpt(
|
targetSpec = cast(str, args.consumeOpt(
|
||||||
"target", "host-" + shell.uname().machine))
|
"target", "host-" + shell.uname().machine))
|
||||||
|
|
||||||
|
scope: str | None = cast(str | None, args.tryConsumeOpt("scope"))
|
||||||
|
onlyLibs: bool = args.consumeOpt("only-libs", False) == True
|
||||||
|
|
||||||
context = contextFor(targetSpec, {})
|
context = contextFor(targetSpec, {})
|
||||||
|
|
||||||
graph.view(context)
|
graph.view(context, scope=scope, showExe=not onlyLibs)
|
||||||
|
|
||||||
|
|
||||||
cmds += [Cmd("g", "graph", "Show dependency graph", graphCmd)]
|
cmds += [Cmd("g", "graph", "Show dependency graph", graphCmd)]
|
||||||
|
|
|
@ -1,20 +1,36 @@
|
||||||
from graphviz import Digraph
|
from graphviz import Digraph
|
||||||
|
|
||||||
from osdk.context import Context
|
from osdk.context import Context
|
||||||
|
from osdk import vt100
|
||||||
|
|
||||||
|
|
||||||
def view(context: Context, showExe: bool = True):
|
def view(context: Context, scope: str | None = None, showExe: bool = True):
|
||||||
g = Digraph(context.target.id, filename='graph.gv')
|
g = Digraph(context.target.id, filename='graph.gv')
|
||||||
|
|
||||||
g.attr('graph', splines='ortho', rankdir='BT')
|
g.attr('graph', splines='ortho', rankdir='BT')
|
||||||
g.attr('node', shape='ellipse')
|
g.attr('node', shape='ellipse')
|
||||||
|
g.attr(
|
||||||
|
'graph', label=f"<<B>{scope or 'Full Dependency Graph'}</B><BR/>{context.target.id}>", labelloc='t')
|
||||||
|
|
||||||
|
scopeInstance = None
|
||||||
|
|
||||||
|
if scope is not None:
|
||||||
|
scopeInstance = context.componentByName(scope)
|
||||||
|
|
||||||
for instance in context.instances:
|
for instance in context.instances:
|
||||||
if not instance.isLib() and not showExe:
|
if not instance.isLib() and not showExe:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
g.node(instance.manifest.id, f"<<B>{instance.manifest.id}</B><BR/>{instance.manifest.decription}>",
|
if scopeInstance is not None and \
|
||||||
shape="plaintext", style="filled", fillcolor="lightgrey" if instance.isLib() else "lightblue")
|
instance.manifest.id != scope and \
|
||||||
|
instance.manifest.id not in scopeInstance.resolved:
|
||||||
|
continue
|
||||||
|
|
||||||
|
fillcolor = "lightgrey" if instance.isLib() else "lightblue"
|
||||||
|
shape = "plaintext" if not scope == instance.manifest.id else 'box'
|
||||||
|
|
||||||
|
g.node(instance.manifest.id, f"<<B>{instance.manifest.id}</B><BR/>{vt100.wordwrap(instance.manifest.decription, 40,newline='<BR/>')}>",
|
||||||
|
shape=shape, style="filled", fillcolor=fillcolor)
|
||||||
|
|
||||||
for req in instance.manifest.requires:
|
for req in instance.manifest.requires:
|
||||||
g.edge(instance.manifest.id, req)
|
g.edge(instance.manifest.id, req)
|
||||||
|
|
Loading…
Reference in a new issue