Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions flow/test/test_generate_klayout_tech.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,13 @@ def test_basic_generation(self):

self.assertIn("<lef-files>", content)
self.assertNotIn("original.lef", content)
# Path should be relative to results_dir
expected_rel = os.path.relpath(
os.path.realpath(lef_path),
os.path.realpath(self.results_dir),
)
self.assertIn(expected_rel, content)
# LEF paths are written as plain abspath (not relpath, not realpath):
# klayout's Layout.read resolves relative <lef-files> entries
# against the realpath of the DEF being merged, which under a
# Bazel sandbox is the bare execroot -- the in-flight sibling
# files only exist in the per-action sandbox. Absolute paths
# bypass the relative-resolution dance.
self.assertIn(os.path.abspath(lef_path), content)

def test_with_map_files(self):
with open(self.template, "w") as f:
Expand Down
19 changes: 12 additions & 7 deletions flow/util/generate_klayout_tech.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,21 @@ def generate_klayout_tech(
with open(template_lyt, "r") as f:
content = f.read()

# Both modes use relative paths from reference_dir, matching the
# original sed-based behavior which always uses realpath --relative-to.
resolved_lefs = [
os.path.relpath(os.path.realpath(f), os.path.realpath(reference_dir))
for f in lef_files
]
# Write absolute (not relative, not realpath'd) LEF paths into the LYT.
# Klayout's Layout.read(def, layout_options) follows the symlinked input
# DEF to its realpath at the bare execroot and resolves relative
# <lef-files> entries from there. Sibling intermediates like
# objects/klayout_tech.lef don't exist at the bare execroot during
# action execution -- they're only at the per-action sandbox -- so
# resolution fails with errno=2. Plain abspath (NOT realpath, which
# would chase Bazel input-file symlinks back out to the bare execroot)
# keeps klayout pointed at the in-sandbox file. reference_dir is now
# unused for LEFs.
resolved_lefs = [os.path.abspath(f) for f in lef_files]
Comment thread
oharboe marked this conversation as resolved.
Outdated

content = replace_lef_files(content, resolved_lefs)

resolved_maps = [os.path.realpath(f) for f in map_files]
resolved_maps = [os.path.abspath(f) for f in map_files]
Comment thread
oharboe marked this conversation as resolved.
Outdated
Comment thread
oharboe marked this conversation as resolved.
Outdated
content = replace_map_files(content, resolved_maps)

with open(output_lyt, "w") as f:
Expand Down