[Starkit] Suggestion for an useful improvement
Wojciech Kocjan
wojciech at kocjan.org
Sat Apr 29 16:54:22 CEST 2006
Hello,
I guess many tclkit users will find this very useful. DQkit allows adding
arbitrary kits/directories to auto_path and (dqkit for 8.5 is alpha right
now and is not released yet) tclmodules paths.
It works in a way that you can just add lines like this to your shell rc
script:
DQKITLIBPATH=~/kits/tcllib-1.8.kit:~/kits/tclhttpd.kit
export DQKITLIBPATH
And dqkit will automatically mount + add this kit to path. This way it is
very easy to have shared scripts. Not sure if Tclkit users will like the
idea, but I guess it may be worth incorporating into boot.tcl:
Here's the code for auto_path:
if {[info exists ::env(DQKITLIBPATH)]} {
if {$::tcl_platform(platform) == "windows"} {
set split "\;"
} elseif {$::tcl_platform(platform) == "mac"} {
set split "\;"
} else {
set split ":"
}
foreach dir [split $::env(DQKITLIBPATH) $split] {
if {$debug} {
$dputs "Libpath: $dir"
}
if {[catch {file stat $dir st}]} {continue}
if {$st(type) == "file"} {
if {[catch {vfs::mk4::Mount $dir $dir -readonly}]} {
puts stderr "Unable to mount $dir:\n$::errorInfo"
continue
}
lappend auto_path $dir
catch {
if {[file exists $dir/lib]} {
lappend auto_path $dir/lib
}
}
if {$debug} {
$dputs "Mounted KIT $dir"
}
} elseif {$st(type) == "directory"} {
foreach dirfile [glob -nocomplain -directory $dir *.kit] {
if {[catch {vfs::mk4::Mount $dirfile $dirfile -readonly}]} {
puts stderr "Unable to mount $dirfile:\n$::errorInfo"
continue
}
lappend auto_path $dirfile
catch {
if {[file exists $dirfile/lib]} {
lappend auto_path $dirfile/lib
}
}
if {$debug} {
$dputs "Mounted KIT $dirfile"
}
}
if {$debug} {
$dputs "Adding directory $dir"
}
lappend ::auto_path $dir
}
}
}
And for tcl::tm in 8.5:
if {([package vcompare [package require Tcl] 8.5] >= 0) && [info
exists ::env(DQKITTMPATH)]} {
if {$::tcl_platform(platform) == "windows"} {
set split "\;"
} elseif {$::tcl_platform(platform) == "mac"} {
set split "\;"
} else {
set split ":"
}
foreach dir [split $::env(DQKITTMPATH) $split] {
if {$debug} {
$dputs "Tcl module path: $dir"
}
if {[catch {file stat $dir st}]} {continue}
if {$st(type) == "file"} {
if {[catch {vfs::mk4::Mount $dir $dir -readonly}]} {
puts stderr "Unable to mount $dir:\n$::errorInfo"
continue
}
if {$debug} {
$dputs "Mounted KIT $dir"
}
} elseif {$st(type) == "directory"} {
} else {
puts stderr "Unknown type for $dir - not using for TclModules
path."
continue
}
tcl::tm::roots $dir
}
}
--
Wojciech Kocjan
wojciech at kocjan.org
More information about the Starkit
mailing list