Re: Adding tcl packages to tkkit for use in Tkx
[email protected] (Jeff Hobbs) Thu, 05 Jan 2012 09:36:44 -0800
| Newsgroups | perl.tcltk |
|---|---|
| Message-ID | <[email protected]> |
On 05/01/2012 1:42 AM, Laurence Anthony wrote: > I've tried many times to add Tcl packages to the Tkkit in ActiveState Perl > to use with a standalone Tkx application (built with perlapp). The only > documentation online seems to be the long thread below, which contains some > code snippets and various corrections (but doesn't seem to be complete). > http://www.nntp.perl.org/group/perl.tcltk/2008/11/msg187.html > > Can someone post a definitive code snippet that will allow a package that > is installed into Tcl (e.g. pdf4tcl) to be added to the Tkkit. It's a rather simple script (just a few lines), but I've attached something that adds more magic and assistance. Jeff
extend-tkkit.tcl
(text/plain, 1.5 KB)
#!/usr/bin/env tclsh
# Extend ActivePerl Tkx tkkits
#
# Copyright 2011 Jeffrey Hobbs, ActiveState Software Inc.
package require Tcl 8.5
package require vfs::mk4
proc usage {{msg {}}} {
if {$msg ne ""} { puts stderr $msg }
puts stderr "Usage: $::argv0 ?-kit tkkit? -add module_dir ?-add ...?"
exit
}
if {$argc < 2 || $argc % 2} { usage }
set tkkit ""
set modules [list]
foreach {key val} $argv {
if {$key eq "-kit"} {
if {![file readable $val]} { usage "tkkit '$val' doesn't exist" }
set tkkit $val
} elseif {$key eq "-add"} {
if {![file isdirectory $val]} {
usage "No such directory '$val'"
}
lappend modules $val
if {![file readable $val/pkgIndex.tcl]} {
puts stderr "WARN: no pkgIndex.tcl in module dir '$val'"
}
} else {
usage
}
}
if {$tkkit eq ""} {
set tkkit [exec perl -MTcl -e {print $Tcl::DL_PATH;}]
}
if {![file readable $tkkit]} { usage "tkkit '$val' doesn't exist" }
if {[llength $modules] == 0} { usage "no modules specified" }
puts stdout "Extending tkkit '$tkkit' with module(s) $modules"
file attributes $tkkit -readonly 0 ; # needs to be writable
vfs::mk4::Mount $tkkit tkkit ; # mounts file as dir 'tkkit'
set target [pwd]/tkkit/lib
if {![file isdirectory $target]} {
puts stderr "integrity failure in tkkit structure (no lib dir)"
vfs::unmount tkkit
exit
}
foreach module $modules {
file copy -force $module $target
}
puts stdout "lib: [glob -tails -directory $target *]"
vfs::unmount tkkit
puts stdout "Completed"
exit