Skip to content

Commit

Permalink
VCS: Avoid breaking library dependency links for empty nodes
Browse files Browse the repository at this point in the history
If some library doesn't contain any HDL files, no make.vlogan will
be created and the dependency tree will drop the branch that depends
on the empty library. This compacts the tree by throwing out empty
nodes and reconnect its dependencies to those that depend on the empty
library.
  • Loading branch information
olofk committed Feb 13, 2025
1 parent ffdb23b commit 53a1e90
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions edalize/tools/vcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ class Vcs(Edatool):
}

def setup(self, edam):
def absorb_node(nodes, node_to_absorb):
for node, deps in nodes.items():
if node_to_absorb in deps:
deps.remove(node_to_absorb)
deps += nodes[node_to_absorb]
del nodes[node_to_absorb]

super().setup(edam)

incdirs = []
Expand All @@ -58,7 +65,6 @@ def setup(self, edam):
unused_files.remove(f)

user_files = []
commands = {}
libs = {}
has_sv = False
for f in unused_files.copy():
Expand Down Expand Up @@ -99,9 +105,6 @@ def setup(self, edam):
if not lib in libs:
libs[lib] = []
libs[lib].append((cmd, f["name"], defines))
if not commands.get((cmd, lib, defines)):
commands[(cmd, lib, defines)] = []
commands[(cmd, lib, defines)].append(f["name"])
unused_files.remove(f)

full64 = [] if self.tool_options.get("32bit") else ["-full64"]
Expand All @@ -110,6 +113,10 @@ def setup(self, edam):
self.workdirs = []
target_files = []
libdeps = self.edam.get("library_dependencies", {})
for lib in libdeps.copy():
if not lib in libs:
absorb_node(libdeps, lib)

for lib, files in libs.items():
cmds = {}
has_vlog = False
Expand All @@ -120,7 +127,6 @@ def setup(self, edam):
cmds[(cmd, defines)].append(fname)
if cmd == "vlogan":
has_vlog = True
commands = [["mkdir", "-p", lib]]
i = 0
f_files = {}
for (cmd, defines), fnames in cmds.items():
Expand Down

0 comments on commit 53a1e90

Please sign in to comment.