|
|
|
#puts stdout "launching punk"
|
|
|
|
set dirname [file dirname [file normalize [info script]]]
|
|
|
|
if {[file tail $dirname] eq "bin"} {
|
|
|
|
lassign [split [info tclversion] .] tclmajorv tclminorv
|
|
|
|
#we shouldn't try to call into the ../src/vfs/* folders - as they are 'partials'
|
|
|
|
#instead we call into one of the ../src/_build/exename.vfs folders
|
|
|
|
|
|
|
|
if {"windows" eq $::tcl_platform(platform)} {
|
|
|
|
set ext ".exe"
|
|
|
|
} else {
|
|
|
|
set ext ""
|
|
|
|
}
|
|
|
|
switch -- $tclmajorv {
|
|
|
|
8 {
|
|
|
|
set vfsfolder [file normalize [file join $dirname "../src/_build/punk86${ext}.vfs"]]
|
|
|
|
}
|
|
|
|
9 {
|
|
|
|
set vfsfolder [file normalize [file join $dirname "../src/_build/punk9cook${ext}.vfs"]]
|
|
|
|
}
|
|
|
|
default {
|
|
|
|
error "no vfs available for tcl major version $tclmajorv"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
set launchpath [file join $vfsfolder main.tcl]
|
|
|
|
if {[file exists [file join $dirname $launchpath]]} {
|
|
|
|
#tclsh [file join $dirname $launchpath] {*}$::argv
|
|
|
|
namespace eval ::punkboot {
|
|
|
|
#this drop-box style interaction is not pretty..
|
|
|
|
#variable vfs_entry_point
|
|
|
|
#set vfs_entry_point $launchpath ;#tell a cooperating main.tcl what's going on
|
|
|
|
variable internal_paths
|
|
|
|
#set internal_paths [list [info library] $vfscommonfolder $vfsfolder]
|
|
|
|
set internal_paths [list [file dirname [file dirname [info nameofexecutable]]]]
|
|
|
|
}
|
|
|
|
source [file join $dirname $launchpath]
|
|
|
|
} else {
|
|
|
|
#todo - tidy up - we don't use fauxlinks in src/vfs/xxx.vfs anymore
|
|
|
|
# - but we may want to fauxlink the active exe vfs above? REVIEW
|
|
|
|
set failed 1
|
|
|
|
set tried_list [list $launchpath]
|
|
|
|
set fauxlinks [glob -nocomplain -dir $vfsfolder -type f main.tcl#*.fxlnk main.tcl#*.fauxlink]
|
|
|
|
#puts stderr "globbed in $vfsfolder result: $fauxlinks"
|
|
|
|
if {[llength $fauxlinks] >= 1} {
|
|
|
|
set vfscommonfolder [file join [file dirname $vfsfolder] _vfscommon.vfs]
|
|
|
|
#review - we don't know what other vfs folder might make up the unbuild vfs
|
|
|
|
#_vfscommon.vfs is standard - REVIEW
|
|
|
|
foreach vfs [list $vfscommonfolder $vfsfolder] {
|
|
|
|
if {[file exists $vfs/modules]} {
|
|
|
|
tcl::tm::add $vfs/modules
|
|
|
|
}
|
|
|
|
if {[file exists $vfs/modules_tcl${tclmajorv}]} {
|
|
|
|
tcl::tm::add $vfs/modules_tcl${tclmajorv}
|
|
|
|
}
|
|
|
|
if {[file exists $vfs/lib]} {
|
|
|
|
lappend ::auto_path $vfs/lib
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if {![catch {package require fauxlink} errM]} {
|
|
|
|
set maintcl_fauxlink [lindex $fauxlinks 0]
|
|
|
|
set fdict [fauxlink::resolve $maintcl_fauxlink]
|
|
|
|
set tags [dict get $fdict tags]
|
|
|
|
#puts stdout "trying fauxlink: $fdict"
|
|
|
|
if {[dict get $fdict name] eq "main.tcl" && "punk::boot,merge_over" in "$tags"} {
|
|
|
|
set target [dict get $fdict targetpath]
|
|
|
|
if {[file pathtype $target] eq "relative"} {
|
|
|
|
set targetfile [file join $vfsfolder $target]
|
|
|
|
} else {
|
|
|
|
set targetfile $target
|
|
|
|
}
|
|
|
|
set targetfile [file normalize $targetfile]
|
|
|
|
puts stdout "trying fauxlinked file: $targetfile"
|
|
|
|
if {[file exists $targetfile]} {
|
|
|
|
namespace eval ::punkboot {
|
|
|
|
#this drop-box style interaction is not pretty..
|
|
|
|
variable vfs_entry_point
|
|
|
|
set vfs_entry_point $launchpath ;#tell a cooperating main.tcl what's going on
|
|
|
|
variable internal_paths
|
|
|
|
set internal_paths [list $vfscommonfolder $vfsfolder]
|
|
|
|
}
|
|
|
|
set failed 0
|
|
|
|
source $targetfile
|
|
|
|
} else {
|
|
|
|
puts "fauxlink target: $targetfile doesn't seem to exist"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
puts stderr "Couldn't load fauxlink package. Tried tm paths [list $vfscommonfolder/modules $vfsfolder/modules]"
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
puts stderr "Couldn't find a fauxlink file as a fallback"
|
|
|
|
}
|
|
|
|
if {$failed} {
|
|
|
|
puts stderr "Unable to locate punk${tclmajorv} entry-point main.tcl tried:[join $tried_list \n]"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
puts stderr "punk launch script must be located in the punk bin folder"
|
|
|
|
}
|
|
|
|
#puts stdout "-done-"
|
|
|
|
|