From c50fa3171c3933485cffcb2f7a556b4eb54b41fe Mon Sep 17 00:00:00 2001 From: Julian Noble Date: Mon, 23 Feb 2026 02:53:36 +1100 Subject: [PATCH] attempt to use a runtime with tclkit capability as fallback for tclkit for sdx when tclkit/sdx not available as executables --- src/make.tcl | 41 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 37 insertions(+), 4 deletions(-) diff --git a/src/make.tcl b/src/make.tcl index 8f7829c4..9d82fb0f 100644 --- a/src/make.tcl +++ b/src/make.tcl @@ -2446,6 +2446,16 @@ set rtfolder $binfolder/runtime/$rt_os_arch set rt_sourcefolder $sourcefolder/runtime ;#where our config lives #review - when building kits for other platforms - it's unlikely runtime will be marked as executable - we should probably process all files in runtime folder except those with certain extensions +proc ::punkboot::lib::runtime_buildcopyname {runtime} { + if {$::tcl_platform(platform) eq "windows"} { + set rtname [file rootname [file tail $runtime]] + set bcname ${rtname}_BUILDCOPY.exe + } else { + set rtname [file tail $runtime] + set bcname ${rtname}_BUILDCOPY + } + return $bcname +} set runtimes [list] if {[file dirname [info nameofexecutable]] eq $rtfolder} { @@ -2453,9 +2463,11 @@ if {[file dirname [info nameofexecutable]] eq $rtfolder} { # - when the current runtime is using a runtime in the rtfolder that is a tclkit, it is mounted at the same path as the physical file and so appears to Tcl as if it's a directory. # - use external filesystem tools to make a copy of the file if {$::tcl_platform(platform) eq "windows"} { - exec cmd /c copy [info nameofexecutable] $rtfolder/[file rootname [file tail [info nameofexecutable]]]_BUILDCOPY.exe + #exec cmd /c copy [info nameofexecutable] $rtfolder/[file rootname [file tail [info nameofexecutable]]]_BUILDCOPY.exe + exec cmd /c copy [info nameofexecutable] $rtfolder/[punkboot::lib::runtime_buildcopyname [info nameofexecutable]] } else { - exec cp [info nameofexecutable] $rtfolder/[file tail [info nameofexecutable]]_BUILDCOPY + #exec cp [info nameofexecutable] $rtfolder/[file tail [info nameofexecutable]]_BUILDCOPY + exec cp [info nameofexecutable] $rtfolder/[punkboot::lib::runtime_buildcopyname [info nameofexecutable]] } lappend runtimes [file tail [info nameofexecutable]] } @@ -2491,13 +2503,34 @@ if {$sdxpath eq ""} { set sdxpath [auto_execok sdx] } if {$sdxpath eq ""} { - #last resort - a tclkit and sdx.kit fine + #last resorts - a tclkit and sdx.kit file if {[file exists $binfolder/sdx.kit]} { set tclkitpath [auto_execok $binfolder/tclkit] if {$tclkitpath eq ""} { set tclkitpath [auto_execok tclkit] } - set sdxpath [list {*}$tclkitpath $binfolder/sdx.kit] + if {$tclkitpath ne ""} { + set sdxpath [list {*}$tclkitpath $binfolder/sdx.kit] + } else { + #see if the runtime (or any runtime *for current platform*) has tclkit in the name or has_starkit(?) and use that + #todo - review + #picking first found for now - fix + dict for {rtname rtprops} $runtime_caps { + if {[dict exists $rtprops has_starkit] && [dict get $rtprops has_starkit]} { + set testpath $rtfolder/$rtname + if {[file exists $testpath]} { + if {[file type $testpath] eq "directory"} { + set tclkitpath $rtfolder/[punk::lib::runtime_buildcopyname $testpath] + } else { + set tclkitpath $testpath + } + if {$tclkitpath ne "" && [file exists $tclkitpath]} { + break + } + } + } + } + } } }