[bazel] Construct FuseSOC calls without duplicate cores_root args
Signed-off-by: Drew Macrae <drewmacrae@google.com>
diff --git a/rules/fusesoc.bzl b/rules/fusesoc.bzl
index bed465c..c5cdb02 100644
--- a/rules/fusesoc.bzl
+++ b/rules/fusesoc.bzl
@@ -36,6 +36,11 @@
verilator_options = ctx.attr.verilator_options[BuildSettingInfo].value
flags.append("--verilator_options={}".format(" ".join(verilator_options)))
+ cores_roots = {}
+ for c in ctx.files.cores:
+ if c.dirname not in cores_roots:
+ cores_roots[c.dirname] = True
+
# Note: the `fileset_top` flag used above is specific to the OpenTitan
# project to select the correct RTL fileset.
ctx.actions.run(
@@ -43,8 +48,8 @@
outputs = outputs,
inputs = ctx.files.srcs + ctx.files.cores,
arguments = [
- "--cores-root={}".format(c.dirname)
- for c in ctx.files.cores
+ "--cores-root={}".format(c)
+ for c in cores_roots.keys()
] + [
"run",
"--flag=fileset_top",