Debian Codegraph @

tcltk/strip_reflibs.tcl

raw ◀ ▶
Source reconstructed at patch state 0 of 1 — not the installed (fully patched) source.
1 Debian patch touch this file
1 #!/usr/local/bin/tclsh
2 #
3 # Strip GDS cell references from magic files.
4 #
5 # This is necessary to make sure that no geometry goes into the output
6 # for files swapped between Cadence and Magic. To import into Magic
7 # from Cadence, "Retain Reference Library" should be FALSE, so that
8 # Magic gets all of the cell contents. Then run this file on the
9 # resulting Magic database directory, and read back into Cadence using
10 # "Retain Reference Library" = TRUE. This will prevent Cadence from
11 # generating local copies of every cell, instead retaining the original
12 # library definition.
13 #
14 # 1. delete lines beginning "string GDS_START"
15 # 2. delete lines beginning "string GDS_END"
16 # 3. do NOT delete "string GDS_FILE" lines.
17 #
18 # Note that if all cells are treated as library references, then the
19 # GDS file itself does not need to exist.
20
21 foreach fname [glob *.mag] {
22 if [catch {open $fname r} fIn] {
23 puts stdout "Error: can't open file $fname"
24 } else {
25 set fOut [open tmp.mag w]
26 while {[gets $fIn line] >= 0} {
27 if [regexp {^string GDS_} $line] {
28 if [regexp {^string GDS_START} $line ] {
29 } elseif [regexp {^string GDS_END} $line] {
30 } else {
31 puts $fOut $line
32 }
33 } else {
34 puts $fOut $line
35 }
36 }
37 close $fIn
38 close $fOut
39 file rename -force tmp.mag $fname
40 }
41 }