Deploying With Freewrap

This page is for tips about deploying standalone applications with Freewrap. Please add to it!

I (EKB) have decided to stick with Freewrap, in spite of the excitement over Starkits, partly because it's got BLT already packaged and ready to go, and partly because it works just fine and I'm used to it.

Some deployment tips

I develop on Windows, and create build scripts that are a mix of batch files and tcl scripts. One quick-and-dirty small project looks like this:

The first thing I do is to modify freewrap.exe so that it has the icon for my program and information about my program. I went ahead and paid the $40 or so for Heaventools' Resource Tuner [L1 ] to do it.

The batch file _BuildAll.bat has contents

 call replaceSnippets.bat
 call wrapDrivingForce.bat

(In larger projects, "_BuildAll.bat" checks out all the files from a CVS or Subversion repository and creates an installer using InnoSetup.)

This batch file calls two other batch files: replaceSnippets.bat:

 tclsh ReplaceSnippets.script "drivingforce.tcl" snippets.txt
 del "drivingforce.tcl"
 ren "drivingforce_snipped.tcl" "drivingforce.tcl"

and wrapDrivingForce.bat:

 freewrap drivingforce.tcl drivingforce.ico

The "wrapDrivingForce.bat" batch file is standard for calling freewrap. The "replaceSnippets.bat" file calls a utility that I use to convert from a development version of a script to a freewrap-ready release version. It goes through and replaces anything between "## SNIP" and "## PINS" with corresponding code in a "snippets.txt" file. For example, in this file, it replaces

 ## SNIP
 set appdir [file dirname [info script]]
 ## PINS


 ## SNIP
    wm iconbitmap . -default drivingforce.ico
 ## PINS


 ## SNIP
 set appdir [file dirname [info nameofexecutable]]
 ## PINS


 ## SNIP
    wm iconbitmap . -default "/development/DrivingForce/drivingforce.ico"
 ## PINS

The ReplaceSnippets.script code is available under the No Obligation License (NOL), and is:

 # Look for sections bracketed by "## SNIP" & "## PINS" and from
 # second arg into first arg. Put into "firstarg_snipped.tcl"
 # (c) 2005 Eric Kemp-Benedict
 # Released under the "No Obligation License":
 #    "No obligation for you, no obligation for me."

 # This is called from a batch file or other automatic process, so
 # checking is minimal!

 set initfile [lindex $argv 0]
 set snipfile [lindex $argv 1]
 set outfile "[file rootname $initfile]_snipped.tcl"

 set infp [open $initfile r]
 set snfp [open $snipfile r]
 set outfp [open $outfile w]

 set insnip_in false
 set insnip_snip false

 while {[gets $infp currline] != -1} {
    if {$insnip_in} {
        if {[regexp -- {##\s*PINS} $currline] == 1} {
            set insnip_in false
    if {[regexp -- {##\s*SNIP} $currline] == 1} {
        set insnip_in true
        # Read from snip file
        while {[gets $snfp snipline] != -1} {
            if {$insnip_snip} {
                if {[regexp -- {##\s*PINS} $snipline] == 1} {
                    set insnip_snip false
                puts $outfp $snipline
            } elseif {[regexp -- {##\s*SNIP} $snipline] == 1} {
                set insnip_snip true
    puts $outfp $currline

 close $infp
 close $snfp
 close $outfp

"Internet Explorer doesn't execute my Tcl application after downloading it"

Category Deployment