Klayout dependency#4001
Merged
maliberty merged 7 commits intoMar 17, 2026
Merged
Conversation
1fcd565 to
4d38cb9
Compare
Collaborator
Author
|
@hzeller @maliberty TL;DR merge this and only users and developers who need klayout have to install it. |
4d38cb9 to
73b906f
Compare
KLayout is a heavy end-user GUI tool that was previously required to complete the ORFS flow. The `finish` target depended on GDS_FINAL_FILE and `do-finish` called `do-gds`, meaning the flow could not complete without KLayout installed — even though most use cases never need GDS. This change decouples KLayout so it is only pulled in when explicitly requested via `make gds` / `make do-gds`, following the existing target naming pattern (place/do-place, finish/do-finish, gds/do-gds). Makefile changes: - Remove $(GDS_FINAL_FILE) from `finish` dependencies - Remove do-gds from `do-finish` recipe - Add explicit `gds` phony target - Add `check-klayout` guard on all KLayout-dependent targets (GDS merge, DRC, LVS, gallery, klayout viewer shortcuts) Extract .lyt tech file generation from sed to Python: - The do-klayout and do-klayout_wrap targets previously used fragile sed-based XML manipulation with shell variable expansion and ifeq/else branching. New util/generate_klayout_tech.py replaces this with stdlib xml/regex processing (no KLayout dependency). Refactor def2stream.py for testability: - Extract logic into merge_gds() function with pya as a parameter - Guard `import pya` so the module can be imported without KLayout - When run via `klayout -r`, the script behaves identically using klayout's -rd global variables The interface is backwards compatible: `make finish gds` produces GDS as before, `do-gds` is unchanged, and bazel-orfs can invoke `do-gds` from a new `orfs_gds()` rule while `do-final` no longer requires KLayout in the toolchain. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
34 mock-based tests that run without KLayout installed: - test_generate_klayout_tech.py: .lyt generation including validation against real platform templates (nangate45, asap7, sky130hd) - test_def2stream.py: cell clearing, VIA_ preservation, orphan detection, GDS_ALLOW_EMPTY regex, seal file merging, error counting - test_convertDrc.py: DRC report conversion (box/edge/text violations, waived items, comment assembly) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
Use glob patterns (flow/util/*.py, flow/test/test_*.py) instead of listing individual files, so new test and utility scripts trigger CI automatically. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
73b906f to
2337490
Compare
maliberty
requested changes
Mar 15, 2026
maliberty
left a comment
Member
There was a problem hiding this comment.
I would rather not change the default behavior. Perhaps a new target like signoff could be used for your purpose.
Address PR review: do-targets are internal to bazel-orfs and don't need user-facing documentation. Use-cases table is redundant with the introductory paragraph. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
No changes to the non do- versions of targets. bazel-orfs does not use the finish target; it uses do-finish and can invoke do-gds as a separate step. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
Collaborator
Author
Well spotted, thanks! Fixed. |
Member
|
hmm... I don't see a new target |
Collaborator
Author
bazel-orfs already has do-gds broken out, so I am good. |
maliberty
reviewed
Mar 16, 2026
maliberty
reviewed
Mar 16, 2026
Remove speculative write_gds section — document it when relevant. Clarify why do-finish differs from finish (Make dependency vs recipe). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
maliberty
approved these changes
Mar 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Make KLayout an optional dependency
KLayout is only needed for GDS generation, DRC, and LVS. Most ORFS
use cases — education, architectural exploration, CI testing, OpenROAD
development — never need GDS output. This PR decouples KLayout so that
make finishanddo-finish/do-finalcomplete without it.What changes
finish/do-finishno longer depend on GDS generationmake gds/do-gdstarget for explicit GDS generation(follows existing pattern: place/do-place, finish/do-finish, gds/do-gds)
check-klayoutguard on all KLayout-dependent targets with ahelpful error message when KLayout is missing
do-klayout/do-klayout_wrapsed-based XML manipulation replacedwith
util/generate_klayout_tech.py(stdlib, no KLayout dependency)def2stream.pyrefactored into a testablemerge_gds()functionwith guarded
import pyaunittest.mock— run without KLayoutflow/util/*.pyandflow/test/test_*.pyBackwards compatibility
make finish gdsproduces GDS exactly as beforedo-gdsis unchanged — bazel-orfs can call it from a neworfs_gds()rulemake finishwill complete withoutKLayout; they simply no longer attempt GDS generation
bazel-orfs
do-finalno longer requires KLayout in the toolchain. A separateorfs_gds()Bazel rule callingdo-gdsmakes KLayout an optionaldependency configured in
MODULE.bazel.Test plan
cd flow/test && python -m unittest test_generate_klayout_tech test_def2stream test_convertDrc(34 tests, no KLayout)make finish DESIGN_CONFIG=designs/nangate45/gcd/config.mkcompletes without KLayoutmake gds DESIGN_CONFIG=designs/nangate45/gcd/config.mkfails with helpful message when KLayout is missingmake finish gds DESIGN_CONFIG=designs/nangate45/gcd/config.mkproduces GDS when KLayout is installed