From e675decfc01e69668d7c97295989218cc5154e59 Mon Sep 17 00:00:00 2001 From: Tim Edwards Date: Wed, 30 Mar 2022 10:55:08 -0400 Subject: [PATCH] Cleaned up a bunch of stuff around "magicdnull", starting with not linking it to Tk or X11 graphics. Added new command "display" which returns the display type, which is good for finding out if the display is "NULL". Added code to allow the wrapper to be defined for NULL graphics with the Tk console, the main necessities of which are to remove the "openwrapper" command, and to return immediately from a number of tag callback functions. --- VERSION | 2 +- scripts/configure | 34 ++++++++++++++++++++++------------ scripts/configure.in | 33 +++++++++++++++++++++------------ scripts/defs.mak.in | 3 ++- tcltk/Makefile | 3 +-- tcltk/magic.tcl.in | 36 ++++++++++++++++++++++++++++++++++-- tcltk/tclmagic.c | 17 +++++++++++++++++ tcltk/wrapper.tcl | 10 +++++++++- 8 files changed, 107 insertions(+), 31 deletions(-) diff --git a/VERSION b/VERSION index 0513e5cf..e75c3cd7 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -8.3.283 +8.3.284 diff --git a/scripts/configure b/scripts/configure index 33d10b9c..6ced3439 100755 --- a/scripts/configure +++ b/scripts/configure @@ -656,6 +656,7 @@ gr_libs TCL_LIB_DIR TCLSH_EXE WISH_EXE +LIB_SPECS_GRNULL LIB_SPECS_NOSTUB LIB_SPECS INC_SPECS @@ -6073,8 +6074,7 @@ fi if test "x$no_x" = "x"; then usingX11=1 else - echo Unable to find X11---compiling without graphics. - echo Cannot find X11---will attempt to compile anyway. + echo Unable to find X11 or X11 disabled---compiling without graphics. echo Graphics options will be NULL only! if test $usingOGL ; then echo "Cannot use OpenGL/GLX without X11, disabling." @@ -6084,10 +6084,10 @@ else echo "Cannot use Cairo without X11, disabling." usingCairo= fi - if test $usingTcl ; then - echo "Cannot compile TCL version without X11, disabling." - usingTcl= - fi + # if test $usingTcl ; then + # echo "Cannot compile TCL version without X11, disabling." + # usingTcl= + # fi fi # For distributed installs, where the run-time files are installed in a @@ -7290,13 +7290,15 @@ fi if test "x$enable_threads" = "xyes" ; then - usingThreads=1 - $as_echo "#define HAVE_PTHREADS 1" >>confdefs.h + if test $usingX11 ; then + usingThreads=1 + $as_echo "#define HAVE_PTHREADS 1" >>confdefs.h - gr_libs="$gr_libs -lpthread" - gr_srcs="$gr_srcs \${X11THREAD_SRCS}" - gr_hsrcs="" - gr_hprog="" + gr_libs="$gr_libs -lpthread" + gr_srcs="$gr_srcs \${X11THREAD_SRCS}" + gr_hsrcs="" + gr_hprog="" + fi fi # Check whether --enable-route was given. @@ -7703,6 +7705,10 @@ else fi fi +if test $usingX11 ; then + gr_libs="$gr_libs \${X11_LDFLAGS}" +fi + case $target in *-linux*) @@ -7764,6 +7770,7 @@ esac if test $usingTcl ; then LIB_SPECS_NOSTUB="${LIB_SPECS}" + LIB_SPECS_GRNULL="${LIB_SPECS}" # ----------------------------------------------------------------------- # @@ -7805,9 +7812,11 @@ if test $usingTcl ; then "${TCL_LIB_DIR}" = "/usr/lib64" -o \ "${TCL_LIB_DIR}" = "${TK_LIB_DIR}" ; then LIB_SPECS_NOSTUB="${LIB_SPECS_NOSTUB} ${TCL_LIB_SPEC}" + LIB_SPECS_GRNULL="${LIB_SPECS_GRNULL} ${TCL_LIB_SPEC}" LIB_SPECS="${LIB_SPECS} ${TCL_STUB_LIB_SPEC}" else LIB_SPECS_NOSTUB="${LIB_SPECS_NOSTUB} -L${TCL_LIB_DIR} ${TCL_LIB_SPEC}" + LIB_SPECS_GRNULL="${LIB_SPECS_GRNULL} -L${TCL_LIB_DIR} ${TCL_LIB_SPEC}" LIB_SPECS="${LIB_SPECS} -L${TCL_LIB_DIR} ${TCL_STUB_LIB_SPEC}" if test "x${loader_run_path}" = "x" ; then loader_run_path="${TCL_LIB_DIR}" @@ -8181,6 +8190,7 @@ fi + fi if test "$GCC" = "yes" ; then diff --git a/scripts/configure.in b/scripts/configure.in index 65d828e7..1a02a713 100644 --- a/scripts/configure.in +++ b/scripts/configure.in @@ -318,8 +318,7 @@ AC_PATH_XTRA if test "x$no_x" = "x"; then usingX11=1 else - echo Unable to find X11---compiling without graphics. - echo Cannot find X11---will attempt to compile anyway. + echo Unable to find X11 or X11 disabled---compiling without graphics. echo Graphics options will be NULL only! if test $usingOGL ; then echo "Cannot use OpenGL/GLX without X11, disabling." @@ -329,10 +328,10 @@ else echo "Cannot use Cairo without X11, disabling." usingCairo= fi - if test $usingTcl ; then - echo "Cannot compile TCL version without X11, disabling." - usingTcl= - fi + # if test $usingTcl ; then + # echo "Cannot compile TCL version without X11, disabling." + # usingTcl= + # fi fi # For distributed installs, where the run-time files are installed in a @@ -1074,12 +1073,14 @@ AC_ARG_ENABLE(threads, ]) if test "x$enable_threads" = "xyes" ; then - usingThreads=1 - AC_DEFINE(HAVE_PTHREADS) - gr_libs="$gr_libs -lpthread" - gr_srcs="$gr_srcs \${X11THREAD_SRCS}" - gr_hsrcs="" - gr_hprog="" + if test $usingX11 ; then + usingThreads=1 + AC_DEFINE(HAVE_PTHREADS) + gr_libs="$gr_libs -lpthread" + gr_srcs="$gr_srcs \${X11THREAD_SRCS}" + gr_hsrcs="" + gr_hprog="" + fi fi AC_ARG_ENABLE(route, @@ -1326,6 +1327,10 @@ else fi fi +if test $usingX11 ; then + gr_libs="$gr_libs \${X11_LDFLAGS}" +fi + dnl ---------------------------------------------------------------- dnl Define system-specific settings dnl ---------------------------------------------------------------- @@ -1380,6 +1385,7 @@ esac if test $usingTcl ; then LIB_SPECS_NOSTUB="${LIB_SPECS}" + LIB_SPECS_GRNULL="${LIB_SPECS}" # ----------------------------------------------------------------------- # @@ -1421,9 +1427,11 @@ if test $usingTcl ; then "${TCL_LIB_DIR}" = "/usr/lib64" -o \ "${TCL_LIB_DIR}" = "${TK_LIB_DIR}" ; then LIB_SPECS_NOSTUB="${LIB_SPECS_NOSTUB} ${TCL_LIB_SPEC}" + LIB_SPECS_GRNULL="${LIB_SPECS_GRNULL} ${TCL_LIB_SPEC}" LIB_SPECS="${LIB_SPECS} ${TCL_STUB_LIB_SPEC}" else LIB_SPECS_NOSTUB="${LIB_SPECS_NOSTUB} -L${TCL_LIB_DIR} ${TCL_LIB_SPEC}" + LIB_SPECS_GRNULL="${LIB_SPECS_GRNULL} -L${TCL_LIB_DIR} ${TCL_LIB_SPEC}" LIB_SPECS="${LIB_SPECS} -L${TCL_LIB_DIR} ${TCL_STUB_LIB_SPEC}" if test "x${loader_run_path}" = "x" ; then loader_run_path="${TCL_LIB_DIR}" @@ -1743,6 +1751,7 @@ if test $usingTcl ; then AC_SUBST(INC_SPECS) AC_SUBST(LIB_SPECS) AC_SUBST(LIB_SPECS_NOSTUB) + AC_SUBST(LIB_SPECS_GRNULL) AC_SUBST(WISH_EXE) AC_SUBST(TCLSH_EXE) AC_SUBST(TCL_LIB_DIR) diff --git a/scripts/defs.mak.in b/scripts/defs.mak.in index 3e883248..3b155a0a 100755 --- a/scripts/defs.mak.in +++ b/scripts/defs.mak.in @@ -66,6 +66,7 @@ LDDL_FLAGS = ${LDFLAGS} @LDDL_FLAGS@ LD_RUN_PATH = @LD_RUN_PATH@ LIB_SPECS = @LIB_SPECS@ LIB_SPECS_NOSTUB = @LIB_SPECS_NOSTUB@ +LIB_SPECS_GRNULL = @LIB_SPECS_GRNULL@ WISH_EXE = @WISH_EXE@ TCL_LIB_DIR = @TCL_LIB_DIR@ MAGIC_VERSION = `cat ../VERSION | cut -d. -f1-2` @@ -92,7 +93,7 @@ EXEEXT = @EXEEXT@ GR_CFLAGS = @X_CFLAGS@ @gr_cflags@ GR_DFLAGS = @gr_dflags@ -DNDEBUG -GR_LIBS = @gr_libs@ ${X11_LDFLAGS} @X_LIBS@ +GR_LIBS = @gr_libs@ @X_LIBS@ GR_SRCS = @gr_srcs@ GR_HELPER_SRCS = @gr_hsrcs@ GR_HELPER_PROG = @gr_hprog@ diff --git a/tcltk/Makefile b/tcltk/Makefile index 1c764ab0..0248bb70 100644 --- a/tcltk/Makefile +++ b/tcltk/Makefile @@ -56,8 +56,7 @@ magicexec: magicexec.c ${MAGICDIR}/defs.mak magicdnull: magicdnull.c ${MAGICDIR}/defs.mak ${CC} ${CFLAGS} ${CPPFLAGS} ${DFLAGS_NOSTUB} ${LDFLAGS} magicdnull.c \ - -o magicdnull ${LD_RUN_PATH} ${LIB_SPECS_NOSTUB} ${LIBS} \ - ${GR_LIBS} + -o magicdnull ${LD_RUN_PATH} ${LIB_SPECS_GRNULL} ${LIBS} magic.tcl: magic.tcl.in ${MAGICDIR}/defs.mak ${MAGICDIR}/VERSION sed -e /MAGIC_VERSION/s%MAGIC_VERSION%${MAGIC_VERSION}%g \ diff --git a/tcltk/magic.tcl.in b/tcltk/magic.tcl.in index 2bee80a0..895e6e61 100755 --- a/tcltk/magic.tcl.in +++ b/tcltk/magic.tcl.in @@ -359,10 +359,42 @@ drc off if {[info commands magic::openwrapper] != {}} { if {[windownames layout] == {}} { - set winname [magic::openwrapper] + if {[magic::display] == "NULL"} { + magic::openwindow + rename magic::openwrapper magic::_openwrapper + } else { + set winname [magic::openwrapper] + magic::scrollupdate $winname + } magic::techmanager initall - magic::scrollupdate $winname + foreach cellname $celllist { + set fext [file extension $cellname] + puts stdout "handling file entry $cellname extension $fext" + switch $fext { + .lef - + .LEF {lef read $cellname} + .def - + .DEF {def read $cellname} + .gds - + .GDS - + .gds2 - + .GDS2 - + .gdsii - + .GDSII {gds read $cellname} + .cif - + .CIF {cif read $cellname} + .tcl {source $cellname} + .mag - + "" {magic::load $cellname} + default {puts stderr "don't know how to load file $cellname"} + } + } + } +} elseif {[info commands wm] == {}} { + # Magic running with Tcl but in NULL graphics mode. + if {[windownames layout] == {}} { + magic::openwindow foreach cellname $celllist { set fext [file extension $cellname] puts stdout "handling file entry $cellname extension $fext" diff --git a/tcltk/tclmagic.c b/tcltk/tclmagic.c index 5b469d52..6dd0ca41 100644 --- a/tcltk/tclmagic.c +++ b/tcltk/tclmagic.c @@ -710,6 +710,21 @@ _magic_flags(ClientData clientData, return TCL_OK; } +/*--------------------------------------------------------------*/ +/* Pre-initialization: Return the state of the graphics type */ +/* so that certain steps can be taken when NULL graphics are */ +/* specified. */ +/*--------------------------------------------------------------*/ + +static int +_magic_display(ClientData clientData, + Tcl_Interp *interp, int argc, char *argv[]) +{ + /* Set the result to the name of the graphics mode used. */ + Tcl_SetResult(magicinterp, MainDisplayType, NULL); + return TCL_OK; +} + /*--------------------------------------------------------------*/ /* Post-initialization: read in the magic startup files and */ /* load any initial layout. Note that this is not done via */ @@ -1223,6 +1238,8 @@ Tclmagic_Init(interp) (ClientData)NULL, (Tcl_CmdDeleteProc *) NULL); Tcl_CreateCommand(interp, "magic::startup", (Tcl_CmdProc *)_magic_startup, (ClientData)NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateCommand(interp, "magic::display", (Tcl_CmdProc *)_magic_display, + (ClientData)NULL, (Tcl_CmdDeleteProc *) NULL); /* Initialize the command-tag callback feature */ diff --git a/tcltk/wrapper.tcl b/tcltk/wrapper.tcl index f8c3056f..143dde8c 100644 --- a/tcltk/wrapper.tcl +++ b/tcltk/wrapper.tcl @@ -15,7 +15,10 @@ global Glyph global Opts global Winopts -set tk_version $::tk_version +# Don't source this file in a non-graphics (no Tk) environment + +if {[catch {set tk_version $::tk_version}]} {return} + # Simple console commands (like TkCon, but much simpler) if {[lsearch [namespace children] ::tkshell] < 0} { @@ -495,6 +498,7 @@ proc magic::techmanager {{option "update"}} { proc magic::captions {{subcommand {}}} { global Opts + if {[magic::display] == "NULL"} {return} if {$subcommand != {} && $subcommand != "writeable" && $subcommand != "load"} { return } @@ -611,6 +615,7 @@ proc magic::repaintwrapper { win } { # infinite recursion. proc magic::boxview {win {cmdstr ""}} { + if {[magic::display] == "NULL"} {return} if {${cmdstr} == "exists" || ${cmdstr} == "help" || ${cmdstr} == ""} { # do nothing. . . informational only, no change to the box } elseif {${cmdstr} == "remove"} { @@ -685,6 +690,7 @@ proc magic::cursorview {win} { proc magic::toolupdate {win {yesno "yes"} {layerlist "none"}} { global Winopts + if {[magic::display] == "NULL"} {return} if {$win == {}} { set win [magic::windownames] } @@ -897,6 +903,7 @@ proc magic::maketoolbar { framename } { proc magic::techrebuild {winpath {cmdstr ""}} { global Opts + if {[magic::display] == "NULL"} {return} # For NULL window, find all layout windows and apply update to each. if {$winpath == {}} { set winlist [magic::windownames layout] @@ -970,6 +977,7 @@ proc magic::setscrollvalues {win} { proc magic::scrollupdate {win} { + if {[magic::display] == "NULL"} {return} if {[info level] <= 1} { # For NULL window, find current window