STEP 1: Get Tclkit and sdxNote: the tclkit web site is now at Google Code : check there first for tclkit and sdx.
- For Windows, get tclkit.exe and tclkitsh.exe
- For Linux, get one of the tclkit-*-linux-ix86.gz files
- For Mac OS X, get a tclkit-*-darwin-univ.gz - these are universal (fat) binaries.
- For everything else, look around for something relevant.
gzip -d tclkit-*.gz mv tclkit-* tclkit chmod +x tclkitOn UNIX/Linux/MacOS X, be certain that tclkit is in a directory that is in your $PATH.SDX is the Starkit Developer eXtension. It is a starkit containing tools for manipulating Starkits and Starpacks. Get sdx.kit from http://tclkit.googlecode.com/ (see the Downloads section on the right). Since it's a starkit, you run it with the command
tclkit sdx.kitWindows note: On Windows you need to use tclkitsh.exe. tclkit.exe is a GUI program and you need a command-line program when using sdx. It is useful on Windows to create a batch script so that you have a sdx command. eg: create sdx.cmd containing:
@c:\Path\To\tclkitsh.exe c:\Path\To\sdx.kit %1 %2 %3 %4 %5 %6 %7 %8 %9Then you can just issue sdx wrap hello.kit like the unix users.If this command responds with the error "can't find package starkit" then you need to add read permissions to your tclkit binary. On UNIX/Linux type systems, this would be via:
chmod u+r tclkitYou now have STARKIT TECHNOLOGY!!Note that ActiveTcl also contains tclkit files but call them basekit. sdx can be driven with basekit just as with tclkit. Basekit executables are mostly identical to tclkit executables.
STEP 2: Wrap Your ApplicationYou can easily wrap any single file Tcl application. For this example, create a file named "hello.tcl" and use the following two lines of text as its contents:
package require Tk pack [button .b -text "Hello World!" -command bell]Use sdx's "qwrap" option to quickly turn a single script into a starkit:
tclkit sdx.kit qwrap hello.tclThe result is a file called hello.kit. On Windows, SDX will also create a file hello.bat. Type "hello" on Windows, or "./hello.kit" on Unix. You'll see a window with button which beeps when clicked
STEP 3: Unwrap Your ApplicationYour wrapped application contains an entire virtual file system. In this case, we have just one script file, but even this simple application has all the virtual file system support you would get with a complex applcation. To see the contents of your starkit, unwrap it like this.
tclkit sdx.kit unwrap hello.kitThis creates a copy of hello.kit's virtual file system in a directory named "hello.vfs/". You will find the startup script at "hello.vfs/main.tcl", and your hello.tcl script has been converted into a package in hello.vfs/lib/app-hello/.
STEP 4: Make ChangesOne of the benefits of starkit applications is that they run exactly the same way wrapped or unwrapped. Both these commands will execute your application, and your application will execute identically.
tclkit hello.kit tclkit hello.vfs/main.tclSo you can continue application development in the unwrapped starkit. Add scripts, data files, or packages under hello.vfs/lib/, and they will all be found by your application. Work on the unwrapped application until it's just right.If your application needs to know the location of the top of the vfs tree it should use the variable $starkit::topdir which gets set appropriately when the starkit is initialized. This ensures the correct result is obtained for any of the ways a tclkit can run your code. Either as a starkit, a starpack or unwrapped or even under tclsvc or the browser plugin.
STEP 5: Wrap It UpWhen you are ready to create an updated starkit, do:
tclkit sdx.kit wrap hello.kitThis takes hello.vfs/ as input, and overwrites hello.kit as before, creating an application that can be run with "hello" (Windows) or "./hello.kit" (Unix)Notice that your application development structure (hello.vfs/) is exactly the same as the starkit. And your starkit will run on any plaform with a Tclkit binary runtime because in this case, the application makes use of only scripts in the starkit and packages in tclkit.
RLH 2005-07-22: For Windows 2000/XP I create these simple bat files to help me create a starkit. It is a given that I am not a very good bat creator. : )
@echo off title CREATING STARKIT FOR POPUPS SCRIPT echo. echo "Wrapping and Unwrapping popups..." tclsh.exe c:\Tcl\bin\sdx.kit qwrap popups.tcl tclsh.exe c:\Tcl\bin\sdx.kit unwrap popups.kit echo. echo "Copying mime into the archive" xcopy C:\Tcl\lib\tcllib1.7\mime "C:\Path_to_vfs\Popups.vfs\lib\mime\" /s /v /y echo. echo "Copying MD5 into the archive" xcopy C:\Tcl\lib\tcllib1.7\md5 "C:\Path_to_vfs\Popups.vfs\lib\MD5\" /s /v /y echo. echo "Copying base64 into the archive" xcopy C:\Tcl\lib\tcllib1.7\base64 "C:\Path_to_vfs\Popups.vfs\lib\base64\" /s /v /y echo. echo "Creating the EXE file" tclsh.exe c:\Tcl\bin\sdx.kit wrap popups.exe -runtime c:\Tcl\bin\tclkitsh.exe echo. echo "Deleting unnecessary files..." del popups.bat /q del popups.kit /q rmdir popups.vfs /s /q echo. echo "Popups executable built..."MHo: Take a look at Windows batch script for 'compiling' starpacks.RPH: Is it possible to cross-build a StarKit? If so how is it done?MSH: By default a starkit is cross-platform as it needs a local tclkit executable to run on a platform, except binary extensions which must be stubs aware and have each .dll/.so for the required platforms and a pkgindex which loads the correct extension.dcd: see Building Starkits and Starpacks using a Makefile 2