Revision: 40470
          http://brlcad.svn.sourceforge.net/brlcad/?rev=40470&view=rev
Author:   starseeker
Date:     2010-09-05 14:08:48 +0000 (Sun, 05 Sep 2010)

Log Message:
-----------
No idea if I'll get away with this, but rip out the C calls to Itcl/Itk init 
routines and replace them with package require calls.  Also need to define 
ITCL_VERSION in brlcad_config.h since we're not directly using the itcl/itk 
headers any more.  Also take out the while loop in bwish and just call the 
routine to add BRL-CAD path info up front - should be harmless if nothing there 
and odds are very good we'll need it.  Much simpler, and also simplifies the 
build logic considerably - no need now for private tcl/tk headers in libtclcad 
and bwish CMake files.

Modified Paths:
--------------
    brlcad/branches/cmake/CMakeLists.txt
    brlcad/branches/cmake/src/bwish/CMakeLists.txt
    brlcad/branches/cmake/src/bwish/main.c
    brlcad/branches/cmake/src/libtclcad/CMakeLists.txt
    brlcad/branches/cmake/src/libtclcad/tclcad.c
    brlcad/branches/cmake/src/libtclcad/tclcadAutoPath.c

Modified: brlcad/branches/cmake/CMakeLists.txt
===================================================================
--- brlcad/branches/cmake/CMakeLists.txt        2010-09-05 01:01:36 UTC (rev 
40469)
+++ brlcad/branches/cmake/CMakeLists.txt        2010-09-05 14:08:48 UTC (rev 
40470)
@@ -877,12 +877,18 @@
                SET(BRLCAD_BUILD_LOCAL_INCRTCL ON)
                SET(ITCL_DEP "itcl")
                SET(ITK_DEP "itk")
+               SET(ITCL_VERSION "3.4")
+               SET(ITK_VERSION "3.3")
        ELSE(NOT BRLCAD_SYSTEM_LIBS_ONLY)
                SET(BRLCAD_BUILD_LOCAL_INCRTCL OFF)
        ENDIF(NOT BRLCAD_SYSTEM_LIBS_ONLY)
 ELSE(NOT ITCL_FOUND OR NOT ITK_FOUND OR BRLCAD_BUILD_LOCAL_ITCL)
        SET(BRLCAD_BUILD_LOCAL_INCRTCL OFF)
+       SET(ITCL_VERSION ${ITCL_PACKAGE_VERSION})
+       SET(ITK_VERSION ${ITK_PACKAGE_VERSION})
 ENDIF(NOT ITCL_FOUND OR NOT ITK_FOUND OR BRLCAD_BUILD_LOCAL_ITCL)
+FILE(APPEND ${CONFIG_H_FILE} "#cmakedefine ITCL_VERSION        
\"${ITCL_VERSION}\"\n")
+FILE(APPEND ${CONFIG_H_FILE} "#cmakedefine ITK_VERSION \"${ITK_VERSION}\"\n")
 
 IF(NOT IWIDGETS_FOUND OR BRLCAD_BUILD_LOCAL_IWIDGETS)
        IF(NOT BRLCAD_SYSTEM_LIBS_ONLY)

Modified: brlcad/branches/cmake/src/bwish/CMakeLists.txt
===================================================================
--- brlcad/branches/cmake/src/bwish/CMakeLists.txt      2010-09-05 01:01:36 UTC 
(rev 40469)
+++ brlcad/branches/cmake/src/bwish/CMakeLists.txt      2010-09-05 14:08:48 UTC 
(rev 40470)
@@ -5,14 +5,6 @@
   ${X11_INCLUDE_DIR}
   ${TCL_INCLUDE_PATH}
   ${TK_INCLUDE_PATH}
-  #TODO - this is needed because tclInt.h isn't being found
-  #by system itclInt.h - located in a deeper subdirectory
-  #not returned by FindTCL.  Either need to ferrit out the
-  #private directories if on system, or determine why the
-  #itcl headers are asking for something they shouldn't be
-  ${BRLCAD_SOURCE_DIR}/src/other/tcl/generic
-  #Same deal for tclUnixPort.h
-  ${BRLCAD_SOURCE_DIR}/src/other/tcl/unix
 )
 
 add_definitions(

Modified: brlcad/branches/cmake/src/bwish/main.c
===================================================================
--- brlcad/branches/cmake/src/bwish/main.c      2010-09-05 01:01:36 UTC (rev 
40469)
+++ brlcad/branches/cmake/src/bwish/main.c      2010-09-05 14:08:48 UTC (rev 
40470)
@@ -31,9 +31,7 @@
 #include "tcl.h"
 
 #ifdef BWISH
-#  include "itk.h"
-#else
-#  include "itcl.h"
+#  include "tk.h"
 #endif
 
 #include "bu.h"
@@ -72,95 +70,39 @@
     int init_tk = 1;
     int init_itcl = 1;
     int init_itk = 1;
+    if (Tcl_Init(interp) == TCL_ERROR) {
+      return TCL_ERROR;
+    }
 
-    /* a two-pass init loop.  the first pass just tries default init
-     * routines while the second calls tclcad_auto_path() to help it
-     * find other, potentially uninstalled, resources.
-     */
-    while (1) {
-
-       /* not called first time through, give Tcl_Init() a chance */
-       if (try_auto_path) {
-           /* Locate the BRL-CAD-specific Tcl scripts, set the auto_path */
-           tclcad_auto_path(interp);
-       }
-
-       /* Initialize Tcl */
-       Tcl_ResetResult(interp);
-       if (init_tcl && Tcl_Init(interp) == TCL_ERROR) {
-           if (!try_auto_path) {
-               try_auto_path=1;
-               continue;
-           }
-           bu_log("Tcl_Init ERROR:\n%s\n", Tcl_GetStringResult(interp));
-           return TCL_ERROR;
-       }
-       init_tcl=0;
-
-       /* warn if tcl_library isn't set by now */
-       if (try_auto_path) {
-           tclcad_tcl_library(interp);
-       }
-
-#ifdef BWISH
-       /* Initialize Tk */
-       Tcl_ResetResult(interp);
-       if (init_tk && Tk_Init(interp) == TCL_ERROR) {
-           if (!try_auto_path) {
-               try_auto_path=1;
-               continue;
-           }
-           bu_log("Tk_Init ERROR:\n%s\n", Tcl_GetStringResult(interp));
-           return TCL_ERROR;
-       }
-       Tcl_StaticPackage(interp, "Tk", Tk_Init, Tk_SafeInit);
-       init_tk=0;
+#ifdef HAVE_TK
+    if (Tk_Init(interp) == TCL_ERROR) {
+      return TCL_ERROR;
+    }
 #endif
 
-       /* Initialize [incr Tcl] */
-       Tcl_ResetResult(interp);
-       if (init_itcl && Itcl_Init(interp) == TCL_ERROR) {
-           if (!try_auto_path) {
-               try_auto_path=1;
-               /* Itcl_Init() leaves initialization in a bad state
-                * and can cause retry failures.  cleanup manually.
-                */
-               Tcl_DeleteCommand(interp, "::itcl::class");
-               Tcl_DeleteNamespace(Tcl_FindNamespace(interp, "::itcl", NULL, 
0));
-               continue;
-           }
-           bu_log("Itcl_Init ERROR:\n%s\n", Tcl_GetStringResult(interp));
-           return TCL_ERROR;
-       }
-       Tcl_StaticPackage(interp, "Itcl", Itcl_Init, Itcl_SafeInit);
-       init_itcl=0;
 
-#ifdef BWISH
-       /* Initialize [incr Tk] */
-       Tcl_ResetResult(interp);
-       if (init_itk && Itk_Init(interp) == TCL_ERROR) {
-           if (!try_auto_path) {
-               try_auto_path=1;
-               continue;
-           }
-           bu_log("Itk_Init ERROR:\n%s\n", Tcl_GetStringResult(interp));
-           return TCL_ERROR;
-       }
-       Tcl_StaticPackage(interp, "Itk", Itk_Init, (Tcl_PackageInitProc *) 
NULL);
-       init_itk=0;
-#endif
+    /* Go ahead and add the BRL-CAD paths - if there is anything
+     * installed there we want to use it in preference to anything
+     * in system path */
+   /* if (Tcl_Eval(interp, "set auto_path [linsert $auto_path 0 
/usr/brlcad/lib]") != TCL_OK) {
+       bu_log("Tcl_Eval ERROR:\n%s\n", Tcl_GetStringResult(interp));
+       return TCL_ERROR;
+    }*/
+    tclcad_auto_path(interp);
 
-       /* don't actually want to loop forever */
-       break;
+    /* Initialize Tcl */
+    if (Tcl_Eval(interp, "package require Itcl") != TCL_OK) {
+       bu_log("Tcl_Eval ERROR:\n%s\n", Tcl_GetStringResult(interp));
+       return TCL_ERROR;
+    }
 
-    } /* end iteration over Init() routines that need auto_path */
-    Tcl_ResetResult(interp);
-
-    /* if we haven't loaded by now, load auto_path so we find our tclscripts */
-    if (!try_auto_path) {
-       /* Locate the BRL-CAD-specific Tcl scripts */
-       tclcad_auto_path(interp);
+#ifdef BWISH
+    /* Initialize Tk */
+    if (Tcl_Eval(interp, "package require Itk") != TCL_OK) {
+       bu_log("Tcl_Eval ERROR:\n%s\n", Tcl_GetStringResult(interp));
+       return TCL_ERROR;
     }
+#endif  /* BWISH */
 
 #ifdef IMPORT_ITCL
     /* Import [incr Tcl] commands into the global namespace. */

Modified: brlcad/branches/cmake/src/libtclcad/CMakeLists.txt
===================================================================
--- brlcad/branches/cmake/src/libtclcad/CMakeLists.txt  2010-09-05 01:01:36 UTC 
(rev 40469)
+++ brlcad/branches/cmake/src/libtclcad/CMakeLists.txt  2010-09-05 14:08:48 UTC 
(rev 40470)
@@ -21,14 +21,6 @@
   ${X11_INCLUDE_DIR}
   ${TCL_INCLUDE_PATH}
   ${TK_INCLUDE_PATH}
-  #TODO - this is needed because tclInt.h isn't being found
-  #by system itclInt.h - located in a deeper subdirectory
-  #not returned by FindTCL.  Either need to ferrit out the
-  #private directories if on system, or determine why the
-  #itcl headers are asking for something they shouldn't be
-  ${BRLCAD_SOURCE_DIR}/src/other/tcl/generic
-  #Same deal for tclUnixPort.h
-  ${BRLCAD_SOURCE_DIR}/src/other/tcl/unix
 )
 
 add_definitions(

Modified: brlcad/branches/cmake/src/libtclcad/tclcad.c
===================================================================
--- brlcad/branches/cmake/src/libtclcad/tclcad.c        2010-09-05 01:01:36 UTC 
(rev 40469)
+++ brlcad/branches/cmake/src/libtclcad/tclcad.c        2010-09-05 14:08:48 UTC 
(rev 40470)
@@ -28,12 +28,7 @@
 
 #define RESOURCE_INCLUDED 1
 #include <tcl.h>
-#include <itcl.h>
 
-#ifdef HAVE_TK
-#  include <itk.h>
-#endif
-
 #include "bio.h"
 
 #include "bu.h"
@@ -64,16 +59,16 @@
     tclcad_auto_path(interp);
 
     /* Initialize [incr Tcl] */
-    if (Itcl_Init(interp) == TCL_ERROR) {
-       bu_log("Itcl_Init ERROR:\n%s\n", Tcl_GetStringResult(interp));
-       return TCL_ERROR;
+    if (Tcl_Eval(interp, "package require Itcl") != TCL_OK) {
+      bu_log("Tcl_Eval ERROR:\n%s\n", Tcl_GetStringResult(interp));
+      return TCL_ERROR;
     }
-
+   
 #ifdef HAVE_TK
     /* Initialize [incr Tk] */
-    if (Itk_Init(interp) == TCL_ERROR) {
-       bu_log("Itk_Init ERROR:\n%s\n", Tcl_GetStringResult(interp));
-       return TCL_ERROR;
+    if (Tcl_Eval(interp, "package require Itk") != TCL_OK) {
+      bu_log("Tcl_Eval ERROR:\n%s\n", Tcl_GetStringResult(interp));
+      return TCL_ERROR;
     }
 #endif
 

Modified: brlcad/branches/cmake/src/libtclcad/tclcadAutoPath.c
===================================================================
--- brlcad/branches/cmake/src/libtclcad/tclcadAutoPath.c        2010-09-05 
01:01:36 UTC (rev 40469)
+++ brlcad/branches/cmake/src/libtclcad/tclcadAutoPath.c        2010-09-05 
14:08:48 UTC (rev 40470)
@@ -34,9 +34,7 @@
 
 #ifdef HAVE_TK
 #  include "tk.h"
-#  include "itk.h"
 #endif
-#include "itcl.h"
 
 /* incrTcl prior to 3.3 doesn't provide ITK_VERSION */
 #ifndef ITK_VERSION


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
This SF.net Dev2Dev email is sponsored by:

Show off your parallel programming skills.
Enter the Intel(R) Threading Challenge 2010.
http://p.sf.net/sfu/intel-thread-sfd
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to