Artifact 91ad13b755f9dcb5ffe09279524a2398ef524b34:
Wiki page
[
Anatomy of a Toadkit project] by
hypnotoad
2014-04-29 12:43:59.
D 2014-04-29T12:43:59.963
L Anatomy\sof\sa\sToadkit\sproject
P 4916efc6a7dc3d38615984146d32b4cc97107b89
U hypnotoad
W 2126
Toadkits are essentially a specially formatted zip file. The nice thing about the zip file format is that the table of contents is located at the back of the file. What we do for toadkits is to use a parlor trick to tack a zipfile to the end of an application binary. But we do it in a way that the executable portion isn't listed in the table of contents. This the operating system treats the file as an executable. And the zip file format treats it as a fully functioning zip file.
<p>
To be able to load the zip file we have to include a little extra code into Tcl/Tk. This code allows Tcl to mount the executable as a zip virtual file system. We also include a little bootloader that tells the system to kick of a file called "main.tcl" at the root of that file system.
<p>
Toadkit projects are a directory, and here are the major players:
<table border=1>
<tr><td>Makefile</td><td>A script compatible with the <b>make</b> system. It's what allows us to call <i>make</i> from the command line and magically create things.</td></tr>
<tr><td>src/</td><td>The directory to be populated with your custom code.</td></tr>
<tr><td>src/main.tcl</td><td>This file is called by the toadkit after Tcl/Tk initializes and mounts the vfs. Any directory structure is preserved in the final kit, and accessible from the /zvfs mountpoint. This file can and should be modified to suit your application.</td></tr>
</table>
<p>
During the process other files are created:
<table border=1>
<tr><td><b>PROJECTNAME</b>.vfs/</td><td>A directory structure that combines your /src directory with ~/odie/zipdir (which contains all of the binary packages that are bundled with the toadkit.)</td></tr>
<tr><td><b>PROJECTNAME</b>.vfs/packages.tcl</td><td>A manifest of all of the packages included with this kit. It should be sourced by your main.tcl:
<pre>
source /zvfs/packages.tcl
</pre></td></tr>
<tr><td><b>PROJECTNAME</b>(.exe)</td><td>The final executable.</td></tr>
<tr><td><b>PROJECTNAME</b>.zkit</td><td>A version of your package which can be loaded by a VFS enabled TclSh/Wish using the source command</td></tr>
</table>
Z 1c83757aa41935bab3b7175f1f3b4779