Commit 7922dbbf authored by Benny Simonsen's avatar Benny Simonsen Committed by Tristan Gingold

Add support for package body in separate file

If a package body exists, then it is included as dependency for its package.
parent 1a8d6db9
......@@ -39,12 +39,14 @@ class DepRelation(object):
PACKAGE = 2
ARCHITECTURE = 3
CONTEXT = 4
PACKAGE_BODY = 5
MODULE = ENTITY
def __init__(self, obj_name, lib_name, rel_type):
assert rel_type in [
DepRelation.ENTITY,
DepRelation.PACKAGE,
DepRelation.PACKAGE_BODY,
DepRelation.ARCHITECTURE,
DepRelation.CONTEXT,
DepRelation.MODULE]
......@@ -66,6 +68,7 @@ class DepRelation(object):
ostr = {
self.ENTITY: "entity",
self.PACKAGE: "package",
self.PACKAGE_BODY: "package body",
self.ARCHITECTURE: "architecture",
self.CONTEXT: "context",
self.MODULE: "module"}
......
......@@ -157,6 +157,8 @@ def check_graph(graph, fileset, syslibs, standard_libs=None):
"standard libs.",
str(rel), investigated_file.name)
continue
if rel.rel_type == DepRelation.PACKAGE_BODY:
continue
logging.warning("File '%s' depends on undeclared (not found) %s",
investigated_file.name, str(rel))
not_satisfied += 1
......
......@@ -201,9 +201,35 @@ class VHDLParser(DepParser):
graph.add_provide(
dep_file,
DepRelation(pkg_name, dep_file.library, DepRelation.PACKAGE))
graph.add_require(
dep_file,
DepRelation(pkg_name, dep_file.library, DepRelation.PACKAGE_BODY))
return "<hdlmake package %s.%s>" % (dep_file.library, pkg_name)
buf = re.sub(package_pattern, do_package, buf)
package_body_pattern = re.compile(
r"^\s*package\s+body\s+(?P<name>\w+)\s+is\s+"
r".*?"
r"end\s*(package\s+body\s*)?(?P=name)?\s*;",
re.DOTALL | re.MULTILINE | re.IGNORECASE)
def do_package_body(text):
"""Function to be applied by re.sub to every match of the
package_body_pattern in the VHDL code -- group() returns positive matches
as indexed plain strings. It adds the found PROVIDE relations
to the file"""
pkg_name = text.group('name')
logging.debug("found package body %s.%s", dep_file.library, pkg_name)
pkg = '%s.%s' % (dep_file.library, pkg_name)
pkg = "package 'osvvm.osvvmscriptsettingspkg'"
graph.add_provide(
dep_file,
DepRelation(pkg_name, dep_file.library, DepRelation.PACKAGE_BODY))
graph.add_require(
dep_file,
DepRelation(pkg_name, dep_file.library, DepRelation.PACKAGE))
return "<hdlmake package_body_pattern %s.%s>" % (dep_file.library, pkg_name)
buf = re.sub(package_body_pattern, do_package_body, buf)
# component declaration
component_pattern = re.compile(
r"^\s*component\s+(\w+).*?end\s+component.*?;",
......
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