Version 7 of Complex Pure Tcl Starkit Example

Updated 2007-09-07 22:53:26 by MG

[I was excited to find this page then disappointed when I read it. Does anyone have a "simple" example of a "complex" Starkit?]

[Apparently this page will be filled in later... Was it meant to contain material from some paper on Starkits?]

[Several complex pure Tcl Starkits can be found in the sdarchive [L1 ], but which would constitute good examples?]


The following was added to this page 2006-11-07, but looks more like a critcl example.

 package require critcl
 critcl::cproc abc {} Tcl_Obj* {
    char test[4] = "abc";
    Tcl_Obj * rv = Tcl_NewStringObj ("abc", 3);
    Tcl_IncrRefCount (rv);
    return rv;
 }
 critcl::cproc 123 {} Tcl_Obj* {
    char test[3] = {1, 2, 3};
    Tcl_Obj * obj = Tcl_NewByteArrayObj (test, 3);
    Tcl_IncrRefCount (obj);
    return obj;
 }
 puts [abc]
 binary scan [123] H* result
 puts $result

MG has recently started looking at Starkits and Starpacks for the first time, for deployment of an app he's working on using Tcl 8.5 that he plans to deploy on Windows, Linux and MacOS X (hopefully). It has (currently) about 5 separate Tcl files, and also 2 binary extensions on Windows only. And it couldn't have been easier to set up (somewhat to my suprise, if I'm completely honest).

Using the instructions to help you Build Your First Starkit, I wrapped the main file of my program into a Starkit, then unwrapped it again (so I had a "myapp.vfs" directory). At this point, the Starkit just sourced the other Tcl files from the same folder.

Then I moved all my extra Tcl files into myapp.vfs/lib/app-myapp, and edited the pkgIndex.tcl file in that folder (which contained the single line)

  package ifneeded app-myapp 1.0 [list source [file join $dir myapp.tcl]]

to add

  package ifneeded app-myapp-file1 1.0 [list source [file join $dir myapp-file1.tcl]]
  package ifneeded app-myapp-file2 1.0 [list source [file join $dir myapp-file2.tcl]]
  # etc

Each of the extra files for my app then got

  package provide app-myapp-file<num>.tcl

added to the bottom of them, and in my main file (now myapp.vfs/lib/app-myapp/myapp.tcl), I changed

  source myapp-file1.tcl

to

  package require app-myapp-file1 [package versions app-myapp]

And that was it. I re-wrapped it into a Starkit (and later, using the example on How to create my first Starpack, a starpack (.exe) for Windows), and it ran perfectly. (For me, including binary extensions was just a case of copying the .dlls into myapp.vfs/lib/app-myapp/ and adding package ifneeded statements for them into the pkgIndex.tcl file; there are more complications if you need to deploy compiled extensions on more than one platform, but that's for another page and, thankfully, not something I needed.)

Hopefully that rambling will help someone else planning to do the same thing. If I ever get the app finished, I'll try and remember to post a link here, in case anyone wants to take a look in the star[kit/pack].


Category Tclkit