Skip to content

Commit 666ad67

Browse files
committed
flow/designs: exports_files() for cross-package source references
bazel-orfs's config_mk_parser translates $(DESIGN_HOME) paths in a config.mk into bazel labels — e.g. an SDC_FILE of $(DESIGN_HOME)/asap7/aes/constraint.sdc becomes //flow/designs/asap7/aes:constraint.sdc. The orfs_design() macro creates per-extension filegroups, but referencing an individual file across packages requires that file to be in an exports_files() list, not just inside a public filegroup. Without this, designs that reuse another design's SDC or shared source fail at analysis with a Visibility error: //flow/designs/asap7/aes-mbff -> aes/constraint.sdc //flow/designs/asap7/gcd-ccs -> gcd/constraint.sdc //flow/designs/asap7/mock-cpu -> src/mock-array/util.tcl //flow/designs/asap7/riscv32i-mock-sram -> fakeram7_256x32/constraints.sdc //flow/designs/sky130hd/gcd -> src/gcd/gcd.v Both helpers in flow/designs/design.bzl now call exports_files() over the same explicit extension list (_EXPORTED_EXTS) the design() macro's filegroup logic uses — kept tight so a glob("*") doesn't silently expose LICENSE/.gitignore/etc. as the public API surface. Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
1 parent eed7931 commit 666ad67

1 file changed

Lines changed: 34 additions & 3 deletions

File tree

‎flow/designs/design.bzl‎

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ _GROUPS = {
1313
"gds": ["gds", "gds.gz"],
1414
}
1515

16+
# Extensions exported as individual labels so bazel-orfs's per-file
17+
# cross-package references resolve. Kept tight on purpose: globbing "*"
18+
# silently exposes LICENSE/.gitignore/etc. as the public API surface.
19+
_EXPORTED_EXTS = ["v", "sv", "svh", "tcl", "sdc", "def", "cfg", "lef", "lib"]
20+
1621
def design(config = "config.mk", user_arguments = [], local_arguments = []):
1722
"""Standard BUILD body for flow/designs/<platform>/<design>/.
1823
@@ -26,18 +31,44 @@ def design(config = "config.mk", user_arguments = [], local_arguments = []):
2631
within the same config.mk, never read by ORFS or by user
2732
.tcl/.mk). Dropped entirely before orfs_flow() is invoked.
2833
"""
34+
35+
# Some designs share another design's SDC, Verilog, or constraint
36+
# files via $(DESIGN_HOME)/<platform>/<other-design>/... paths in
37+
# config.mk. bazel-orfs translates these into cross-package labels
38+
# like //flow/designs/<platform>/<other-design>:constraint.sdc,
39+
# which require explicit exports_files() on the source package.
40+
exported = native.glob(
41+
["*.{}".format(e) for e in _EXPORTED_EXTS],
42+
allow_empty = True,
43+
)
44+
if exported:
45+
native.exports_files(exported, visibility = ["//visibility:public"])
46+
2947
orfs_design(
3048
config = config,
3149
user_arguments = user_arguments,
3250
local_arguments = local_arguments,
3351
)
3452

3553
def files(group, extra_srcs = None):
36-
"""Named filegroup over conventional extensions."""
54+
"""Named filegroup over conventional extensions.
55+
56+
Also exports the same files individually so per-file labels
57+
(e.g. //flow/designs/src/gcd:gcd.v) resolve from sibling packages.
58+
bazel-orfs's config_mk_parser emits such labels for
59+
$(DESIGN_HOME)/src/<name>/<file> references.
60+
"""
3761
exts = _GROUPS[group]
62+
srcs = native.glob(["*.{}".format(e) for e in exts], allow_empty = True) + \
63+
(extra_srcs or [])
3864
native.filegroup(
3965
name = group,
40-
srcs = native.glob(["*.{}".format(e) for e in exts], allow_empty = True) +
41-
(extra_srcs or []),
66+
srcs = srcs,
4267
visibility = ["//visibility:public"],
4368
)
69+
exported = native.glob(
70+
["*.{}".format(e) for e in _EXPORTED_EXTS],
71+
allow_empty = True,
72+
)
73+
if exported:
74+
native.exports_files(exported, visibility = ["//visibility:public"])

0 commit comments

Comments
 (0)