Fix tree generation

parent b939af42
......@@ -133,7 +133,7 @@ def main():
action = [
GenerateSynthesisProject,
GenerateSynthesisMakefile,
GenerateRemoteSynthesisMakefile
#GenerateRemoteSynthesisMakefile
]
elif top_mod.action == "qsys_hw_tcl_update":
if not top_mod.hw_tcl_filename:
......
......@@ -28,7 +28,8 @@ class ListFiles(Action):
unfetched_modules = [m for m in self.modules_pool if not m.isfetched]
for m in unfetched_modules:
logging.warning("List incomplete, module %s has not been fetched!", m)
solved_files = self.modules_pool.build_file_set()
self.modules_pool.build_file_set()
solved_files = self.modules_pool.hierarchy_solved
if self.options.delimiter == None:
delimiter = "\n"
else:
......
......@@ -26,7 +26,7 @@ import sys
import os
import importlib
from hdlmake.srcfile import SourceFileFactory
from hdlmake.srcfile import SourceFileFactory, SourceFileSet
from hdlmake.dependable_file import DependableFile
from hdlmake.util import path
......@@ -171,7 +171,9 @@ end sdb_meta_pkg;""")
update=False
top_mod = self.modules_pool.get_top_module()
fileset = self.modules_pool.build_file_set()
self.modules_pool.build_file_set()
fileset = SourceFileSet()
fileset.add(self.modules_pool.hierarchy_solved)
non_dependable = fileset.inversed_filter(DependableFile)
fileset.add(non_dependable)
privative_files = tool_object.supported_files(self.modules_pool.build_complete_file_set())
......
......@@ -33,41 +33,10 @@ class Tree(Action):
except Exception as e:
logging.error(e)
quit()
unfetched_modules = False
files_str = []
hierarchy = nx.DiGraph()
#hierarchy = pgv.AGraph(directed=True, overlap=False, strict=False, rotate=1)
#hierarchy.node_attr['shape'] = 'box'
color_index = 0
if self.options.solved:
logging.warning("This is the solved tree")
else:
for m in self.modules_pool:
if not m.isfetched:
unfetched_modules = True
else:
if m.parent:
hierarchy.add_node(path.relpath(m.path))
#hierarchy.add_node(m)
hierarchy.add_edge(path.relpath(m.parent.path), path.relpath(m.path))
#hierarchy.add_edge(m, m.parent)
else:
hierarchy.add_node(path.relpath(m.path))
top_id = path.relpath(m.path)
#hierarchy.add_node(m)
if self.options.withfiles:
if len(m.files):
for f in m.files:
hierarchy.add_edge(path.relpath(m.path), path.relpath(f.path))
#hierarchy.add_edge(f, m)
color_index += 1
if unfetched_modules: logging.warning("Some of the modules have not been fetched!")
#hierarchy.layout(prog='dot')
#hierarchy.layout(prog='sfdp')
#hierarchy.layout()
self.modules_pool.build_file_set()
hierarchy = self.modules_pool.hierarchy_tree
top_id = self.modules_pool.top_module.top_module
# Define the program used to write the graphviz:
# Program should be one of:
# twopi, gvcolor, wc, ccomps, tred, sccmap, fdp,
......
......@@ -38,6 +38,11 @@ class ModulePool(list):
self.global_fetch = os.getenv("HDLMAKE_COREDIR")
self._deps_solved = False
self.env = None
# Directed Acyclic Graph
self.hierarchy_dag = None
self.hierarchy_dict = None
self.hierarchy_tree =None
self.hierarchy_solved =None
def set_environment(self, env):
self.env = env
......@@ -188,12 +193,6 @@ class ModulePool(list):
else:
logging.debug("NOT appended to fetch queue: " + str(mod.url))
def build_file_set(self):
from srcfile import SourceFileSet
build_files = SourceFileSet()
solved_files = self.build_limited_file_set()
return solved_files
def build_complete_file_set(self):
"""Build set of all files listed in the manifests"""
logging.debug("Begin build complete file set")
......@@ -204,14 +203,13 @@ class ModulePool(list):
logging.debug("End build complete file set")
return all_manifested_files
def build_limited_file_set(self):
def build_file_set(self):
top_entity = self.top_module.top_module
#self.solve_dependencies()
all_files = self.build_complete_file_set()
from srcfile import SourceFileSet
source_files = SourceFileSet()
source_files.add(dep_solver.solve(all_files, top_entity))
return source_files
(self.hierarchy_dag, self.hierarchy_dict, self.hierarchy_tree, self.hierarchy_solved) = dep_solver.solve(all_files, top_entity)
def get_top_module(self):
return self.top_module
......
......@@ -135,7 +135,6 @@ def solve(fileset, top_entity):
for used_instance in module_test.instances:
hierarchy.add_edge(module_test.model, used_instance[0])
tree = nx.bfs_tree(hierarchy, top_entity)
top_hierarchy = tree
......@@ -152,47 +151,9 @@ def solve(fileset, top_entity):
logging.info("Dependencies solved: %s files added to the hierarchy" % len(solved_files))
# 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 False:
import matplotlib.pyplot as plt
pos=nx.graphviz_layout(top_hierarchy, prog='neato', root=top_entity)
nx.draw(top_hierarchy, pos,
with_labels=True,
alpha=0.5,
node_size=100)
plt.savefig("hierarchy.png")
plt.show()
if False:
import matplotlib.pyplot as plt
pos=nx.graphviz_layout(hierarchy, prog='neato', root=top_entity)
nx.draw(hierarchy, pos,
with_labels=True,
alpha=0.5,
node_size=100)
plt.savefig("hierarchy.png")
plt.show()
if True:
import json
from networkx.readwrite import json_graph
data = json_graph.tree_data(top_hierarchy, root=top_entity)
#data = json_graph.tree_data(hierarchy, root='../../ip_cores/gn4124-core')
#print(data)
s = json.dumps(data)
#print(s)
json_file = open("hierarchy.json", "w")
json_file.write(s)
json_file.close()
logging.debug("SOLVE END")
return solved_files
return (hierarchy, hierarchy_dict, top_hierarchy, solved_files)
def make_dependency_sorted_list(fileset, purge_unused=True, reverse=False):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment