msxbuild/lib/openmsx/share/scripts/save_flight.tcl

64 lines
1.9 KiB
Tcl
Raw Normal View History

# safe_flight -- Setup the black box flight recorder for build pipelines.
#
# Adds the following command to openMSX;
#
# 'save_flight_screenshot'
# Takes an screenshot with optional prefix parameter.
#
# 'save_flight_video'
# Starts video recording with optional prefix parameter.
#
# Supported environment variables by this script;
#
# SAVE_FLIGHT_PREFIX=msxbuild
# Gives screenshots and videos an prefix; msxbuild0001.avi
#
# SAVE_FLIGHT_SEPERATOR=-
# Gives screenshots and videos an seperator; openmsx-0001.png
#
# SAVE_FLIGHT_RECORD_FLAG=-doublesize
# Flag given to the video record command.
#
set save_flight_prefix flight
set save_flight_seperator -
set save_flight_record_flag ""
proc save_flight_screenshot {{prefix_id 0}} {
global save_flight_prefix
global save_flight_seperator
if {$prefix_id != 0} {
set file_prefix "$prefix_id$save_flight_seperator"
} else {
set file_prefix "$save_flight_prefix$save_flight_seperator"
}
after time 1 "screenshot -prefix $file_prefix"
return "Flight screenshot saved"
}
proc save_flight_video {{prefix_id 0}} {
global save_flight_prefix
global save_flight_seperator
global save_flight_record_flag
if {$prefix_id != 0} {
set file_prefix "$prefix_id$save_flight_seperator"
} else {
set file_prefix "$save_flight_prefix$save_flight_seperator"
}
after quit "record stop"
after time 1 "record start $save_flight_record_flag -prefix $file_prefix"
return "Flight video started"
}
if {[info exists ::env(SAVE_FLIGHT_PREFIX)] && ([string trim $::env(SAVE_FLIGHT_PREFIX)] != "")} {
set save_flight_prefix [string trim $::env(SAVE_FLIGHT_PREFIX)]
}
if {[info exists ::env(SAVE_FLIGHT_SEPERATOR)] && ([string trim $::env(SAVE_FLIGHT_SEPERATOR)] != "")} {
set save_flight_seperator [string trim $::env(SAVE_FLIGHT_SEPERATOR)]
}
if {[info exists ::env(SAVE_FLIGHT_RECORD_FLAG)] && ([string trim $::env(SAVE_FLIGHT_RECORD_FLAG)] != "")} {
set save_flight_record_flag [string trim $::env(SAVE_FLIGHT_RECORD_FLAG)]
}