Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
H
Hdlmake
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
15
Issues
15
List
Board
Labels
Milestones
Merge Requests
4
Merge Requests
4
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
Hdlmake
Commits
3c9acec4
Commit
3c9acec4
authored
Jun 12, 2017
by
Javier D. Garcia-Lasheras
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improved functionality for the web based GUI interface
parent
267e6232
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
64 additions
and
62 deletions
+64
-62
__main__.py
hdlmake/__main__.py
+5
-18
tree.py
hdlmake/action/tree.py
+59
-44
No files found.
hdlmake/__main__.py
View file @
3c9acec4
...
...
@@ -145,24 +145,11 @@ def _get_parser():
action
=
"store_true"
,
dest
=
"withfiles"
)
tree
.
add_argument
(
"--graphviz"
,
dest
=
"graphviz"
,
default
=
None
,
help
=
"qctivate graphviz and specify the program to be used to plot "
"the graph (twopi, gvcolor, wc, ccomps, tred, sccmap, fdp, "
"circo, neato, acyclic, nop, gvpr, dot, sfdp)"
)
tree
.
add_argument
(
"--web"
,
help
=
"export the tree hierarchy in a web friendly JSON format"
,
default
=
False
,
action
=
"store_true"
,
dest
=
"web"
)
tree
.
add_argument
(
"--solved"
,
help
=
"enable the parser"
,
default
=
False
,
action
=
"store_true"
,
dest
=
"solved"
)
"--mode"
,
dest
=
"mode"
,
default
=
"mods"
,
help
=
"set the working mode for the tree generator: "
"(mods, dfs, bfs)"
)
subparsers
.
add_parser
(
"manifest-help"
,
help
=
"print manifest file variables description"
)
...
...
hdlmake/action/tree.py
View file @
3c9acec4
...
...
@@ -27,6 +27,7 @@ from hdlmake.util import path
import
logging
from
.action
import
Action
from
hdlmake.dep_file
import
DepFile
class
ActionTree
(
Action
):
...
...
@@ -38,41 +39,22 @@ class ActionTree(Action):
def
_generate_tree_web
(
self
,
hierarchy
,
top_id
):
"""Create a JSON file containing the graph hierarchy from pool"""
if
self
.
options
.
web
:
try
:
import
json
from
networkx.readwrite
import
json_graph
except
ImportError
as
error_import
:
logging
.
error
(
error_import
)
quit
()
data
=
json_graph
.
tree_data
(
hierarchy
,
root
=
top_id
)
json_string
=
json
.
dumps
(
data
)
json_file
=
open
(
"hierarchy.json"
,
"w"
)
json_file
.
write
(
json_string
)
json_file
.
close
()
def
_generate_tree_graphviz
(
self
,
hierarchy
,
top_id
):
"""Define the program used to write the graphviz:
Program should be one of:
twopi, gvcolor, wc, ccomps, tred, sccmap, fdp,
circo, neato, acyclic, nop, gvpr, dot, sfdp
"""
if
self
.
options
.
graphviz
:
try
:
import
matplotlib.pyplot
as
plt
import
networkx
as
nx
except
ImportError
as
error_import
:
logging
.
error
(
error_import
)
quit
()
pos
=
nx
.
graphviz_layout
(
hierarchy
,
prog
=
self
.
options
.
graphviz
,
root
=
top_id
)
nx
.
draw
(
hierarchy
,
pos
,
with_labels
=
True
,
alpha
=
0.5
,
node_size
=
100
)
plt
.
savefig
(
"hierarchy.png"
)
plt
.
show
()
try
:
import
json
import
networkx
as
nx
from
networkx.readwrite
import
json_graph
except
ImportError
as
error_import
:
logging
.
error
(
error_import
)
quit
()
if
self
.
options
.
mode
==
'dfs'
:
hierarchy
=
nx
.
dfs_tree
(
hierarchy
,
top_id
)
elif
self
.
options
.
mode
==
'bfs'
:
hierarchy
=
nx
.
bfs_tree
(
hierarchy
,
top_id
,
reverse
=
False
)
data
=
json_graph
.
tree_data
(
hierarchy
,
root
=
top_id
)
json_string
=
json
.
dumps
(
data
)
json_file
=
open
(
"hierarchy.json"
,
"w"
)
json_file
.
write
(
json_string
)
json_file
.
close
()
def
generate_tree
(
self
):
"""Generate the graph from pool and create the requested outcomes"""
...
...
@@ -84,9 +66,7 @@ class ActionTree(Action):
unfetched_modules
=
False
hierarchy
=
nx
.
DiGraph
()
if
self
.
options
.
solved
:
logging
.
warning
(
"This is the solved tree"
)
else
:
if
self
.
options
.
mode
==
"mods"
:
for
mod_aux
in
self
:
if
not
mod_aux
.
isfetched
:
unfetched_modules
=
True
...
...
@@ -97,14 +77,49 @@ class ActionTree(Action):
else
:
hierarchy
.
add_node
(
mod_aux
.
path
)
top_id
=
mod_aux
.
path
if
self
.
options
.
withfiles
:
if
len
(
mod_aux
.
files
):
for
file_aux
in
mod_aux
.
files
:
hierarchy
.
add_edge
(
mod_aux
.
path
,
path
.
relpath
(
file_aux
.
path
))
if
len
(
mod_aux
.
files
):
for
file_aux
in
mod_aux
.
files
:
hierarchy
.
add_edge
(
mod_aux
.
path
,
path
.
relpath
(
file_aux
.
path
))
elif
(
self
.
options
.
mode
==
'dfs'
or
self
.
options
.
mode
==
'bfs'
):
logging
.
warning
(
"This is the solved tree"
)
#self.top_entity = self.options.top
self
.
build_file_set
()
self
.
solve_file_set
()
from
hdlmake.srcfile
import
SourceFileSet
from
hdlmake.dep_file
import
DepRelation
assert
isinstance
(
self
.
parseable_fileset
,
SourceFileSet
)
fset
=
self
.
parseable_fileset
.
filter
(
DepFile
)
# Find the file that provides the named top level entity
top_rel_vhdl
=
DepRelation
(
"
%
s.
%
s"
%
(
"work"
,
self
.
top_entity
),
DepRelation
.
PROVIDE
,
DepRelation
.
ENTITY
)
top_rel_vlog
=
DepRelation
(
"
%
s.
%
s"
%
(
"work"
,
self
.
top_entity
),
DepRelation
.
PROVIDE
,
DepRelation
.
MODULE
)
top_file
=
None
for
chk_file
in
fset
:
hierarchy
.
add_node
(
path
.
relpath
(
chk_file
.
path
))
for
file_required
in
chk_file
.
depends_on
:
hierarchy
.
add_edge
(
path
.
relpath
(
chk_file
.
path
),
path
.
relpath
(
file_required
.
path
))
for
rel
in
chk_file
.
rels
:
if
(
rel
==
top_rel_vhdl
)
or
(
rel
==
top_rel_vlog
):
top_file
=
chk_file
top_id
=
path
.
relpath
(
chk_file
.
path
)
if
top_file
is
None
:
logging
.
critical
(
'Could not find a top level file that provides the '
'top_module="
%
s". Continuing with the full file set.'
,
top_level_entity
)
else
:
logging
.
error
(
'Unknown tree mode:
%
s'
,
self
.
options
.
mode
)
quit
()
if
unfetched_modules
:
logging
.
warning
(
"Some of the modules have not been fetched!"
)
self
.
_generate_tree_web
(
hierarchy
,
top_id
)
self
.
_generate_tree_graphviz
(
hierarchy
,
top_id
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment