1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
|
###
# script to build a tclkit
###
#####
# Define procedures
#####
namespace eval ::practcl {}
proc ::cat fname {
set fname [open $fname r]
set data [read $fname]
close $fname
return $data
}
proc ::practcl::localtools {} {
}
proc ::practcl::_isdirectory name {
return [file isdirectory $name]
}
###
# topic: ebd68484cb7f18cad38beaab3cf574e2de5702ea
###
proc ::practcl::_istcl name {
return [string match *.tcl $name]
}
###
# topic: 2e481bd24d970304a1dd0acad3d75198b56c122e
###
proc ::practcl::_istm name {
return [string match *.tm $name]
}
###
# Return true if the pkgindex file contains
# any statement other than "package ifneeded"
# and/or if any package ifneeded loads a DLL
###
proc ::practcl::_pkgindex_directory {path} {
set buffer {}
set pkgidxfile [file join $path pkgIndex.tcl]
if {![file exists $pkgidxfile]} {
# No pkgIndex file, read the source
foreach file [glob -nocomplain $path/*.tm] {
set file [file normalize $file]
set fname [file rootname [file tail $file]]
###
# We used to be able to ... Assume the package is correct in the filename
# No hunt for a "package provides"
###
set package [lindex [split $fname -] 0]
set version [lindex [split $fname -] 1]
###
# Read the file, and override assumptions as needed
###
set fin [open $file r]
set dat [read $fin]
close $fin
# Look for a teapot style Package statement
foreach line [split $dat \n] {
set line [string trim $line]
if { [string range $line 0 9] != "# Package " } continue
set package [lindex $line 2]
set version [lindex $line 3]
break
}
# Look for a package provide statement
foreach line [split $dat \n] {
set line [string trim $line]
if { [string range $line 0 14] != "package provide" } continue
set package [lindex $line 2]
set version [lindex $line 3]
break
}
append buffer "package ifneeded $package $version \[list source \[file join \$dir [file tail $file]\]\]" \n
}
foreach file [glob -nocomplain $path/*.tcl] {
if { [file tail $file] == "version_info.tcl" } continue
set fin [open $file r]
set dat [read $fin]
close $fin
if {![regexp "package provide" $dat]} continue
set fname [file rootname [file tail $file]]
# Look for a package provide statement
foreach line [split $dat \n] {
set line [string trim $line]
if { [string range $line 0 14] != "package provide" } continue
set package [lindex $line 2]
set version [lindex $line 3]
if {[string index $package 0] in "\$ \["} continue
if {[string index $version 0] in "\$ \["} continue
append buffer "package ifneeded $package $version \[list source \[file join \$dir [file tail $file]\]\]" \n
break
}
}
return $buffer
}
set fin [open $pkgidxfile r]
set dat [read $fin]
close $fin
set thisline {}
foreach line [split $dat \n] {
append thisline $line \n
if {![info complete $thisline]} continue
set line [string trim $line]
if {[string length $line]==0} {
set thisline {} ; continue
}
if {[string index $line 0] eq "#"} {
set thisline {} ; continue
}
try {
# Ignore contditionals
if {[regexp "if.*catch.*package.*Tcl.*return" $thisline]} continue
if {[regexp "if.*package.*vsatisfies.*package.*provide.*return" $thisline]} continue
if {![regexp "package.*ifneeded" $thisline]} {
# This package index contains arbitrary code
# source instead of trying to add it to the master
# package index
return {source [file join $dir pkgIndex.tcl]}
}
append buffer $thisline \n
} on error {err opts} {
puts ***
puts "GOOF: $pkgidxfile"
puts $line
puts $err
puts [dict get $opts -errorinfo]
puts ***
} finally {
set thisline {}
}
}
return $buffer
}
proc ::practcl::_pkgindex_path_subdir {path} {
set result {}
foreach subpath [glob -nocomplain [file join $path *]] {
if {[file isdirectory $subpath]} {
lappend result $subpath {*}[_pkgindex_path_subdir $subpath]
}
}
return $result
}
###
# Index all paths given as though they will end up in the same
# virtual file system
###
proc ::practcl::pkgindex_path args {
set stack {}
set buffer {
lappend ::PATHSTACK $dir
}
foreach base $args {
set base [file normalize $base]
set paths [::practcl::_pkgindex_path_subdir $base]
set i [string length $base]
# Build a list of all of the paths
foreach path $paths {
if {$path eq $base} continue
set path_indexed($path) 0
}
set path_indexed($base) 1
set path_indexed([file join $base boot tcl]) 1
#set path_index([file join $base boot tk]) 1
foreach path $paths {
if {$path_indexed($path)} continue
#set thisdir [::fileutil::relative $base $path]
set thisdir [string range $path $i+1 end]
set idxbuf [::practcl::_pkgindex_directory $path]
if {[string length $idxbuf]} {
incr path_indexed($path)
append buffer "set dir \[file join \[lindex \$::PATHSTACK end\] $thisdir\]" \n
append buffer [string trimright $idxbuf] \n
}
}
}
append buffer {
set dir [lindex $::PATHSTACK end]
set ::PATHSTACK [lrange $::PATHSTACK 0 end-1]
}
return $buffer
}
proc read_Config.sh {filename} {
set fin [open $filename r]
set result {}
while {[gets $fin line] >= 0} {
set line [string trim $line]
if {[string index $line 0] eq "#"} continue
if {$line eq {}} continue
catch {
set eq [string first "=" $line]
if {$eq > 0} {
set field [string range $line 0 [expr {$eq - 1}]]
set value [string trim [string range $line [expr {$eq+1}] end] ']
#set value [read_sh_subst [string range $line [expr {$eq+1}] end] $local]
dict set result $field $value
}
} err opts
if {[dict get $opts -code] != 0} {
#puts $opts
puts "Error reading line:\n$line\nerr: $err\n***"
return $err {*}$opts
}
}
return $result
}
proc ::doexec args {
puts [list {*}$args]
exec {*}$args >&@ stdout
}
proc ::domake {args} {
puts [list make {*}$args]
exec make {*}$args >&@ stdout
}
proc ::COMPILE {which cfile {extras {}}} {
set objfile [file normalize [file join $::PWD build [file tail [file dirname $cfile]]_[file rootname [file tail $cfile]].o]]
lappend ::KIT(${which}_OBJS) $objfile
if {[file exists $objfile] && [file mtime $objfile] > [file mtime $cfile]} return
lappend cmd $::KIT(cc) {*}$::KIT(cflags_optimize) {*}$::KIT(shlib_cflags) {*}$::KIT(cflags_warning) {*}$::KIT(extra_cflags) {*}$::KIT(defs) {*}$extras
foreach path $::KIT(INCLUDES) {
lappend cmd -I./[fileutil::relative $::PWD $path]
}
lappend cmd {*}$::KIT(EXTRA_CFLAGS)
lappend cmd -c [fileutil::relative $::PWD $cfile] -o $objfile
puts [list [file tail $cfile] -> [file tail $objfile]]
puts $cmd
exec {*}$cmd >&@ stdout
}
proc ::copyDir {d1 d2} {
#puts [list $d1 -> $d2]
#file delete -force -- $d2
file mkdir $d2
foreach ftail [glob -directory $d1 -nocomplain -tails *] {
set f [file join $d1 $ftail]
if {[file isdirectory $f] && [string compare CVS $ftail]} {
copyDir $f [file join $d2 $ftail]
} elseif {[file isfile $f]} {
file copy -force $f [file join $d2 $ftail]
}
}
}
proc ::practcl::wrap {PWD name vfspath args} {
cd $PWD
if {![file exists $vfspath]} {
file mkdir $vfspath
}
package ifneeded zipfile::mkzip 1.2 [list source [file join $::HERE scripts mkzip.tcl]]
package require zipfile::mkzip
set fout [open [file join $vfspath packages.tcl] w]
puts $fout [list set dir $::KIT(PKGPREFIX)]
set buffer [::practcl::pkgindex_path $::KIT(BASEVFS) $vfspath]
puts $fout $buffer
close $fout
copyDir $::KIT(BASEVFS) $vfspath
copyDir $::KIT(PKGROOT)$::KIT(PKGPREFIX)/lib $vfspath/boot/pkgs
foreach arg $args {
copyDir $arg $vfspath
}
::zipfile::mkzip::mkzip ${name}$::KIT(EXEEXT) -runtime $::TARGET(tclkit_bare) -directory $vfspath
if { $::KIT(platform) ne "windows" } {
file attributes ${name}$::KIT(EXEEXT) -permissions a+x
}
}
#########################################
#
# BUILD THE INTERPRETER ENVIRONMENT
#
#########################################
set HERE [file dirname [file normalize [info script]]]
set PWD [pwd]
lappend auto_path [file normalize [file join $HERE .. tcllib modules]]
lappend auto_path [file normalize [file join $HERE .. odielib modules]]
#package ifneeded zipfile::mkzip 1.2 [list source [file join $::HERE scripts mkzip.tcl]]
package require fileutil
#########################################
#
# BEGIN THE KITBUILDING PROCESS HERE
#
#########################################
set _search_paths {{$PWD} {$PWD ..}}
if {![file exists [file join $::HERE odieConfig.tcl]]} {
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
|
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
###
# script to build a tclkit
###
#########################################
#
# BUILD THE INTERPRETER ENVIRONMENT
#
#########################################
set HERE [file dirname [file normalize [info script]]]
set PWD [pwd]
lappend auto_path [file normalize [file join $HERE .. tcllib modules]]
package ifneeded practcl 0.1.4 [list source [file join $HERE .. odielib modules practcl practcl.tcl]]
package require practcl
#####
# Define procedures
#####
namespace eval ::practcl {}
proc ::COMPILE {which cfile {extras {}}} {
set objfile [file normalize [file join $::PWD build [file tail [file dirname $cfile]]_[file rootname [file tail $cfile]].o]]
lappend ::KIT(${which}_OBJS) $objfile
if {[file exists $objfile] && [file mtime $objfile] > [file mtime $cfile]} return
lappend cmd $::KIT(cc) {*}$::KIT(cflags_optimize) {*}$::KIT(shlib_cflags) {*}$::KIT(cflags_warning) {*}$::KIT(extra_cflags) {*}$::KIT(defs) {*}$extras
foreach path $::KIT(INCLUDES) {
lappend cmd -I./[fileutil::relative $::PWD $path]
}
lappend cmd {*}$::KIT(EXTRA_CFLAGS)
lappend cmd -c [fileutil::relative $::PWD $cfile] -o $objfile
puts [list [file tail $cfile] -> [file tail $objfile]]
puts $cmd
exec {*}$cmd >&@ stdout
}
proc ::practcl::wrap {PWD name vfspath args} {
cd $PWD
if {![file exists $vfspath]} {
file mkdir $vfspath
}
package ifneeded zipfile::mkzip 1.2 [list source [file join $::HERE scripts mkzip.tcl]]
package require zipfile::mkzip
set fout [open [file join $vfspath packages.tcl] w]
puts $fout [list set dir $::KIT(PKGPREFIX)]
set buffer [::practcl::pkgindex_path $::KIT(BASEVFS) $vfspath]
puts $fout $buffer
close $fout
::practcl::copyDir $::KIT(BASEVFS) $vfspath
::practcl::copyDir $::KIT(PKGROOT)$::KIT(PKGPREFIX)/lib $vfspath/boot/pkgs
foreach arg $args {
::practcl::copyDir $arg $vfspath
}
::zipfile::mkzip::mkzip ${name}$::KIT(EXEEXT) -runtime $::TARGET(tclkit_bare) -directory $vfspath
if { $::KIT(platform) ne "windows" } {
file attributes ${name}$::KIT(EXEEXT) -permissions a+x
}
}
#########################################
#
# BEGIN THE KITBUILDING PROCESS HERE
#
#########################################
set _search_paths {{$PWD} {$PWD ..}}
if {![file exists [file join $::HERE odieConfig.tcl]]} {
|
| ︙ | | | ︙ | |
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
|
if {$build(tcl)} {
file mkdir build
file mkdir [file join $::KIT(BASEVFS) boot]
###
# Build a starter VFS for both Tcl and wish
###
if {![file exists $::KIT(TCLSRCDIR)]} {
copyDir $::KIT(ORIG_TCL_SRC_DIR) $::KIT(TCLSRCDIR)
cd $_TclSrcDir
catch {domake distclean}
}
if {$USEMSVC} {
puts "BUILDING Static Tcl"
cd $_TclSrcDir
doexec nmake -f makefile.vc INSTALLDIR=$::KIT(PKGROOT) release
|
|
|
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
|
if {$build(tcl)} {
file mkdir build
file mkdir [file join $::KIT(BASEVFS) boot]
###
# Build a starter VFS for both Tcl and wish
###
if {![file exists $::KIT(TCLSRCDIR)]} {
::practcl::copyDir $::KIT(ORIG_TCL_SRC_DIR) $::KIT(TCLSRCDIR)
cd $_TclSrcDir
catch {domake distclean}
}
if {$USEMSVC} {
puts "BUILDING Static Tcl"
cd $_TclSrcDir
doexec nmake -f makefile.vc INSTALLDIR=$::KIT(PKGROOT) release
|
| ︙ | | | ︙ | |
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
|
domake packages
cd $PWD
}
}
}
if {$build(tk)} {
if {![file exists $::KIT(TKSRCDIR)]} {
copyDir $::KIT(ORIG_TK_SRC_DIR) $::KIT(TKSRCDIR)
cd [file join $_TkSrcDir]
catch {domake distclean}
}
if {$USEMSVC} {
cd $_TkSrcDir
puts "BUILD TK"
doexec nmake -f makefile.vc TCLDIR=[file nativename $::KIT(TCLSRCDIR)] INSTALLDIR=$::KIT(PKGROOT) release
|
|
|
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
|
domake packages
cd $PWD
}
}
}
if {$build(tk)} {
if {![file exists $::KIT(TKSRCDIR)]} {
::practcl::copyDir $::KIT(ORIG_TK_SRC_DIR) $::KIT(TKSRCDIR)
cd [file join $_TkSrcDir]
catch {domake distclean}
}
if {$USEMSVC} {
cd $_TkSrcDir
puts "BUILD TK"
doexec nmake -f makefile.vc TCLDIR=[file nativename $::KIT(TCLSRCDIR)] INSTALLDIR=$::KIT(PKGROOT) release
|
| ︙ | | | ︙ | |
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
|
set ::KIT(OBJS) {}
set ::KIT(INCLUDES) {}
###
# Read tclConfig.sh and tkConfig.sh
###
foreach {array pre file} [list ::TCL tcl $::TARGET(tclConfig.sh) ::TK tk $::TARGET(tkConfig.sh)] {
set l [expr {[string length $pre]+1}]
foreach {field dat} [read_Config.sh $file] {
set field [string tolower $field]
if {[string match ${pre}_* $field]} {
set field [string range $field $l end]
}
set ${array}($field) $dat
if {[info exists ::KIT($field)]} {
if {$::KIT($field) ne $dat} {
|
|
|
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
|
set ::KIT(OBJS) {}
set ::KIT(INCLUDES) {}
###
# Read tclConfig.sh and tkConfig.sh
###
foreach {array pre file} [list ::TCL tcl $::TARGET(tclConfig.sh) ::TK tk $::TARGET(tkConfig.sh)] {
set l [expr {[string length $pre]+1}]
foreach {field dat} [::practcl::read_Config.sh $file] {
set field [string tolower $field]
if {[string match ${pre}_* $field]} {
set field [string range $field $l end]
}
set ${array}($field) $dat
if {[info exists ::KIT($field)]} {
if {$::KIT($field) ne $dat} {
|
| ︙ | | | ︙ | |
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
|
if {[file exists $::KIT(BASEVFS)]} {
file delete -force $::KIT(BASEVFS)
}
puts "***
*** BASE KIT VFS PACKAGES
***"
puts [list COPY [file join $::KIT(PKGROOT) [string trimleft $::KIT(PKGPREFIX) /] lib]]
copyDir [file join $::KIT(PKGROOT) [string trimleft $::KIT(PKGPREFIX) /] lib] [file join $::KIT(BASEVFS) pkgs]
copyDir [file join $::KIT(TCLSRCDIR) library] [file join $::KIT(BASEVFS) boot tcl]
if { $::KIT(platform) eq "windows" } {
set ddedll [glob -nocomplain [file join $_TclSrcDir tcldde*.dll]]
if {$ddedll != {}} {
file copy $ddedll [file join $::KIT(BASEVFS) boot tcl dde]
}
set regdll [glob -nocomplain [file join $_TclSrcDir tclreg*.dll]]
if {$regdll != {}} {
file copy $regdll [file join $::KIT(BASEVFS) boot tcl reg]
}
} else {
file delete -force [file join $::KIT(BASEVFS) boot tcl dde]
file delete -force [file join $::KIT(BASEVFS) boot tcl reg]
}
copyDir [file join $::KIT(TKSRCDIR) library] $::KIT(BASEVFS)/boot/tk
if { $::KIT(platform) eq "windows" } {
set dllsrc [file join $_TkSrcDir [string trim $::TK(dll_file) \"]]
} else {
set dllsrc [file join $_TkSrcDir [string trim $::TK(lib_file) \"]]
}
file copy -force $dllsrc [file join $::KIT(BASEVFS) boot tk]
set fout [open [file join $::KIT(BASEVFS) boot tk pkgIndex.tcl] w]
|
|
|
|
|
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
|
if {[file exists $::KIT(BASEVFS)]} {
file delete -force $::KIT(BASEVFS)
}
puts "***
*** BASE KIT VFS PACKAGES
***"
puts [list COPY [file join $::KIT(PKGROOT) [string trimleft $::KIT(PKGPREFIX) /] lib]]
::practcl::copyDir [file join $::KIT(PKGROOT) [string trimleft $::KIT(PKGPREFIX) /] lib] [file join $::KIT(BASEVFS) pkgs]
::practcl::copyDir [file join $::KIT(TCLSRCDIR) library] [file join $::KIT(BASEVFS) boot tcl]
if { $::KIT(platform) eq "windows" } {
set ddedll [glob -nocomplain [file join $_TclSrcDir tcldde*.dll]]
if {$ddedll != {}} {
file copy $ddedll [file join $::KIT(BASEVFS) boot tcl dde]
}
set regdll [glob -nocomplain [file join $_TclSrcDir tclreg*.dll]]
if {$regdll != {}} {
file copy $regdll [file join $::KIT(BASEVFS) boot tcl reg]
}
} else {
file delete -force [file join $::KIT(BASEVFS) boot tcl dde]
file delete -force [file join $::KIT(BASEVFS) boot tcl reg]
}
::practcl::copyDir [file join $::KIT(TKSRCDIR) library] $::KIT(BASEVFS)/boot/tk
if { $::KIT(platform) eq "windows" } {
set dllsrc [file join $_TkSrcDir [string trim $::TK(dll_file) \"]]
} else {
set dllsrc [file join $_TkSrcDir [string trim $::TK(lib_file) \"]]
}
file copy -force $dllsrc [file join $::KIT(BASEVFS) boot tk]
set fout [open [file join $::KIT(BASEVFS) boot tk pkgIndex.tcl] w]
|
| ︙ | | | ︙ | |