Version 0 of auto_path4platform

Updated 2005-04-12 19:09:42

wcf I've been working on my new AMD 64-bit system (with SuSE 9.2) and learned very quickly that the existing platform specific package loading didn't handle 64-bit stuff at all well. That combined with my desire for a easier way of building platform specific Starpacks that didn't contain the extensions for the platforms not needed by the wrapped runtime...I worked out the following.

Simply place the following *pkgIndex.tcl* file in your xxx.vfs/lib directory and place all platform specific extensions in directories such as xxx.vfs/lib/_platform_Darwin-ppc or xxx.vfs/lib/_platform_Linux-x86_64

 # Extend the auto_path variable to include a platform specific directory.
 # This provides the means for multi-platform Starkits easily. When
 # wrapping a starkit with a runtime binary, you can exclude unneeded
 # platform specific extensions by add the -ignore option to the wrap
 # command as such:
 #
 #   tclkit sdx.kit wrap myapp.freebsd5 -runtime tclkit-freebsd5-x86 \
 #     -ignore _platform_Darwin-ppc -ignore _platform_Linux-x86 \
 #     -ignore _platform_Linux-x86_64 -ignore _platform_Windows-x86
 #
 # Platform specific directories are located in the lib directory of the
 # .vfs and are named like:
 #               _platform_Darwin-ppc
 #               _platform_FreeBSD-x86
 #               _platform_FreeBSD-x86_64
 #               _platform_Linux-x86_32
 #               _platform_Linux-x86_64
 #               _platform_SunOS-sparc
 #               _platform_SunOS-x86_32
 #               _platform_Windows-x86_32
 #
 # The platform directory will be picked by selecting a name based
 # on the platform os, machine, and word size. The word size is
 # optional and will be selected if the directory exists, otherwise it
 # will fall back to the directory without the word size.
 #
 # Created by Chuck Ferril 04/2005
 #

 proc ::auto_path4platform { dir } {
        rename ::auto_path4platform {}

        switch -glob -- $::tcl_platform(machine) {
                sun4*                        { set platformBinary "[lindex $::tcl_platform(os) 0]-sparc" }
                intel                        -
                x86*                        -
                i*86*                        { set platformBinary "[lindex $::tcl_platform(os) 0]-x86" }
                "Power*"                { set platformBinary "[lindex $::tcl_platform(os) 0]-ppc" }
                default                        { set platformBinary "[lindex $::tcl_platform(os) 0]-$::tcl_platform(machine)" }
        }

        set platformDir [file join $dir "_platform_$platformBinary"]
        if { [info exists ::tcl_platform(wordSize)] } {
                set testDir "${platformDir}_[expr {$::tcl_platform(wordSize) * 8}]"
                # if a wordsize specific directory exists, use it instead
                if { [file exists $testDir] } {
                        set platformDir $testDir
                }
        }

        if { [file exists $platformDir] && [lsearch -exact $::auto_path $platformDir] == -1 } {
                lappend ::auto_path $platformDir
        }
 }
 ::auto_path4platform $dir