Version 11 of auto_path4platform

Updated 2005-05-30 18:18:23 by wcf3

wcf3 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 I was using 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.

Observation: Some extensions (e.g. tile) depend on the windowing system in use (I'm assuming...). For example, tile might be compiled against X11 or against Aqua on MacOSX. The following code places all extensions for an architecture in one place which makes it impossible to support both Aqua and X11. Admittedly this is a bit of an edge case, but it might be good to append [tk windowingsystem] to the computed library name wcf3 Excellent idea...done!

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 for multi-platform Starkits very 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 directories are generally located in the lib directory of the
 # .vfs and are named such as:
 #               _platform_Darwin-ppc
 #               _platform_Darwin-ppc_classic
 #               _platform_Darwin-ppc_aqua
 #               _platform_Darwin-ppc_x11_32
 #               _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
 #
 # Platform directories will be appended to ::auto_path if they exist,
 # in order from more specific to less specific. The order used starts
 # with platform/windowingsystem/wordsize and progresses with
 # platform/windowingsystem, platform/wordsize, and finishing with
 # just platform. For instance:
 #        _platform_Linux-x86_x11_32
 #        _platform_Linux-x86_x11
 #        _platform_Linux-x86_32
 #        _platform_Linux-x86
 #
 # Created by Chuck Ferril (wcf3) 04/2005
 #
 # Modified by wcf3 05/2005 to include the windowing system as
 # suggested by an unknown person on the wiki. Also allowed for
 # combining multiple layers of platform specific paths and cleaned
 # up the code a bit.
 #

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

         # generate the platform path
         set platform [file join $dir "_platform_[lindex $::tcl_platform(os) 0]-"]
         switch -glob -- $::tcl_platform(machine) {
                 intel                        -
                 x86*                        -
                 i*86*                        { append platform "x86" }
                 "Power*"                { append platform "ppc" }
                 sun4*                        { append platform "sparc" }
                 default                        { append platform "$::tcl_platform(machine)" }
         }

         # generate the windowing system portion
         set windowingsystem ""
         if { [info commands tk] != {} } {
                 set windowingsystem "_[tk windowingsystem]"
         }

         # generate the word size portion
         set wordsize ""
         if { [info exists ::tcl_platform(wordSize)] } {
                 set wordsize "_[expr {$::tcl_platform(wordSize) * 8}]"
         }

         # append paths to ::auto_path starting with more specific and running to less specific
         foreach testdir [list "${platform}${windowingsystem}$wordsize" \
                                                         "${platform}$windowingsystem" \
                                                         "${platform}$wordsize" \
                                                         "$platform"] {
                 if { [file exists $testdir] && [lsearch -exact $::auto_path $testdir] == -1 } {
                         lappend ::auto_path $testdir
                 }
         }
 }

 ::auto_path4platform $dir

LV Just curious, why prefix the directory with _platform_ ? Note, however, I'd love to see something like this added to sdx's default directory layout, generated with the qwrap/unwrap combination.

wcf3 So you can easily exclude it from other packages. My goal was to reverse the -ignore option, and make a '-platform FreeBSD-x86' option that would exclude anything except the _platform_FreeBSD-x86 directory. The _platform_ makes it really clear that it is a platform specific directory tree so that in the future it would just work when a _platform_MrCoffee-z80 shows up.


See also auto_path, starkit,


Category Command