Build Your First Starkit

The steps to build your first starkit are described below.

A starkit contains an entire directory structure, including scripts, libraries, and even data files, that are made available to Tcl as a virtual file system. The unpacked directory can be used during development and testing and then packed into a starkit, and thence into a starpack for distribution and deployment. Tools are available that make it easy to create a starkit.

STEP 1: Get a Tclkit and sdx

SDX, short for Starkit Developer eXtension, is a starkit containing tools for manipulating starkits and starpacks. To invoke it:

sometclkit sdx.kit

Windows note: On Windows the original tclkit.exe is a GUI program, and the corresponding tclkitsh.exe is what to use from the command line. It is useful on Windows to create a batch script implementing an sdx command:

c:\Path\To\tclkitsh.exe c:\Path\To\sdx.kit %1 %2 %3 %4 %5 %6 %7 %8 %9

Then the command can the same as it on *nix:

sdx wrap hello.kit

If this command responds with the error "can't find package starkit" adding read permission to the tclkit executable ma solve the problem. The UNIX/Linux command to do this would be:

chmod u+r sometclkit

STEP 2: Wrap Your Application

It is easy to wrap a single Tcl script. 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]

sdx's "qwrap" option wraps a single script up into a starkit:

tclkit sdx.kit qwrap hello.tcl

The result is a file called hello.kit. On Windows, SDX also creates a file hello.bat. To invoke the script, type "hello" on Windows, or ./hello.kit on Unix. A window will appear that beeps when clicked.

STEP 3: Unwrap Your Application

A wrapped application contains an entire virtual file system. In this case just just one script file, but the resulting directory structure contains all the needed virtual file system support files needed for an application of arbitrary complexity. To see the contents of your starkit, unwrap it:

tclkit sdx.kit unwrap hello.kit

This creates a copy of the directoy file contained in hello.kit', called "hello.vfs/". The startup script is "hello.vfs/main.tcl", and hello.tcl is hello.vfs/lib/app-hello/.

STEP 4: Make Changes

A starkit can be run either wrappe or unwrapped. Each of the follwing commands execute the same application:

tclkit hello.kit
tclkit hello.vfs/main.tcl

Development can proceed using the unwrapped starkit. scripts, data files, or packages under hello.vfs/lib/, are all available to the application.

$starkit::topdir returns the location of the top of the vfs tree, ensuring ensures the correct result regardles of whether the kit is wrapped or unwrapped, or even even perhaps executed under tclsvc or the browser plugin.

STEP 5: Wrap It Up

To wrap up the hello.vfs directory into a starkit:

tclkit sdx.kit wrap hello.kit

Discussion

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 pyk: 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 contain one .dll/.so for each target platform and a pkgindex which loads the correct extension.

dcd: see Building Starkits and Starpacks using a Makefile 2


Jaj0 2017-03-01 22:19:54

Hello, is there possibility to pack additional .exe file into startkit/exe? I have tcl script which calls (by exec) aditional .exe program which is in the same folder. When i copy this additional .exe into .vfs directory and pack kit i cannot run this .exe. APN The operating system does not know about the starkit filesystem or have access to it. You have to explicitly copy the exe, and supporting files if any, to the physical file system and invoke it from there.


JOB 2017-03-02

Maybe this helps you out to solve the problem: Executing programs which are shipped within starpacks