Browse Source

update make_punk86.tcl to install tcl .tm library files

master
Julian Noble 2 years ago
parent
commit
27ad9dea05
  1. 249
      src/make_punk86.tcl

249
src/make_punk86.tcl

@ -1,118 +1,131 @@
if {[lsearch $::argv -k] >= 0} {
set forcekill 1
} else {
set forcekill 0
}
puts stdout "::argv $::argv"
set dirname [file normalize [file dirname [info script]]]
if {![file exists $dirname/punk86.vfs]} {
puts stderr "missing $dirname/punk86.vfs"
exit 1
}
if {[file exists $dirname/punk86]} {
puts stderr "deleting existing $dirname/punk86"
file delete $dirname/punk86
}
puts stdout "building with sdx.."
if {[catch {
exec sdx wrap punk86 -runtime tclkit86bi.exe -verbose
} result]} {
puts stderr "sdx wrap punk86 -runtime tclkit86bi.exe -verbose failed with msg: $result"
} else {
puts stdout "ok - finished sdx"
set separator [string repeat = 40]
puts stdout $separator
puts stdout $result
puts stdout $separator
}
if {![file exists $dirname/punk86]} {
puts stderr "|err> build didn't seem to produce output at $dirname/punk86"
exit 2
}
if {![catch {
exec tasklist | grep punk86
} still_running]} {
puts stdout "found punk86 instances still running\n"
set count_killed 0
foreach ln [split $still_running \n] {
puts stdout " $ln"
set pid [lindex $ln 1]
if {$forcekill} {
set killcmd [list taskkill /F /PID $pid]
} else {
set killcmd [list taskkill /PID $pid]
}
puts stdout " pid: $pid (attempting to kill now using '$killcmd')"
if {[catch {
exec {*}$killcmd
} errMsg]} {
puts stderr "taskkill /PID $pid returned an error:"
puts stderr $errMsg
puts stderr "(try '[info script] -k' option to force kill)"
exit 4
} else {
puts stderr "taskkill /PID $pid ran without error"
incr count_killed
}
}
if {$count_killed > 0} {
puts stderr "\nKilled $count_killed processes. Waiting a short time before attempting to delete executable"
after 2000
}
} else {
puts stderr "Ok.. no running punk processes found"
}
if {[file exists $dirname/punk86.exe]} {
puts stderr "deleting existing $dirname/punk86.exe"
if {[catch {
file delete $dirname/punk86.exe
} msg]} {
puts stderr "Failed to delete $dirname/punk86.exe"
exit 3
}
}
#is this test necessary?
if {[file exists $dirname/punk86.exe]} {
puts stderr "deletion of $dirname/punk86.exe failed - locked?"
exit 3
}
file rename $dirname/punk86 $dirname/punk86.exe
after 500
set deployment_folder [file dirname $dirname]
if {[file exists $deployment_folder/punk86.exe]} {
puts stderr "deleting existing deployed at $deployment_folder/punk86.exe"
if {[catch {
file delete $deployment_folder/punk86.exe
} errMsg]} {
puts stderr "deletion of deployed version at $deployment_folder/punk86.exe failed: $errMsg"
exit 4
}
}
puts stdout "copying.."
puts stdout "$dirname/punk86.exe"
puts stdout "to:"
puts stdout "$deployment_folder/punk86.exe"
after 500
file copy $dirname/punk86.exe $deployment_folder/punk86.exe
puts stdout "done"
if {[lsearch $::argv -k] >= 0} {
set forcekill 1
} else {
set forcekill 0
}
puts stdout "::argv $::argv"
set dirname [file normalize [file dirname [info script]]]
# ----------------------------------------
set src_module_dir $dirname/modules
set src_modules [glob -nocomplain -dir $src_module_dir -type f -tail *.tm]
set target_module_dir [file dirname $dirname]/modules
file mkdir $target_module_dir
foreach m $src_modules {
puts stdout "copying module $src_module_dir/$m to $target_module_dir"
file copy -force $src_module_dir/$m $target_module_dir
}
# ----------------------------------------
#
if {![file exists $dirname/punk86.vfs]} {
puts stderr "missing $dirname/punk86.vfs"
exit 1
}
if {[file exists $dirname/punk86]} {
puts stderr "deleting existing $dirname/punk86"
file delete $dirname/punk86
}
puts stdout "building with sdx.."
if {[catch {
exec sdx wrap punk86 -runtime tclkit86bi.exe -verbose
} result]} {
puts stderr "sdx wrap punk86 -runtime tclkit86bi.exe -verbose failed with msg: $result"
} else {
puts stdout "ok - finished sdx"
set separator [string repeat = 40]
puts stdout $separator
puts stdout $result
puts stdout $separator
}
if {![file exists $dirname/punk86]} {
puts stderr "|err> build didn't seem to produce output at $dirname/punk86"
exit 2
}
if {![catch {
exec tasklist | grep punk86
} still_running]} {
puts stdout "found punk86 instances still running\n"
set count_killed 0
foreach ln [split $still_running \n] {
puts stdout " $ln"
set pid [lindex $ln 1]
if {$forcekill} {
set killcmd [list taskkill /F /PID $pid]
} else {
set killcmd [list taskkill /PID $pid]
}
puts stdout " pid: $pid (attempting to kill now using '$killcmd')"
if {[catch {
exec {*}$killcmd
} errMsg]} {
puts stderr "taskkill /PID $pid returned an error:"
puts stderr $errMsg
puts stderr "(try '[info script] -k' option to force kill)"
exit 4
} else {
puts stderr "taskkill /PID $pid ran without error"
incr count_killed
}
}
if {$count_killed > 0} {
puts stderr "\nKilled $count_killed processes. Waiting a short time before attempting to delete executable"
after 2000
}
} else {
puts stderr "Ok.. no running punk processes found"
}
if {[file exists $dirname/punk86.exe]} {
puts stderr "deleting existing $dirname/punk86.exe"
if {[catch {
file delete $dirname/punk86.exe
} msg]} {
puts stderr "Failed to delete $dirname/punk86.exe"
exit 3
}
}
#is this test necessary?
if {[file exists $dirname/punk86.exe]} {
puts stderr "deletion of $dirname/punk86.exe failed - locked?"
exit 3
}
file rename $dirname/punk86 $dirname/punk86.exe
after 500
set deployment_folder [file dirname $dirname]
if {[file exists $deployment_folder/punk86.exe]} {
puts stderr "deleting existing deployed at $deployment_folder/punk86.exe"
if {[catch {
file delete $deployment_folder/punk86.exe
} errMsg]} {
puts stderr "deletion of deployed version at $deployment_folder/punk86.exe failed: $errMsg"
exit 4
}
}
puts stdout "copying.."
puts stdout "$dirname/punk86.exe"
puts stdout "to:"
puts stdout "$deployment_folder/punk86.exe"
after 500
file copy $dirname/punk86.exe $deployment_folder/punk86.exe
puts stdout "done"

Loading…
Cancel
Save