[Starkit] filleting tcllib
Techentin, Robert W.
techentin.robert at mayo.edu
Wed May 4 09:15:42 CEST 2005
> Anyone know what tools would need to be developed to automate
> this? I've always wished that sdx had the ability , as it was
> doing the qwrap, to probe the script, figure out what
> extensions were needed, and to create the various
> subdirectories, etc. needed.
Here is some code that uses the package mechanism to find package
dependencies. It presumes that any tcllib packages have the string 'tcllib'
somewhere in the package ifneeded script. It uses a slave interpreter to
load the package, then compares the list of before and after loaded packages
to figure out what the tcllib package requires.
Guess what? The optimize package can't be loaded into a slave interp. I
ran into this on Monday. Slave interps don't have $::argv0, so this package
script fails.
Bob
--
Bob Techentin techentin.robert at mayo.edu
Mayo Foundation (507) 538-5495
200 First St. SW FAX (507) 284-9171
Rochester MN, 55901 USA http://www.mayo.edu/sppdg/
# recursively find out package dependencies
# Force Tcl to read the pkgIndex.tcl files
catch {package require foobar}
puts "total number of packages = [llength [package names]]"
# Iterate over all known packages
foreach p [lsort [package names]] {
# is this a tcllib package?
set v [lindex [package versions $p] 0]
if {$v eq ""} continue
if {! [string match "*tcllib*" [package ifneeded $p $v]] } {
continue
}
# run this script to get a list of loaded packages
set script {
set result ""
foreach p [package names] {
if {![catch {package present $p}]} {
lappend result $p
}
}
set result
}
# load the package in a slave to see what it requires
set s [interp create]
set beforePackages [$s eval $script]
set packageVersion [$s eval package require $p]
set afterPackages [$s eval $script]
interp delete $s
# print a result
puts -nonewline "$p $packageVersion "
foreach p [lsort $afterPackages] {
if { [lsearch $beforePackages $p] == -1 } {
puts -nonewline "$p "
}
}
puts ""
}
More information about the Starkit
mailing list