Check-in [07c8c54701]
Not logged in
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2018 Conference, Houston/TX, US, Oct 15-19
Send your abstracts to tclconference@googlegroups.com or submit via the online form
by Aug 20.

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Instead of embedding the package ifneeded script for TK in the tclIndex file, it now gets its own "pkgIndex.tcl" file in boot/tk The packages.tcl file for the VFS is now loaded on startup (if present) Cleaned up and straightened up the boot process for kits
Timelines: family | ancestors | descendants | both | gort
Files: files | file ages | folders
SHA1: 07c8c54701e6a6b45cfca2ab29298abede74f4b4
User & Date: hypnotoad 2016-03-01 18:12:57
Context
2016-03-01
18:13
Closing the gort branch check-in: 02f5a924cb user: hypnotoad tags: trunk
18:12
Instead of embedding the package ifneeded script for TK in the tclIndex file, it now gets its own "pkgIndex.tcl" file in boot/tk The packages.tcl file for the VFS is now loaded on startup (if present) Cleaned up and straightened up the boot process for kits Closed-Leaf check-in: 07c8c54701 user: hypnotoad tags: gort
11:42
Upgraded all the tcl bits to reference 8.6.5 Fixed more platform aphorisms for Windows that didn't translate to unix check-in: c77f5a58bd user: hypnotoad tags: gort
Changes
Unified Diff Ignore Whitespace Patch
Changes to build.tcl.
1
2
3
4
5
6
7
8
9
10

11

12

13
14
15
16
17
18
19
###
# script to build a tclkit
###
set HERE [file dirname [file normalize [info script]]]
set PWD [pwd]
namespace eval ::practcl {}
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



proc ::cat fname {
    set fname [open $fname r]
    set data [read $fname]
    close $fname
    return $data
}




<
<
<
<
<
<

>
|
>

>







1
2
3






4
5
6
7
8
9
10
11
12
13
14
15
16
###
# 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
}

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
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 pkgIndex.tcl] w]
  set buffer [::practcl::pkgindex_path $::KIT(BASEVFS) $vfspath]
  puts $fout $buffer
  close $fout




  ::zipfile::mkzip::mkzip ${name}$::KIT(EXEEXT) -runtime $::TARGET(tclkit_bare) $::KIT(BASEVFS) {*}$args $vfspath

}
















#########################################
#
# BEGIN THE KITBUILDING PROCESS HERE
#
#########################################
set _search_paths {{$PWD} {$PWD ..}}
if {![file exists odieConfig.tcl]} {
  # Build the local toolset
  cd $HERE
  exec [info nameofexecutable] [file join $HERE autosetup autosetup] --host 
  cd $PWD
}

source [file join $::HERE odieConfig.tcl]
set ::KIT(platform) ::odie(platform)
set ::KIT(ORIG_TCL_SRC_DIR) $::odie_tcl(src_dir)
set ::KIT(ORIG_TK_SRC_DIR) $::odie_tk(src_dir)
set ::KIT(TCL_BUILD_OPTS) $::odie_tcl(config_flags)
set ::KIT(TK_BUILD_OPTS) $::odie_tk(config_flags)
set ::KIT(HOST) $::odie(host)







|



>
>
>
>
|
>

>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







|


|


>







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
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]
  set buffer [::practcl::pkgindex_path $::KIT(BASEVFS) $vfspath]
  puts $fout $buffer
  close $fout
  copyDir $::KIT(BASEVFS) $vfspath
  foreach arg $args {
     copyDir $arg $vfspath
  }
  ::zipfile::mkzip::mkzip ${name}$::KIT(EXEEXT) -runtime $::TARGET(tclkit_bare) -directory $vfspath
  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]]} {
  # Build the local toolset
  cd $HERE
  exec [info nameofexecutable] [file join $HERE autosetup autosetup]
  cd $PWD
}
puts "AUTOPATH (276): $::auto_path"
source [file join $::HERE odieConfig.tcl]
set ::KIT(platform) ::odie(platform)
set ::KIT(ORIG_TCL_SRC_DIR) $::odie_tcl(src_dir)
set ::KIT(ORIG_TK_SRC_DIR) $::odie_tk(src_dir)
set ::KIT(TCL_BUILD_OPTS) $::odie_tcl(config_flags)
set ::KIT(TK_BUILD_OPTS) $::odie_tk(config_flags)
set ::KIT(HOST) $::odie(host)
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
  }
  clean {
  }
  default {
    error "Unknown command $COMMAND. Valid: clean tcl toadkit wrap"
  }
}
for {set i 1} {$i < [llength $argv]} {incr i} {
  set arg [lindex $argv $i]
  switch $arg {
    set 
    target {
      incr i
      set ::KIT(TARGET) [lindex $argv $i]
    }
    default {
      error "Unknown option $arg"
    }
  }
}

if { $::KIT(platform) eq "windows" } {
  set ::KIT(EXEEXT) .exe
  set ::KIT(platform_src_dir) win
  set USEMSVC [info exists env(VisualStudioVersion)]
} else {
  set ::KIT(EXEEXT) {}
  set ::KIT(platform_src_dir) unix
  set USEMSVC 0
}
set ::KIT(PKGPREFIX) /tcl

foreach dpath $_search_paths {
  set path [file normalize [file join {*}[subst $dpath] toadkit$::KIT(TCL_VERSION)$::KIT(TCL_PATCH_LEVEL)]]
  set ::KIT(TCLSRCDIR)  [file join $path tcl]
  set ::KIT(TKSRCDIR)   [file join $path tk]
  set ::KIT(PKGROOT)    [file join $path pkg]
  set ::KIT(BASEVFS)    [file join $path vfs]







<
<
<
<
<
<
<
<
<
<
<
<
<










|







345
346
347
348
349
350
351













352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
  }
  clean {
  }
  default {
    error "Unknown command $COMMAND. Valid: clean tcl toadkit wrap"
  }
}














if { $::KIT(platform) eq "windows" } {
  set ::KIT(EXEEXT) .exe
  set ::KIT(platform_src_dir) win
  set USEMSVC [info exists env(VisualStudioVersion)]
} else {
  set ::KIT(EXEEXT) {}
  set ::KIT(platform_src_dir) unix
  set USEMSVC 0
}
set ::KIT(PKGPREFIX) /zvfs

foreach dpath $_search_paths {
  set path [file normalize [file join {*}[subst $dpath] toadkit$::KIT(TCL_VERSION)$::KIT(TCL_PATCH_LEVEL)]]
  set ::KIT(TCLSRCDIR)  [file join $path tcl]
  set ::KIT(TKSRCDIR)   [file join $path tk]
  set ::KIT(PKGROOT)    [file join $path pkg]
  set ::KIT(BASEVFS)    [file join $path vfs]
459
460
461
462
463
464
465



466
467
468
469
470
471
472
      puts "BUILDING Static Tcl"
      cd $_TclSrcDir
      set opts {}
      if {$::KIT(HOST) != $::KIT(TARGET)} {
        lappend opts --host=$::KIT(TARGET)
      }
      lappend opts {*}$::KIT(TCL_BUILD_OPTS) --prefix=$::KIT(PKGPREFIX) --exec_prefix=$::KIT(PKGPREFIX) --with-tzdata --enable-shared=no



      doexec sh configure {*}$opts
      domake binaries
      domake packages
      cd $PWD
    }
  }
}







>
>
>







464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
      puts "BUILDING Static Tcl"
      cd $_TclSrcDir
      set opts {}
      if {$::KIT(HOST) != $::KIT(TARGET)} {
        lappend opts --host=$::KIT(TARGET)
      }
      lappend opts {*}$::KIT(TCL_BUILD_OPTS) --prefix=$::KIT(PKGPREFIX) --exec_prefix=$::KIT(PKGPREFIX) --with-tzdata --enable-shared=no
      puts ***
      puts "CONFIGURE {*}opts"
      puts ***
      doexec sh configure {*}$opts
      domake binaries
      domake packages
      cd $PWD
    }
  }
}
487
488
489
490
491
492
493



494
495
496
497
498
499
500
      puts "BUILD TK"
      set opts {}
      cd $_TkSrcDir
      if {$::KIT(HOST) != $::KIT(TARGET)} {
        lappend opts --host=$::KIT(TARGET)
      }
      lappend opts {*}$::KIT(TK_BUILD_OPTS) --with-tcl=$_TclSrcDir --enable-shared=yes



      doexec sh configure {*}$opts
      domake binaries
      cd $PWD
    }
  }
}








>
>
>







495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
      puts "BUILD TK"
      set opts {}
      cd $_TkSrcDir
      if {$::KIT(HOST) != $::KIT(TARGET)} {
        lappend opts --host=$::KIT(TARGET)
      }
      lappend opts {*}$::KIT(TK_BUILD_OPTS) --with-tcl=$_TclSrcDir --enable-shared=yes
      puts ***
      puts "CONFIGURE {*}opts"
      puts ***
      doexec sh configure {*}$opts
      domake binaries
      cd $PWD
    }
  }
}

714
715
716
717
718
719
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
752
753
754
755
756
757

758
759
  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]
  
  
  # For the following packages, cat their pkgIndex files to tclIndex
  if {$::tcl_platform(platform) eq {unix}} {
      file attributes [file join $::KIT(BASEVFS) boot tcl tclIndex] -permissions 0744
  } else {
      file attributes [file join $::KIT(BASEVFS) boot tcl tclIndex] -readonly 0
  }

  set fout [open [file join $::KIT(BASEVFS) boot tcl tclIndex] a]
  puts $fout {#
# MANIFEST OF INCLUDED PACKAGES
#
}
  set map [list @TKVERSION@ $::TK(version)$::TK(patch_level)]
  if { $::KIT(platform) eq "windows" } {
    lappend map @TKDLL@ [string trim $::TK(dll_file) \"]
  } else {
    lappend map @TKDLL@ [string trim $::TK(lib_file) \"]
  }
  puts $fout [string map $map {
package ifneeded Tk @TKVERSION@ [list load $::tk_library/@TKDLL@ Tk]
  }]
  puts $fout {
if {[file exists /zvfs/pkgIndex.tcl]} {
  set dir /zvfs
  source /zvfs/pkgIndex.tcl
}
  }
  #close $fout
  close $fout
}
if {$COMMAND eq "toadkit"} {
  ::practcl::wrap $::PWD toadkit toadkit-vfs
}

if {$COMMAND eq "wrap"} {

  ::practcl::wrap $::PWD {*}[lrange $args 1 end]
}







<
<
<
<
<
<
<
<
<
|
<
<
<
<









<
<
<
<
<
<
<







>
|

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
  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]




  set map [list @TKVERSION@ $::TK(version)$::TK(patch_level)]
  if { $::KIT(platform) eq "windows" } {
    lappend map @TKDLL@ [string trim $::TK(dll_file) \"]
  } else {
    lappend map @TKDLL@ [string trim $::TK(lib_file) \"]
  }
  puts $fout [string map $map {
package ifneeded Tk @TKVERSION@ [list load $::tk_library/@TKDLL@ Tk]
  }]







  close $fout
}
if {$COMMAND eq "toadkit"} {
  ::practcl::wrap $::PWD toadkit toadkit-vfs
}

if {$COMMAND eq "wrap"} {
  puts "WRAP {*}[lrange $argv 1 end]"
  ::practcl::wrap $::PWD {*}[lrange $argv 1 end]
}
Changes to generic/zvfsboot.c.
61
62
63
64
65
66
67

68
69
70
71
72





73
74
75
76
77
78
79
80
      Tcl_DStringAppendElement(&preinit,vfsmountpoint);
      Tcl_DStringAppend(&preinit,"\nset ::SRCDIR ",-1);
      Tcl_DStringAppendElement(&preinit,vfsmountpoint);
      
      if(Tcl_FSAccess(vfstcllib,F_OK)==0) {
        Tcl_DStringAppend(&preinit,"\nset tcl_library ",-1);
        Tcl_DStringAppendElement(&preinit,Tcl_GetString(vfstcllib));

      }
      if(Tcl_FSAccess(vfstklib,F_OK)==0) {
        Tcl_DStringAppend(&preinit,"\nset tk_library ",-1);
        Tcl_DStringAppendElement(&preinit,Tcl_GetString(vfstklib));
      }





      Tcl_DStringAppend(&preinit,"\nlappend ::auto_path [file join $::SRCDIR pkgs]",-1);
      
      vfspreinit=Tcl_NewStringObj(Tcl_DStringValue(&preinit),-1);
      /* NOTE: We never decr this refcount, lest the contents of the script be deallocated */
      Tcl_IncrRefCount(vfspreinit);
      TclSetPreInitScript(Tcl_GetString(vfspreinit));

      Tcl_DecrRefCount(vfsinitscript);







>





>
>
>
>
>
|







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
      Tcl_DStringAppendElement(&preinit,vfsmountpoint);
      Tcl_DStringAppend(&preinit,"\nset ::SRCDIR ",-1);
      Tcl_DStringAppendElement(&preinit,vfsmountpoint);
      
      if(Tcl_FSAccess(vfstcllib,F_OK)==0) {
        Tcl_DStringAppend(&preinit,"\nset tcl_library ",-1);
        Tcl_DStringAppendElement(&preinit,Tcl_GetString(vfstcllib));
        Tcl_DStringAppend(&preinit,"\nset auto_path {}",-1);
      }
      if(Tcl_FSAccess(vfstklib,F_OK)==0) {
        Tcl_DStringAppend(&preinit,"\nset tk_library ",-1);
        Tcl_DStringAppendElement(&preinit,Tcl_GetString(vfstklib));
      }
      Tcl_DStringAppend(&preinit,"\nif {[file exists [file join $::SRCDIR packages.tcl]]} \{",-1);
      Tcl_DStringAppend(&preinit,"\n  #In a wrapped exe, we don't go out to the environment",-1);
      Tcl_DStringAppend(&preinit,"\n  set auto_path {}",-1);
      Tcl_DStringAppend(&preinit,"\n  set dir $::SRCDIR",-1);
      Tcl_DStringAppend(&preinit,"\n  source [file join $::SRCDIR packages.tcl]",-1);
      Tcl_DStringAppend(&preinit,"\n\}",-1);
      
      vfspreinit=Tcl_NewStringObj(Tcl_DStringValue(&preinit),-1);
      /* NOTE: We never decr this refcount, lest the contents of the script be deallocated */
      Tcl_IncrRefCount(vfspreinit);
      TclSetPreInitScript(Tcl_GetString(vfspreinit));

      Tcl_DecrRefCount(vfsinitscript);