Have magic.tcl look for the shared library in the script directory

Rather than having the build process embed an absolute path.
The first of a couple of steps to make the magic build relocatable.
This commit is contained in:
Keno Fischer 2020-10-05 01:34:53 -04:00 committed by Tim Edwards
parent d675076254
commit 80488a8ee9
3 changed files with 15 additions and 14 deletions

View File

@ -63,7 +63,7 @@ magic.tcl: magic.tcl.in ${MAGICDIR}/defs.mak ${MAGICDIR}/VERSION
sed -e /TCL_DIR/s%TCL_DIR%${TCLDIR}%g \
-e /MAGIC_VERSION/s%MAGIC_VERSION%${MAGIC_VERSION}%g \
-e /MAGIC_REVISION/s%MAGIC_REVISION%${MAGIC_REVISION}%g \
-e /SHDLIB_EXT/s%SHDLIB_EXT%${SHDLIB_EXT}%g magic.tcl.in > magic.tcl
-e /SHDLIB_EXT/s%SHDLIB_EXT%${SHDLIB_EXT}%g magic.tcl.in > magic.tcl
magic.sh: magic.sh.in ${MAGICDIR}/defs.mak
sed -e /TCL_DIR/s%TCL_DIR%${TCLDIR}%g \

View File

@ -1,19 +1,20 @@
# Wishrc startup for ToolScript (magic)
#
# For installation: Put this file and also magicwrap.so into
# directory TCL_DIR, and set the "load" line below
# to point to the location of magicwrap.so. Also see comments
# in shell script "magic.sh".
# the same directory. Also see comments in shell script "magic.sh".
global Opts
# If we called magic via the non-console script, then we want to reset
# the environment variable HOME to its original value.
variable MAGIC_TCL_DIR [file dirname [file normalize [info script]]]
variable CAD_ROOT_DEFAULT [file normalize [file join $MAGIC_TCL_DIR ../..]]
if {${tcl_version} >= 8.6} {
load -lazy TCL_DIR/tclmagicSHDLIB_EXT
load -lazy [file join $MAGIC_TCL_DIR tclmagic[info sharedlibextension]]
} else {
load TCL_DIR/tclmagicSHDLIB_EXT
load [file join $MAGIC_TCL_DIR tclmagic[info sharedlibextension]]
}
# It is important to make sure no magic commands overlap with Tcl built-in
@ -30,8 +31,8 @@ proc pushnamespace { name } {
foreach v $y {
regsub -all {\*} $v {\\*} i
set x [namespace tail $i]
if {[lsearch $z $x] < 0} {
namespace import $i
if {[lsearch $z $x] < 0} {
namespace import $i
}
}
}
@ -124,7 +125,7 @@ proc xcircuit { args } {
# execute script in the scope of magic, because its variable space is
# not modularized.
set argv $args
set argc [llength $args]
set argc [llength $args]
uplevel #0 source $xcircscript
}
}
@ -143,7 +144,7 @@ proc netgen { args } {
puts stderr "\"source <path>/netgen.tcl\"."
} else {
set argv $args
set argc [llength $args]
set argc [llength $args]
uplevel #0 source $netgenscript
}
}
@ -151,7 +152,7 @@ proc netgen { args } {
# Add the "echo" command
proc echo {args} {
puts stdout $args
puts stdout $args
}
# Parse argument list for "-c[onsole]" and "-now[rapper]".

View File

@ -1224,7 +1224,7 @@ Tclmagic_Init(interp)
/* Set $CAD_ROOT as a Tcl variable */
cadroot = getenv("CAD_ROOT");
if (cadroot == NULL) cadroot = CAD_DIR;
if (cadroot == NULL) cadroot = Tcl_GetVar(interp, "CAD_ROOT_DEFAULT", TCL_GLOBAL_ONLY);
Tcl_SetVar(interp, "CAD_ROOT", cadroot, TCL_GLOBAL_ONLY);