Skip to content

Commit 2f82049

Browse files
committed
fix: address gemini-code-assist nits on The-OpenROAD-Project#4229
Three drive-by suggestions from the bot review: - bazel/yosys-check.sh: refuse BLOCKS= designs up front, mirroring make-yosys-netlist.sh. Same rationale — bazel-orfs's hierarchical block plumbing diverges from make's (sub-block .lef/.lib not staged into the parent synth action), so the per-stage .odb table would not be apples-to-apples. - flow/designs/design.bzl: include gds and gds.gz in _EXPORTED_EXTS so cross-package ADDITIONAL_GDS references resolve. Brings the exported set into line with the _GROUPS["gds"] entry that already filegroups them. - flow/designs/design.bzl: factor the duplicated exports_files() glob in design() and files() into a private _export_design_files() helper. Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
1 parent cf164f2 commit 2f82049

2 files changed

Lines changed: 37 additions & 21 deletions

File tree

‎bazel/yosys-check.sh‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,28 @@ PLAT="${DESIGN_DIR%%/*}" # asap7
4444
DESIGN="${DESIGN_DIR#*/}" # uart
4545
SYNTH_TARGET="//$PKG:${NAME%_test}_synth"
4646

47+
# BLOCKS= designs don't pass clean bazel-vs-make comparisons because
48+
# bazel-orfs's hierarchical-block plumbing differs from make's
49+
# (sub-block .lef/.lib aren't staged into the parent synth action).
50+
# See aes-block. Refuse rather than emit a misleading DIFFER table.
51+
# Matches make-yosys-netlist.sh.
52+
if grep -qE '^[[:space:]]*export[[:space:]]+BLOCKS[[:space:]]*[?:]?=' \
53+
"flow/designs/$PLAT/$DESIGN/config.mk"; then
54+
echo "yosys-check: $DESIGN sets BLOCKS=… (hierarchical design)." >&2
55+
echo " bazel-orfs's BLOCKS handling diverges from make's at the parent" >&2
56+
echo " synth step (sub-block abstracts not staged into the parent action)" >&2
57+
echo " so a per-stage .odb comparison won't be apples-to-apples." >&2
58+
echo " Skipping; this is a known bazel-orfs gap, not an OpenROAD-determinism" >&2
59+
echo " question." >&2
60+
exit 2
61+
fi
62+
4763
# bazel-orfs and classic make disagree on which design-config var to
4864
# put in the results path: bazel uses DESIGN_NAME (the module/top),
4965
# make uses DESIGN_NICKNAME (the user-friendly tag). For most designs
5066
# they're equal; aes-block is the canonical exception
5167
# (DESIGN_NAME=aes_cipher_top vs DESIGN_NICKNAME=aes-block).
5268
echo "==> Building $SYNTH_TARGET (need bazel's 1_2_yosys.v and the results subdir)"
53-
SYNTH_TARGET="//$PKG:${NAME%_test}_synth"
5469
bazelisk build "$SYNTH_TARGET"
5570

5671
# Bazel side: glob the single subdir under bazel-bin/<pkg>/results/<plat>/.

‎flow/designs/design.bzl‎

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,25 @@ _GROUPS = {
1616
# Extensions exported as individual labels so bazel-orfs's per-file
1717
# cross-package references resolve. Kept tight on purpose: globbing "*"
1818
# silently exposes LICENSE/.gitignore/etc. as the public API surface.
19-
_EXPORTED_EXTS = ["v", "sv", "svh", "tcl", "sdc", "def", "cfg", "lef", "lib"]
19+
# gds/gds.gz are inputs in hierarchical flows via ADDITIONAL_GDS.
20+
_EXPORTED_EXTS = ["v", "sv", "svh", "tcl", "sdc", "def", "cfg", "lef", "lib", "gds", "gds.gz"]
21+
22+
def _export_design_files():
23+
"""Publicly export per-file labels for cross-package references.
24+
25+
bazel-orfs's config_mk_parser turns $(DESIGN_HOME)/... and
26+
$(PLATFORM_DIR)/... paths in a config.mk into per-file bazel labels
27+
like //flow/designs/<plat>/<other>:constraint.sdc. Those labels
28+
resolve only if the source package calls exports_files() on the
29+
individual files — being part of a public filegroup is not
30+
sufficient.
31+
"""
32+
exported = native.glob(
33+
["*.{}".format(e) for e in _EXPORTED_EXTS],
34+
allow_empty = True,
35+
)
36+
if exported:
37+
native.exports_files(exported, visibility = ["//visibility:public"])
2038

2139
def design(config = "config.mk", user_arguments = [], local_arguments = []):
2240
"""Standard BUILD body for flow/designs/<platform>/<design>/.
@@ -31,19 +49,7 @@ def design(config = "config.mk", user_arguments = [], local_arguments = []):
3149
within the same config.mk, never read by ORFS or by user
3250
.tcl/.mk). Dropped entirely before orfs_flow() is invoked.
3351
"""
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-
52+
_export_design_files()
4753
orfs_design(
4854
config = config,
4955
user_arguments = user_arguments,
@@ -66,9 +72,4 @@ def files(group, extra_srcs = None):
6672
srcs = srcs,
6773
visibility = ["//visibility:public"],
6874
)
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"])
75+
_export_design_files()

0 commit comments

Comments
 (0)