Skip to content

Commit f707195

Browse files
authored
Merge pull request #3238 from Pinata-Consulting/dependencies-remove-perl
dependencies: remove sole Perl dependency in ORFS
2 parents 997e74a + c44fb33 commit f707195

File tree

3 files changed

+57
-62
lines changed

3 files changed

+57
-62
lines changed

flow/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ $(DONT_USE_LIBS): $$(filter %$$(@F) %$$(@F).gz,$(LIB_FILES))
207207
$(PYTHON_EXE) $(UTILS_DIR)/preprocessLib.py -i $^ -o $@
208208

209209
$(OBJECTS_DIR)/lib/merged.lib: $(DONT_USE_LIBS)
210-
$(UTILS_DIR)/mergeLib.pl $(PLATFORM)_merged $(DONT_USE_LIBS) > $@
210+
$(PYTHON_EXE) $(UTILS_DIR)/merge_lib.py $(PLATFORM)_merged $(DONT_USE_LIBS) > $@
211211

212212
# Pre-process KLayout tech
213213
# ==============================================================================

flow/util/mergeLib.pl

Lines changed: 0 additions & 61 deletions
This file was deleted.

flow/util/merge_lib.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/usr/bin/env python3
2+
3+
import re
4+
import sys
5+
6+
7+
def process_header(filename, sclname):
8+
with open(filename, "r") as fh:
9+
for line in fh:
10+
if re.search(r"library\s*\(", line):
11+
print(f"library ({sclname}) {{")
12+
continue
13+
if re.match(r"^[\t ]*cell\s*\(", line):
14+
break
15+
print(line, end="")
16+
17+
18+
def process_cells(filename):
19+
with open(filename, "r") as fh:
20+
flag = 0 # brace depth
21+
for line in fh:
22+
# Match 'cell ( ... )' with optional whitespace
23+
if re.match(r"^[\t ]*cell\s*\(", line):
24+
if flag != 0:
25+
raise RuntimeError(
26+
"Error! new cell before finishing the previous one!"
27+
)
28+
print() # print blank line like Perl
29+
print(line, end="")
30+
flag = 1 # entering a cell block
31+
elif flag > 0:
32+
# Increase/decrease brace depth
33+
flag += line.count("{")
34+
flag -= line.count("}")
35+
print(line, end="")
36+
37+
# Optionally: reset flag to 0 here if it's finished
38+
# But not necessary unless you're adding post-processing
39+
40+
41+
def main():
42+
if len(sys.argv) < 3:
43+
print("use: mergeLib.py new_library_name lib1 lib2 lib3 ....")
44+
sys.exit(1)
45+
46+
sclname = sys.argv[1]
47+
files = sys.argv[2:]
48+
49+
process_header(files[0], sclname)
50+
for file in files:
51+
process_cells(file)
52+
print("\n}")
53+
54+
55+
if __name__ == "__main__":
56+
main()

0 commit comments

Comments
 (0)