Slight extension to the "options=" option to allow the value to be
a Tcl expression instead of a filename, in case only a one-line
addition is needed to a script.
diff --git a/common/foundry_install.py b/common/foundry_install.py
index ea50eeb..d2fd919 100755
--- a/common/foundry_install.py
+++ b/common/foundry_install.py
@@ -123,7 +123,9 @@
# options: Followed by "=" and the name of a script. Behavior
# is dependent on the mode; if applied to "-gds",
# then the script is inserted before the GDS read
-# in the Tcl generate script passed to magic.
+# in the Tcl generate script passed to magic. If
+# what follows the "=" is not a file, then it is
+# Tcl code to be inserted verbatim.
#
# NOTE: This script can be called once for all libraries if all file
# types (gds, cdl, lef, etc.) happen to all work with the same wildcards.
@@ -1234,8 +1236,13 @@
print('Creating magic generation script to generate magic database files.')
if tclscript:
- with open(tclscript, 'r') as ifile:
- tcllines = ifile.read().splitlines()
+ # If tclscript is a file, then read it. Otherwise, assume
+ # that the option contents should be inserted verbatim.
+ if os.path.isfile(tclscript):
+ with open(tclscript, 'r') as ifile:
+ tcllines = ifile.read().splitlines()
+ else:
+ tcllines = list(tclscript)
with open(destlibdir + '/generate_magic.tcl', 'w') as ofile:
print('#!/usr/bin/env wish', file=ofile)