Browse Source

short-term fix for bin/runtime.cmd listing and runtime selectin, fix logic errors in last

master
Julian Noble 1 week ago
parent
commit
2f57ff757b
  1. 32
      bin/runtime.cmd
  2. 4
      src/make.tcl
  3. 4
      src/project_layouts/custom/_project/punk.basic/src/make.tcl
  4. 4
      src/project_layouts/custom/_project/punk.project-0.1/src/make.tcl
  5. 4
      src/project_layouts/custom/_project/punk.shell-0.1/src/make.tcl
  6. 4
      src/scriptapps/runtime.bash
  7. 6
      src/scriptapps/runtime.ps1

32
bin/runtime.cmd

@ -432,21 +432,27 @@ SETLOCAL EnableDelayedExpansion
@REM batch file library functions
@GOTO :endlib
@REM padding
@REM padding
@REM padding
@REM padding
@REM padding xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
@REM padding xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
%= ---------------------------------------------------------------------- =%
@rem courtesy of dbenham
:: Example usage
@rem call :getUniqueFile "d:\test\myFile" ".txt" myFile
@rem echo myFile="%myFile%"
@rem 2025 - wmic deprecated :/
@rem 2025 - output of 'wmic os get localDateTime' was something like:
@rem LocalDateTime
@rem 20251015234316.777000+660
@rem !time! has a resolution of centiseconds. As we test in a loop for file existence, that should be ok.
:getUniqueFile baseName extension rtnVar
setlocal
setlocal enabledelayedexpansion
:getUniqueFileLoop
for /f "skip=1" %%A in ('wmic os get localDateTime') do for %%B in (%%A) do set "rtn=%~1_%%B%~2"
set "r=!date!_!time!"
set "r=%r::=.%"
set "r=%r: =%"
set "rtn=%~1_!r!%~2"
echo "### %rtn%"
if exist "%rtn%" (
goto :getUniqueFileLoop
) else (
@ -454,6 +460,7 @@ if exist "%rtn%" (
)
endlocal & set "%~3=%rtn%"
exit /b
%= ---------------------------------------------------------------------- =%
@REM padding
@ -1389,7 +1396,7 @@ case "$1" in
;;
"list")
if [[ -d "$archdir" ]]; then
echo "$(ls $archdir -1 | wc -l) files in $archdir"
echo "$(ls $archdir -1 | grep -v '_BUILDCOPY$' | wc -l) files in $archdir"
echo $(ls $archdir -1)
else
echo -e "No runtimes available in $archdir\n Use '$0 fetch' to install."
@ -1397,7 +1404,7 @@ case "$1" in
;;
"run")
#todo - lookup active runtime for os-arch from .toml file
activeruntime=$(ls $archdir -1 | tail -n 1)
activeruntime=$(ls $archdir -1 | grep -v '_BUILDCOPY$' | tail -n 1)
activeruntime_fullpath="$archdir/$activeruntime"
#echo "using $activeruntime_fullpath"
shift
@ -1960,7 +1967,7 @@ function psmain {
if (-not(Test-Path -Path $archfolder -PathType Container)) {
write-host "No runtimes seem to be installed for $arch`nPlease use 'runtime.cmd fetch' to install"
} else {
$dircontents = (get-childItem -Path $archfolder -File | Sort-Object Name)
$dircontents = (get-childItem -Path $archfolder -File | where-object Name -Notlike '*_BUILDCOPY.*' | Sort-Object Name)
if ($dircontents.Count -gt 0) {
#write-host "run.."
write-host "num params: $($PSBoundParameters.opts.count)"
@ -2033,7 +2040,7 @@ function psmain {
$localdict = @{}
if (test-path -Path $archfolder -Type Container) {
$dircontents = (get-childItem -Path $archfolder -File | Where-object {-not ($(".txt",".tm") -contains $_.Extension) })
$dircontents = (get-childItem -Path $archfolder -File | Where-object Name -Notlike '*_BUILDCOPY.*' | Where-object {-not ($(".txt",".tm") -contains $_.Extension) })
foreach ($f in $dircontents) {
$local_sha1 = Get-FileHash -Path $(${f}.FullName) -Algorithm SHA1
$localdict[$f.Name] = ${local_sha1}.Hash
@ -2086,7 +2093,7 @@ function psmain {
if (test-path -Path $archfolder -Type Container) {
Write-host "-----------------------------------------------------------------------"
Write-Host "Local runtimes for $arch"
$dircontents = (get-childItem -Path $archfolder -File | Where-object {-not ($(".txt",".tm") -contains $_.Extension) })
$dircontents = (get-childItem -Path $archfolder -File | Where-object Name -Notlike '*_BUILDCOPY.*' | Where-object {-not ($(".txt",".tm") -contains $_.Extension) })
write-host "$(${dircontents}.count) files in $archfolder"
Write-host "-----------------------------------------------------------------------"
foreach ($f in $dircontents) {
@ -2163,3 +2170,4 @@ no script engine should try to run me

4
src/make.tcl

@ -2636,7 +2636,7 @@ foreach runtime [dict keys $runtime_vfs_map] {
}
#invoke can fail if runtime not an executable file for the current platform
if {[file type $rtfolder/$runtime] ne "directory"} {
if {[file type $rtfolder/$runtime] eq "directory"} {
#assume it's a mounted tclkit (because tcl kits mount in same place as their underlying path and mask the executable)
#use the BUILDCOPY created above - REVIEW
if {$::tcl_platform(platform) eq "windows"} {
@ -2696,7 +2696,7 @@ foreach runtimefile $runtimes {
}
#----------------------
if {[file type $rtfolder/$runtimefile] ne "directory"} {
if {[file type $rtfolder/$runtimefile] eq "directory"} {
#assume it's a mounted tclkit (because tcl kits mount in same place as their underlying path and mask the executable)
#use the BUILDCOPY created above - REVIEW
if {$::tcl_platform(platform) eq "windows"} {

4
src/project_layouts/custom/_project/punk.basic/src/make.tcl

@ -2636,7 +2636,7 @@ foreach runtime [dict keys $runtime_vfs_map] {
}
#invoke can fail if runtime not an executable file for the current platform
if {[file type $rtfolder/$runtime] ne "directory"} {
if {[file type $rtfolder/$runtime] eq "directory"} {
#assume it's a mounted tclkit (because tcl kits mount in same place as their underlying path and mask the executable)
#use the BUILDCOPY created above - REVIEW
if {$::tcl_platform(platform) eq "windows"} {
@ -2696,7 +2696,7 @@ foreach runtimefile $runtimes {
}
#----------------------
if {[file type $rtfolder/$runtimefile] ne "directory"} {
if {[file type $rtfolder/$runtimefile] eq "directory"} {
#assume it's a mounted tclkit (because tcl kits mount in same place as their underlying path and mask the executable)
#use the BUILDCOPY created above - REVIEW
if {$::tcl_platform(platform) eq "windows"} {

4
src/project_layouts/custom/_project/punk.project-0.1/src/make.tcl

@ -2636,7 +2636,7 @@ foreach runtime [dict keys $runtime_vfs_map] {
}
#invoke can fail if runtime not an executable file for the current platform
if {[file type $rtfolder/$runtime] ne "directory"} {
if {[file type $rtfolder/$runtime] eq "directory"} {
#assume it's a mounted tclkit (because tcl kits mount in same place as their underlying path and mask the executable)
#use the BUILDCOPY created above - REVIEW
if {$::tcl_platform(platform) eq "windows"} {
@ -2696,7 +2696,7 @@ foreach runtimefile $runtimes {
}
#----------------------
if {[file type $rtfolder/$runtimefile] ne "directory"} {
if {[file type $rtfolder/$runtimefile] eq "directory"} {
#assume it's a mounted tclkit (because tcl kits mount in same place as their underlying path and mask the executable)
#use the BUILDCOPY created above - REVIEW
if {$::tcl_platform(platform) eq "windows"} {

4
src/project_layouts/custom/_project/punk.shell-0.1/src/make.tcl

@ -2636,7 +2636,7 @@ foreach runtime [dict keys $runtime_vfs_map] {
}
#invoke can fail if runtime not an executable file for the current platform
if {[file type $rtfolder/$runtime] ne "directory"} {
if {[file type $rtfolder/$runtime] eq "directory"} {
#assume it's a mounted tclkit (because tcl kits mount in same place as their underlying path and mask the executable)
#use the BUILDCOPY created above - REVIEW
if {$::tcl_platform(platform) eq "windows"} {
@ -2696,7 +2696,7 @@ foreach runtimefile $runtimes {
}
#----------------------
if {[file type $rtfolder/$runtimefile] ne "directory"} {
if {[file type $rtfolder/$runtimefile] eq "directory"} {
#assume it's a mounted tclkit (because tcl kits mount in same place as their underlying path and mask the executable)
#use the BUILDCOPY created above - REVIEW
if {$::tcl_platform(platform) eq "windows"} {

4
src/scriptapps/runtime.bash

@ -116,7 +116,7 @@ case "$1" in
;;
"list")
if [[ -d "$archdir" ]]; then
echo "$(ls $archdir -1 | wc -l) files in $archdir"
echo "$(ls $archdir -1 | grep -v '_BUILDCOPY$' | wc -l) files in $archdir"
echo $(ls $archdir -1)
else
echo -e "No runtimes available in $archdir\n Use '$0 fetch' to install."
@ -124,7 +124,7 @@ case "$1" in
;;
"run")
#todo - lookup active runtime for os-arch from .toml file
activeruntime=$(ls $archdir -1 | tail -n 1)
activeruntime=$(ls $archdir -1 | grep -v '_BUILDCOPY$' | tail -n 1)
activeruntime_fullpath="$archdir/$activeruntime"
#echo "using $activeruntime_fullpath"
shift

6
src/scriptapps/runtime.ps1

@ -254,7 +254,7 @@ function psmain {
if (-not(Test-Path -Path $archfolder -PathType Container)) {
write-host "No runtimes seem to be installed for $arch`nPlease use 'runtime.cmd fetch' to install"
} else {
$dircontents = (get-childItem -Path $archfolder -File | Sort-Object Name)
$dircontents = (get-childItem -Path $archfolder -File | where-object Name -Notlike '*_BUILDCOPY.*' | Sort-Object Name)
if ($dircontents.Count -gt 0) {
#write-host "run.."
write-host "num params: $($PSBoundParameters.opts.count)"
@ -327,7 +327,7 @@ function psmain {
$localdict = @{}
if (test-path -Path $archfolder -Type Container) {
$dircontents = (get-childItem -Path $archfolder -File | Where-object {-not ($(".txt",".tm") -contains $_.Extension) })
$dircontents = (get-childItem -Path $archfolder -File | Where-object Name -Notlike '*_BUILDCOPY.*' | Where-object {-not ($(".txt",".tm") -contains $_.Extension) })
foreach ($f in $dircontents) {
$local_sha1 = Get-FileHash -Path $(${f}.FullName) -Algorithm SHA1
$localdict[$f.Name] = ${local_sha1}.Hash
@ -380,7 +380,7 @@ function psmain {
if (test-path -Path $archfolder -Type Container) {
Write-host "-----------------------------------------------------------------------"
Write-Host "Local runtimes for $arch"
$dircontents = (get-childItem -Path $archfolder -File | Where-object {-not ($(".txt",".tm") -contains $_.Extension) })
$dircontents = (get-childItem -Path $archfolder -File | Where-object Name -Notlike '*_BUILDCOPY.*' | Where-object {-not ($(".txt",".tm") -contains $_.Extension) })
write-host "$(${dircontents}.count) files in $archfolder"
Write-host "-----------------------------------------------------------------------"
foreach ($f in $dircontents) {

Loading…
Cancel
Save