Skip to content

Commit 6a321fa

Browse files
committed
fix(generate_klayout_tech): address gemini-code-assist nits on #4234
Two follow-ups from gemini's review of #4234: * The map-file test in test_with_map_files still asserted `os.path.realpath(map_path)`, inconsistent with the LEF test's `os.path.abspath` switch. On platforms whose tmpdir contains symlinks (macOS /var -> /private/var) the test would fail. Switch to `os.path.abspath` to match the LEF case. * `reference_dir` and `use_relative_paths` are now both unused. Update the function docstring to say so, default both to `None` / `False` so callers can drop them, and demote the CLI flags to `required=False` so external scripts that don't pass them still work. flow/Makefile still passes `--reference-dir` so we keep accepting the flag. Signed-off-by: Øyvind Harboe <oyvind@ascenium.com> Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
1 parent 369c98b commit 6a321fa

2 files changed

Lines changed: 24 additions & 10 deletions

File tree

‎flow/test/test_generate_klayout_tech.py‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,10 @@ def test_with_map_files(self):
160160
with open(self.output) as f:
161161
content = f.read()
162162

163-
self.assertIn(os.path.realpath(map_path), content)
163+
# Same abspath semantics as LEFs: map files are also written as
164+
# plain absolute paths so klayout doesn't resolve them relative
165+
# to the bare-execroot realpath of the input DEF.
166+
self.assertIn(os.path.abspath(map_path), content)
164167
self.assertNotIn("original.map", content)
165168

166169
def test_multiple_lef_files(self):

‎flow/util/generate_klayout_tech.py‎

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,23 @@ def generate_klayout_tech(
3434
template_lyt,
3535
output_lyt,
3636
lef_files,
37-
reference_dir,
3837
map_files,
39-
use_relative_paths,
38+
reference_dir=None,
39+
use_relative_paths=False,
4040
):
4141
"""Generate a klayout .lyt file from a platform template.
4242
4343
Args:
4444
template_lyt: Path to the platform .lyt template file.
4545
output_lyt: Path to write the generated .lyt file.
4646
lef_files: List of LEF file paths to include.
47-
reference_dir: Directory to compute relative paths from.
4847
map_files: List of map file paths.
49-
use_relative_paths: If True, compute paths relative to reference_dir.
48+
reference_dir: Unused. Accepted for backward compatibility with
49+
callers (e.g. flow/Makefile) that still pass it from when
50+
paths were resolved relative to this directory.
51+
use_relative_paths: Unused. Same backward-compat rationale as
52+
reference_dir -- paths are always written as plain abspath
53+
now, regardless of this flag.
5054
"""
5155
with open(template_lyt, "r") as f:
5256
content = f.read()
@@ -59,8 +63,8 @@ def generate_klayout_tech(
5963
# action execution -- they're only at the per-action sandbox -- so
6064
# resolution fails with errno=2. Plain abspath (NOT realpath, which
6165
# would chase Bazel input-file symlinks back out to the bare execroot)
62-
# keeps klayout pointed at the in-sandbox file. reference_dir is now
63-
# unused for LEFs.
66+
# keeps klayout pointed at the in-sandbox file. reference_dir and
67+
# use_relative_paths are both ignored.
6468
resolved_lefs = [os.path.abspath(f) for f in lef_files]
6569

6670
content = replace_lef_files(content, resolved_lefs)
@@ -85,16 +89,23 @@ def main():
8589
)
8690
parser.add_argument(
8791
"--reference-dir",
88-
required=True,
89-
help="Directory for computing relative paths",
92+
required=False,
93+
default=None,
94+
help=(
95+
"Unused; accepted for backward compatibility. LEF / map paths "
96+
"are written as plain abspath regardless of this directory."
97+
),
9098
)
9199
parser.add_argument(
92100
"--map-files", nargs="*", default=[], help="Map files to include"
93101
)
94102
parser.add_argument(
95103
"--use-relative-paths",
96104
action="store_true",
97-
help="Use paths relative to reference-dir",
105+
help=(
106+
"Unused; accepted for backward compatibility. LEF / map paths "
107+
"are written as plain abspath regardless of this flag."
108+
),
98109
)
99110
args = parser.parse_args()
100111

0 commit comments

Comments
 (0)