Commit 1d55f716 authored by Tristan Gingold's avatar Tristan Gingold

dep_file.py: split rels set into requires/provides.

parent f7cfce26
......@@ -146,27 +146,28 @@ class DepFile(File):
def __init__(self, path, module):
assert isinstance(path, six.string_types)
File.__init__(self, path=path, module=module)
self.rels = set()
self.depends_on = set()
self.provides = set()
self.requires = set()
self.depends_on = set() # Set of files this file depends on.
self.dep_level = None
self.is_parsed = False
def add_require(self, rel):
"""Add dependency :param rel:"""
assert rel.direction == DepRelation.USE
self.rels.add(rel)
self.requires.add(rel)
def add_provide(self, rel):
"""Add provide :param rel:"""
assert rel.direction == DepRelation.PROVIDE
self.rels.add(rel)
self.provides.add(rel)
def satisfies(self, rel_b):
"""Check if any of the file object relations match any of the relations
listed in the parameter (rel_b)"""
assert isinstance(rel_b, DepRelation)
# self._parse_if_needed()
return any([x.satisfies(rel_b) for x in self.rels])
return any([x.satisfies(rel_b) for x in self.provides])
def get_dep_level(self):
"""Get the dependency level for the file instance, so we can order
......
......@@ -64,42 +64,41 @@ def solve(fileset, standard_libs=None):
not_satisfied = 0
for investigated_file in fset:
# logging.info("INVESTIGATED FILE: %s" % investigated_file)
# print(investigated_file.rels)
for rel in investigated_file.rels:
for rel in investigated_file.requires:
# logging.info("- relation: %s" % rel)
# logging.info("- direction: %s" % rel.direction)
# Only analyze USE relations, we are looking for dependencies
if rel.direction == DepRelation.USE:
satisfied_by = set()
for dep_file in fset:
if dep_file.satisfies(rel):
if dep_file is not investigated_file:
investigated_file.depends_on.add(dep_file)
satisfied_by.add(dep_file)
if len(satisfied_by) > 1:
logging.warning(
"Relation %s satisfied by multiple (%d) files:\n %s",
str(rel),
len(satisfied_by),
'\n '.join([file_aux.path for
file_aux in list(satisfied_by)]))
elif len(satisfied_by) == 0:
# if relation is a USE PACKAGE, check against
# the standard libs provided by the tool HDL compiler
required_lib = rel.obj_name.split('.')[0]
if (not standard_libs is None and
required_lib in standard_libs and
rel.direction is DepRelation.USE and
rel.rel_type is DepRelation.PACKAGE):
logging.debug("Not satisfied relation %s in %s will "
"be covered by the target compiler "
"standard libs.",
str(rel), investigated_file.name)
else:
logging.warning("Relation %s in %s not satisfied by "
"any source file",
str(rel), investigated_file.name)
not_satisfied += 1
assert rel.direction == DepRelation.USE
satisfied_by = set()
for dep_file in fset:
if dep_file.satisfies(rel):
if dep_file is not investigated_file:
investigated_file.depends_on.add(dep_file)
satisfied_by.add(dep_file)
if len(satisfied_by) > 1:
logging.warning(
"Relation %s satisfied by multiple (%d) files:\n %s",
str(rel),
len(satisfied_by),
'\n '.join([file_aux.path for
file_aux in list(satisfied_by)]))
elif len(satisfied_by) == 0:
# if relation is a USE PACKAGE, check against
# the standard libs provided by the tool HDL compiler
required_lib = rel.obj_name.split('.')[0]
if (not standard_libs is None and
required_lib in standard_libs and
rel.direction is DepRelation.USE and
rel.rel_type is DepRelation.PACKAGE):
logging.debug("Not satisfied relation %s in %s will "
"be covered by the target compiler "
"standard libs.",
str(rel), investigated_file.name)
else:
logging.warning("Relation %s in %s not satisfied by "
"any source file",
str(rel), investigated_file.name)
not_satisfied += 1
logging.debug("SOLVE END")
if not_satisfied != 0:
logging.warning(
......@@ -141,7 +140,7 @@ def make_dependency_set(fileset, top_level_entity, extra_modules=None):
entity_rel_vlog = DepRelation(
"%s.%s" %
("work", entity_name), DepRelation.PROVIDE, DepRelation.MODULE)
for rel in test_file.rels:
for rel in test_file.provides:
if (rel == entity_rel_vhdl) or (rel == entity_rel_vlog):
return True
return 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