Skip to content

Commit 548e0be

Browse files
committed
dependencies: remove sole Perl dependency in ORFS
Python is endemic, Perl was used in one place Signed-off-by: Øyvind Harboe <[email protected]>
1 parent 2b0d8be commit 548e0be

File tree

2 files changed

+50
-1
lines changed

2 files changed

+50
-1
lines changed

flow/Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,9 @@ $(DONT_USE_LIBS): $$(filter %$$(@F) %$$(@F).gz,$(LIB_FILES))
201201
$(UTILS_DIR)/preprocessLib.py -i $^ -o $@
202202

203203
$(OBJECTS_DIR)/lib/merged.lib: $(DONT_USE_LIBS)
204-
$(UTILS_DIR)/mergeLib.pl $(PLATFORM)_merged $(DONT_USE_LIBS) > $@
204+
$(UTILS_DIR)/mergeLib.pl $(PLATFORM)_merged $(DONT_USE_LIBS) > $@.old
205+
$(PYTHON_EXE) $(UTILS_DIR)/merge_lib.py $(PLATFORM)_merged $(DONT_USE_LIBS) > $@
206+
diff -u $@.old $@ || (echo "Merged library differs from original!"; exit 1)
205207

206208
# Pre-process KLayout tech
207209
# ==============================================================================

flow/util/merge_lib.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/usr/bin/env python3
2+
3+
import sys
4+
5+
6+
def process_header(filename, sclname):
7+
with open(filename, "r") as fh:
8+
for line in fh:
9+
if "library" in line and "(" in line:
10+
print(f"library ({sclname}) {{")
11+
continue
12+
if line.lstrip().startswith("cell("):
13+
break
14+
print(line, end="")
15+
16+
17+
def process_cells(filename):
18+
with open(filename, "r") as fh:
19+
flag = 0
20+
for line in fh:
21+
if line.lstrip().startswith("cell("):
22+
if flag != 0:
23+
sys.exit("Error! new cell before finishing the previous one!\n")
24+
print(f"\n{line}", end="")
25+
flag = 1
26+
elif flag > 0:
27+
flag += line.count("{")
28+
flag -= line.count("}")
29+
print(line, end="")
30+
31+
32+
def main():
33+
if len(sys.argv) < 3:
34+
print("use: mergeLib.py new_library_name lib1 lib2 lib3 ....")
35+
sys.exit(1)
36+
37+
sclname = sys.argv[1]
38+
files = sys.argv[2:]
39+
40+
process_header(files[0], sclname)
41+
for file in files:
42+
process_cells(file)
43+
print("\n}\n")
44+
45+
46+
if __name__ == "__main__":
47+
main()

0 commit comments

Comments
 (0)