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