Artifact 31a964e6439d909529721e26ad8de11fbb0e8a48:
- File
kitdll/buildsrc/kitdll-0.0/boot.tcl
— part of check-in
[e98c176999]
at
2010-10-01 20:20:09
on branch trunk
— Updated to mount vfs::zip VFS from DLL into /.KITDLL_USER
Updated to mount vfs::zip VFS from application into /.KITDLL_APP
Minor cleanup and added comments (user: rkeene, size: 3116) [annotate] [blame] [check-ins using]
0000: 70 72 6f 63 20 74 63 6c 49 6e 69 74 20 7b 7d 20 proc tclInit {} 0010: 7b 0a 09 72 65 6e 61 6d 65 20 74 63 6c 49 6e 69 {..rename tclIni 0020: 74 20 7b 7d 0a 0a 09 67 6c 6f 62 61 6c 20 61 75 t {}...global au 0030: 74 6f 5f 70 61 74 68 20 74 63 6c 5f 6c 69 62 72 to_path tcl_libr 0040: 61 72 79 20 74 63 6c 5f 6c 69 62 50 61 74 68 0a ary tcl_libPath. 0050: 09 67 6c 6f 62 61 6c 20 74 63 6c 5f 76 65 72 73 .global tcl_vers 0060: 69 6f 6e 0a 20 20 0a 09 23 20 53 65 74 20 70 61 ion. ..# Set pa 0070: 74 68 20 77 68 65 72 65 20 74 6f 20 6d 6f 75 6e th where to moun 0080: 74 20 56 46 53 0a 09 73 65 74 20 74 63 6c 5f 6d t VFS..set tcl_m 0090: 6f 75 6e 74 70 6f 69 6e 74 20 22 2f 2e 4b 49 54 ountpoint "/.KIT 00a0: 44 4c 4c 5f 54 43 4c 22 0a 0a 09 73 65 74 20 74 DLL_TCL"...set t 00b0: 63 6c 5f 6c 69 62 72 61 72 79 20 5b 66 69 6c 65 cl_library [file 00c0: 20 6a 6f 69 6e 20 24 74 63 6c 5f 6d 6f 75 6e 74 join $tcl_mount 00d0: 70 6f 69 6e 74 20 6c 69 62 20 74 63 6c 24 74 63 point lib tcl$tc 00e0: 6c 5f 76 65 72 73 69 6f 6e 5d 0a 09 73 65 74 20 l_version]..set 00f0: 74 63 6c 5f 6c 69 62 50 61 74 68 20 5b 6c 69 73 tcl_libPath [lis 0100: 74 20 24 74 63 6c 5f 6c 69 62 72 61 72 79 20 5b t $tcl_library [ 0110: 66 69 6c 65 20 6a 6f 69 6e 20 24 74 63 6c 5f 6d file join $tcl_m 0120: 6f 75 6e 74 70 6f 69 6e 74 20 6c 69 62 5d 5d 0a ountpoint lib]]. 0130: 0a 09 23 20 67 65 74 20 72 69 64 20 6f 66 20 61 ..# get rid of a 0140: 20 62 75 69 6c 64 20 72 65 73 69 64 75 65 0a 09 build residue.. 0150: 75 6e 73 65 74 20 2d 6e 6f 63 6f 6d 70 6c 61 69 unset -nocomplai 0160: 6e 20 3a 3a 74 63 6c 44 65 66 61 75 6c 74 4c 69 n ::tclDefaultLi 0170: 62 72 61 72 79 0a 0a 09 23 20 74 68 65 20 66 6f brary...# the fo 0180: 6c 6c 6f 77 69 6e 67 20 63 6f 64 65 20 6f 6e 6c llowing code onl 0190: 79 20 67 65 74 73 20 65 78 65 63 75 74 65 64 20 y gets executed 01a0: 6f 6e 63 65 20 6f 6e 20 73 74 61 72 74 75 70 0a once on startup. 01b0: 09 69 66 20 7b 5b 69 6e 66 6f 20 65 78 69 73 74 .if {[info exist 01c0: 73 20 3a 3a 69 6e 69 74 56 46 53 5d 7d 20 7b 0a s ::initVFS]} {. 01d0: 09 09 73 65 74 20 76 66 73 48 61 6e 64 6c 65 72 ..set vfsHandler 01e0: 20 5b 6c 69 73 74 20 3a 3a 76 66 73 3a 3a 6b 69 [list ::vfs::ki 01f0: 74 64 6c 6c 3a 3a 76 66 73 68 61 6e 64 6c 65 72 tdll::vfshandler 0200: 20 74 63 6c 5d 0a 0a 09 09 23 20 61 6c 74 65 72 tcl]....# alter 0210: 20 70 61 74 68 20 74 6f 20 66 69 6e 64 20 65 6e path to find en 0220: 63 6f 64 69 6e 67 73 0a 09 09 69 66 20 7b 5b 69 codings...if {[i 0230: 6e 66 6f 20 74 63 6c 76 65 72 73 69 6f 6e 5d 20 nfo tclversion] 0240: 65 71 20 22 38 2e 34 22 7d 20 7b 0a 09 09 09 6c eq "8.4"} {....l 0250: 6f 61 64 20 7b 7d 20 70 77 62 0a 09 09 09 6c 69 oad {} pwb....li 0260: 62 72 61 72 79 70 61 74 68 20 5b 69 6e 66 6f 20 brarypath [info 0270: 6c 69 62 72 61 72 79 5d 0a 09 09 7d 20 65 6c 73 library]...} els 0280: 65 20 7b 0a 09 09 09 65 6e 63 6f 64 69 6e 67 20 e {....encoding 0290: 64 69 72 73 20 5b 6c 69 73 74 20 5b 66 69 6c 65 dirs [list [file 02a0: 20 6a 6f 69 6e 20 5b 69 6e 66 6f 20 6c 69 62 72 join [info libr 02b0: 61 72 79 5d 20 65 6e 63 6f 64 69 6e 67 5d 5d 20 ary] encoding]] 02c0: 3b 23 20 54 49 50 20 32 35 38 0a 09 09 7d 0a 0a ;# TIP 258...}.. 02d0: 09 09 23 20 66 69 78 20 73 79 73 74 65 6d 20 65 ..# fix system e 02e0: 6e 63 6f 64 69 6e 67 2c 20 69 66 20 69 74 20 77 ncoding, if it w 02f0: 61 73 6e 27 74 20 70 72 6f 70 65 72 6c 79 20 73 asn't properly s 0300: 65 74 20 75 70 20 28 32 30 30 32 30 37 2e 30 30 et up (200207.00 0310: 34 20 62 75 67 29 0a 09 09 69 66 20 7b 5b 65 6e 4 bug)...if {[en 0320: 63 6f 64 69 6e 67 20 73 79 73 74 65 6d 5d 20 65 coding system] e 0330: 71 20 22 69 64 65 6e 74 69 74 79 22 7d 20 7b 0a q "identity"} {. 0340: 09 09 09 69 66 20 7b 5b 69 6e 66 6f 20 65 78 69 ...if {[info exi 0350: 73 74 73 20 3a 3a 74 63 6c 6b 69 74 5f 73 79 73 sts ::tclkit_sys 0360: 74 65 6d 5f 65 6e 63 6f 64 69 6e 67 5d 20 26 26 tem_encoding] && 0370: 20 24 3a 3a 74 63 6c 6b 69 74 5f 73 79 73 74 65 $::tclkit_syste 0380: 6d 5f 65 6e 63 6f 64 69 6e 67 20 21 3d 20 22 22 m_encoding != "" 0390: 7d 20 7b 0a 09 09 09 09 63 61 74 63 68 20 7b 0a } {.....catch {. 03a0: 09 09 09 09 09 65 6e 63 6f 64 69 6e 67 20 73 79 .....encoding sy 03b0: 73 74 65 6d 20 24 3a 3a 74 63 6c 6b 69 74 5f 73 stem $::tclkit_s 03c0: 79 73 74 65 6d 5f 65 6e 63 6f 64 69 6e 67 0a 09 ystem_encoding.. 03d0: 09 09 09 7d 0a 09 09 09 7d 0a 09 09 09 75 6e 73 ...}....}....uns 03e0: 65 74 20 2d 6e 6f 63 6f 6d 70 6c 61 69 6e 20 3a et -nocomplain : 03f0: 3a 74 63 6c 6b 69 74 5f 73 79 73 74 65 6d 5f 65 :tclkit_system_e 0400: 6e 63 6f 64 69 6e 67 0a 09 09 7d 0a 0a 09 09 23 ncoding...}....# 0410: 20 49 66 20 77 65 27 76 65 20 73 74 69 6c 6c 20 If we've still 0420: 6e 6f 74 20 62 65 65 6e 20 61 62 6c 65 20 74 6f not been able to 0430: 20 73 65 74 20 74 68 65 20 65 6e 63 6f 64 69 6e set the encodin 0440: 67 2c 20 72 65 76 65 72 74 20 74 6f 20 54 63 6c g, revert to Tcl 0450: 6b 69 74 20 64 65 66 61 75 6c 74 73 0a 09 09 69 kit defaults...i 0460: 66 20 7b 5b 65 6e 63 6f 64 69 6e 67 20 73 79 73 f {[encoding sys 0470: 74 65 6d 5d 20 65 71 20 22 69 64 65 6e 74 69 74 tem] eq "identit 0480: 79 22 7d 20 7b 0a 09 09 09 63 61 74 63 68 20 7b y"} {....catch { 0490: 0a 09 09 09 09 73 77 69 74 63 68 20 24 3a 3a 74 .....switch $::t 04a0: 63 6c 5f 70 6c 61 74 66 6f 72 6d 28 70 6c 61 74 cl_platform(plat 04b0: 66 6f 72 6d 29 20 7b 0a 09 09 09 09 09 77 69 6e form) {......win 04c0: 64 6f 77 73 09 09 7b 20 65 6e 63 6f 64 69 6e 67 dows..{ encoding 04d0: 20 73 79 73 74 65 6d 20 63 70 31 32 35 32 20 7d system cp1252 } 04e0: 0a 09 09 09 09 09 6d 61 63 69 6e 74 6f 73 68 09 ......macintosh. 04f0: 7b 20 65 6e 63 6f 64 69 6e 67 20 73 79 73 74 65 { encoding syste 0500: 6d 20 6d 61 63 52 6f 6d 61 6e 20 7d 0a 09 09 09 m macRoman }.... 0510: 09 20 20 20 20 20 20 20 20 64 65 66 61 75 6c 74 . default 0520: 09 09 7b 20 65 6e 63 6f 64 69 6e 67 20 73 79 73 ..{ encoding sys 0530: 74 65 6d 20 69 73 6f 38 38 35 39 2d 31 20 7d 0a tem iso8859-1 }. 0540: 09 09 09 09 7d 0a 09 09 09 7d 0a 09 09 7d 0a 0a ....}....}...}.. 0550: 09 09 23 20 6e 6f 77 20 72 65 6d 6f 75 6e 74 20 ..# now remount 0560: 74 68 65 20 65 78 65 63 75 74 61 62 6c 65 20 77 the executable w 0570: 69 74 68 20 74 68 65 20 63 6f 72 72 65 63 74 20 ith the correct 0580: 65 6e 63 6f 64 69 6e 67 0a 09 09 76 66 73 3a 3a encoding...vfs:: 0590: 66 69 6c 65 73 79 73 74 65 6d 20 75 6e 6d 6f 75 filesystem unmou 05a0: 6e 74 20 5b 6c 69 6e 64 65 78 20 5b 3a 3a 76 66 nt [lindex [::vf 05b0: 73 3a 3a 66 69 6c 65 73 79 73 74 65 6d 20 69 6e s::filesystem in 05c0: 66 6f 5d 20 30 5d 0a 0a 09 09 23 20 52 65 73 6f fo] 0]....# Reso 05d0: 6c 76 65 20 73 79 6d 6c 69 6e 6b 73 0a 09 09 73 lve symlinks...s 05e0: 65 74 20 74 63 6c 5f 6d 6f 75 6e 74 70 6f 69 6e et tcl_mountpoin 05f0: 74 20 5b 66 69 6c 65 20 64 69 72 6e 61 6d 65 20 t [file dirname 0600: 5b 66 69 6c 65 20 6e 6f 72 6d 61 6c 69 7a 65 20 [file normalize 0610: 5b 66 69 6c 65 20 6a 6f 69 6e 20 24 74 63 6c 5f [file join $tcl_ 0620: 6d 6f 75 6e 74 70 6f 69 6e 74 20 5f 5f 64 75 6d mountpoint __dum 0630: 6d 79 5f 5f 5d 5d 5d 0a 0a 09 09 73 65 74 20 74 my__]]]....set t 0640: 63 6c 5f 6c 69 62 72 61 72 79 20 5b 66 69 6c 65 cl_library [file 0650: 20 6a 6f 69 6e 20 24 74 63 6c 5f 6d 6f 75 6e 74 join $tcl_mount 0660: 70 6f 69 6e 74 20 6c 69 62 20 74 63 6c 24 74 63 point lib tcl$tc 0670: 6c 5f 76 65 72 73 69 6f 6e 5d 0a 09 09 73 65 74 l_version]...set 0680: 20 74 63 6c 5f 6c 69 62 50 61 74 68 20 5b 6c 69 tcl_libPath [li 0690: 73 74 20 24 74 63 6c 5f 6c 69 62 72 61 72 79 20 st $tcl_library 06a0: 5b 66 69 6c 65 20 6a 6f 69 6e 20 24 74 63 6c 5f [file join $tcl_ 06b0: 6d 6f 75 6e 74 70 6f 69 6e 74 20 6c 69 62 5d 5d mountpoint lib]] 06c0: 0a 0a 09 09 76 66 73 3a 3a 66 69 6c 65 73 79 73 ....vfs::filesys 06d0: 74 65 6d 20 6d 6f 75 6e 74 20 24 74 63 6c 5f 6d tem mount $tcl_m 06e0: 6f 75 6e 74 70 6f 69 6e 74 20 24 76 66 73 48 61 ountpoint $vfsHa 06f0: 6e 64 6c 65 72 0a 0a 09 7d 0a 0a 09 23 20 6c 6f ndler...}...# lo 0700: 61 64 20 63 6f 6e 66 69 67 20 73 65 74 74 69 6e ad config settin 0710: 67 73 20 66 69 6c 65 20 69 66 20 70 72 65 73 65 gs file if prese 0720: 6e 74 0a 09 6e 61 6d 65 73 70 61 63 65 20 65 76 nt..namespace ev 0730: 61 6c 20 3a 3a 76 66 73 20 7b 20 76 61 72 69 61 al ::vfs { varia 0740: 62 6c 65 20 74 63 6c 6b 69 74 5f 76 65 72 73 69 ble tclkit_versi 0750: 6f 6e 20 31 20 7d 0a 09 63 61 74 63 68 20 7b 20 on 1 }..catch { 0760: 75 70 6c 65 76 65 6c 20 23 30 20 5b 6c 69 73 74 uplevel #0 [list 0770: 20 73 6f 75 72 63 65 20 5b 66 69 6c 65 20 6a 6f source [file jo 0780: 69 6e 20 24 74 63 6c 5f 6d 6f 75 6e 74 70 6f 69 in $tcl_mountpoi 0790: 6e 74 20 63 6f 6e 66 69 67 2e 74 63 6c 5d 5d 20 nt config.tcl]] 07a0: 7d 0a 0a 09 75 70 6c 65 76 65 6c 20 23 30 20 5b }...uplevel #0 [ 07b0: 6c 69 73 74 20 73 6f 75 72 63 65 20 5b 66 69 6c list source [fil 07c0: 65 20 6a 6f 69 6e 20 24 74 63 6c 5f 6c 69 62 72 e join $tcl_libr 07d0: 61 72 79 20 69 6e 69 74 2e 74 63 6c 5d 5d 0a 20 ary init.tcl]]. 07e0: 20 0a 09 23 20 72 65 73 65 74 20 61 75 74 6f 5f ..# reset auto_ 07f0: 70 61 74 68 2c 20 73 6f 20 74 68 61 74 20 69 6e path, so that in 0800: 69 74 2e 74 63 6c 27 73 20 73 65 61 72 63 68 20 it.tcl's search 0810: 6f 75 74 73 69 64 65 20 6f 66 20 74 63 6c 6b 69 outside of tclki 0820: 74 20 69 73 20 63 61 6e 63 65 6c 6c 65 64 0a 09 t is cancelled.. 0830: 73 65 74 20 61 75 74 6f 5f 70 61 74 68 20 24 74 set auto_path $t 0840: 63 6c 5f 6c 69 62 50 61 74 68 0a 0a 09 23 20 54 cl_libPath...# T 0850: 68 69 73 20 6c 6f 61 64 73 20 65 76 65 72 79 74 his loads everyt 0860: 68 69 6e 67 20 6e 65 65 64 65 64 20 66 6f 72 20 hing needed for 0870: 22 63 6c 6f 63 6b 20 73 63 61 6e 22 20 74 6f 20 "clock scan" to 0880: 77 6f 72 6b 0a 09 23 20 22 63 6c 6f 63 6b 20 73 work..# "clock s 0890: 63 61 6e 22 20 69 73 20 75 73 65 64 20 77 69 74 can" is used wit 08a0: 68 69 6e 20 22 76 66 73 3a 3a 7a 69 70 22 2c 20 hin "vfs::zip", 08b0: 77 68 69 63 68 20 6d 61 79 20 62 65 0a 09 23 20 which may be..# 08c0: 6c 6f 61 64 65 64 20 62 65 66 6f 72 65 20 74 68 loaded before th 08d0: 69 73 20 69 73 20 72 75 6e 20 63 61 75 73 69 6e is is run causin 08e0: 67 20 74 68 65 20 72 6f 6f 74 20 56 46 53 20 74 g the root VFS t 08f0: 6f 20 62 72 65 61 6b 0a 09 63 61 74 63 68 20 7b o break..catch { 0900: 20 63 6c 6f 63 6b 20 73 63 61 6e 20 7d 0a 0a 09 clock scan }... 0910: 23 20 4c 6f 61 64 20 74 68 65 73 65 2c 20 74 68 # Load these, th 0920: 65 20 6f 72 69 67 69 6e 61 6c 20 54 63 6c 6b 69 e original Tclki 0930: 74 20 64 6f 65 73 20 73 6f 20 69 74 20 73 68 6f t does so it sho 0940: 75 6c 64 20 62 65 20 73 61 66 65 2e 0a 09 75 70 uld be safe...up 0950: 6c 65 76 65 6c 20 23 30 20 5b 6c 69 73 74 20 73 level #0 [list s 0960: 6f 75 72 63 65 20 5b 66 69 6c 65 20 6a 6f 69 6e ource [file join 0970: 20 24 74 63 6c 5f 6d 6f 75 6e 74 70 6f 69 6e 74 $tcl_mountpoint 0980: 20 6c 69 62 20 76 66 73 20 76 66 73 55 74 69 6c lib vfs vfsUtil 0990: 73 2e 74 63 6c 5d 5d 0a 0a 09 23 20 4e 6f 77 20 s.tcl]]...# Now 09a0: 74 68 61 74 20 74 68 65 20 69 6e 69 74 69 61 6c that the initial 09b0: 69 7a 61 74 69 6f 6e 20 69 73 20 63 6f 6d 70 6c ization is compl 09c0: 65 74 65 2c 20 6d 6f 75 6e 74 20 74 68 65 20 75 ete, mount the u 09d0: 73 65 72 20 56 46 53 20 69 66 20 6e 65 65 64 65 ser VFS if neede 09e0: 64 0a 09 23 23 20 4d 6f 75 6e 74 20 74 68 65 20 d..## Mount the 09f0: 56 46 53 20 66 72 6f 6d 20 74 68 65 20 53 68 61 VFS from the Sha 0a00: 72 65 64 20 4f 62 6a 65 63 74 0a 09 69 66 20 7b red Object..if { 0a10: 5b 69 6e 66 6f 20 65 78 69 73 74 73 20 3a 3a 69 [info exists ::i 0a20: 6e 69 74 56 46 53 5d 20 26 26 20 5b 69 6e 66 6f nitVFS] && [info 0a30: 20 65 78 69 73 74 73 20 3a 3a 74 63 6c 4b 69 74 exists ::tclKit 0a40: 46 69 6c 65 6e 61 6d 65 5d 7d 20 7b 0a 09 09 63 Filename]} {...c 0a50: 61 74 63 68 20 7b 0a 09 09 09 70 61 63 6b 61 67 atch {....packag 0a60: 65 20 72 65 71 75 69 72 65 20 76 66 73 3a 3a 7a e require vfs::z 0a70: 69 70 0a 0a 09 09 09 76 66 73 3a 3a 7a 69 70 3a ip.....vfs::zip: 0a80: 3a 4d 6f 75 6e 74 20 24 3a 3a 74 63 6c 4b 69 74 :Mount $::tclKit 0a90: 46 69 6c 65 6e 61 6d 65 20 22 2f 2e 4b 49 54 44 Filename "/.KITD 0aa0: 4c 4c 5f 55 53 45 52 22 0a 0a 09 09 09 6c 61 70 LL_USER".....lap 0ab0: 70 65 6e 64 20 61 75 74 6f 5f 70 61 74 68 20 5b pend auto_path [ 0ac0: 66 69 6c 65 20 6e 6f 72 6d 61 6c 69 7a 65 20 22 file normalize " 0ad0: 2f 2e 4b 49 54 44 4c 4c 5f 55 53 45 52 2f 6c 69 /.KITDLL_USER/li 0ae0: 62 22 5d 0a 09 09 7d 0a 09 7d 0a 0a 09 23 23 20 b"]...}..}...## 0af0: 4d 6f 75 6e 74 20 74 68 65 20 56 46 53 20 66 72 Mount the VFS fr 0b00: 6f 6d 20 65 78 65 63 75 74 61 62 6c 65 0a 09 69 om executable..i 0b10: 66 20 7b 5b 69 6e 66 6f 20 65 78 69 73 74 73 20 f {[info exists 0b20: 3a 3a 69 6e 69 74 56 46 53 5d 7d 20 7b 0a 09 09 ::initVFS]} {... 0b30: 63 61 74 63 68 20 7b 0a 09 09 09 70 61 63 6b 61 catch {....packa 0b40: 67 65 20 72 65 71 75 69 72 65 20 76 66 73 3a 3a ge require vfs:: 0b50: 7a 69 70 0a 0a 09 09 09 76 66 73 3a 3a 7a 69 70 zip.....vfs::zip 0b60: 3a 3a 4d 6f 75 6e 74 20 5b 69 6e 66 6f 20 6e 61 ::Mount [info na 0b70: 6d 65 6f 66 65 78 65 63 75 74 61 62 6c 65 5d 20 meofexecutable] 0b80: 22 2f 2e 4b 49 54 44 4c 4c 5f 41 50 50 22 0a 0a "/.KITDLL_APP".. 0b90: 09 09 09 6c 61 70 70 65 6e 64 20 61 75 74 6f 5f ...lappend auto_ 0ba0: 70 61 74 68 20 5b 66 69 6c 65 20 6e 6f 72 6d 61 path [file norma 0bb0: 6c 69 7a 65 20 22 2f 2e 4b 49 54 44 4c 4c 5f 41 lize "/.KITDLL_A 0bc0: 50 50 2f 6c 69 62 22 5d 0a 09 09 7d 0a 09 7d 0a PP/lib"]...}..}. 0bd0: 0a 09 23 20 43 6c 65 61 6e 20 75 70 20 61 66 74 ..# Clean up aft 0be0: 65 72 20 74 68 65 20 6b 69 74 49 6e 69 74 2e 63 er the kitInit.c 0bf0: 3a 70 72 65 49 6e 69 74 43 6d 64 0a 09 75 6e 73 :preInitCmd..uns 0c00: 65 74 20 2d 6e 6f 63 6f 6d 70 6c 61 69 6e 20 3a et -nocomplain : 0c10: 3a 69 6e 69 74 56 46 53 20 3a 3a 74 63 6c 4b 69 :initVFS ::tclKi 0c20: 74 46 69 6c 65 6e 61 6d 65 0a 7d 0a tFilename.}.