msxbuild/lib/make/mb_autoexec.mk
Willem Cazander 8b89c47824
All checks were successful
Run test asserts / Test-Asserts (push) Successful in -8s
Added dir/w output.
2024-06-29 16:04:44 +02:00

98 lines
4.1 KiB
Makefile

MB_AUTOEXEC_VERSION ?= on
MB_AUTOEXEC_STARTUP_TIMEOUT ?= 60
MB_AUTOEXEC_STARTUP_EXITCODE ?= 124
MB_AUTOEXEC_TEST_TIMEOUT ?= 120
MB_AUTOEXEC_TEST_EXITCODE ?= 1
MB_AUTOEXEC_CMD_TIMEOUT ?= 300
MB_AUTOEXEC_CMD_EXITCODE ?= 1
define mb_autoexec_append_cmd
echo "$(2)\r" >> $(1)/autoexec.bat
endef
define mb_autoexec_append_echo
$(call mb_autoexec_append_cmd,$(1),echo $(subst >,>,$(2)))
endef
define mb_autoexec_append_rem
$(call mb_autoexec_append_cmd,$(1),rem $(2))
endef
define mb_autoexec_append_show_gui
$(call mb_autoexec_append_cmd,$(1),omsxctl boot_mode_show_gui)
endef
define mb_autoexec_append_stop_fail
$(call mb_autoexec_append_cmd,$(1),omsxctl fail_after 0)
endef
define mb_autoexec_append_exit
$(if $(filter on,$(MB_FLIGHT_SCREEN)),$(call mb_autoexec_append_save_screenshot,$(1)))
$(call mb_autoexec_append_cmd,$(1),omsxctl boot_exec_exit)
endef
define mb_autoexec_append_joyporta_mouse
$(call mb_autoexec_append_cmd,$(1),omsxctl plug joyporta mouse)
endef
define mb_autoexec_append_save_screenshot
$(call mb_autoexec_append_cmd,$(1),omsxctl save_flight_screenshot $(2))
endef
define mb_autoexec_append_save_video
$(call mb_autoexec_append_cmd,$(1),omsxctl save_flight_video $(2))
endef
define mb_autoexec_append_safe_test
$(call mb_autoexec_append_cmd,$(1),omsxctl fail_after $(if $(3),$(3),$(MB_AUTOEXEC_TEST_TIMEOUT)) seconds failed_test $(if $(4),$(4),$(MB_AUTOEXEC_TEST_EXITCODE)))
$(call mb_autoexec_append_echo,$(1),Running test: $(2))
$(call mb_autoexec_append_cmd,$(1),$(2))
endef
define mb_autoexec_append_safe_cmd
$(call mb_autoexec_append_cmd,$(1),omsxctl fail_after $(if $(3),$(3),$(MB_AUTOEXEC_CMD_TIMEOUT)) seconds failed_cmd $(if $(4),$(4),$(MB_AUTOEXEC_CMD_EXITCODE)))
$(call mb_autoexec_append_echo,$(1),Running command: $(2))
$(call mb_autoexec_append_cmd,$(1),$(2))
endef
define mb_autoexec_write_default
@echo === Writing autoexec.bat for $(notdir $(1))
@echo -n "" > $(1)/autoexec.bat
$(if $(filter 40,$(2)),$(call mb_autoexec_append_cmd,$(1),mode 40),$(call mb_autoexec_append_cmd,$(1),mode 80))
$(call mb_autoexec_append_echo,$(1),==== MSXBUILD ====)
$(if $(filter 40,$(2)),$(call mb_autoexec_append_echo,$(1),Boot mode 40),$(call mb_autoexec_append_echo,$(1),Boot mode 80))
$(call mb_autoexec_append_cmd,$(1),omsxctl boot_exec_color_dark)
$(if $(filter on,$(MB_FLIGHT_VIDEO)),$(call mb_autoexec_append_save_video,$(1)))
$(call mb_autoexec_append_cmd,$(1),omsxctl fail_after $(MB_AUTOEXEC_STARTUP_TIMEOUT) seconds failed_exec $(MB_AUTOEXEC_STARTUP_EXITCODE))
$(if $(filter on,$(MB_AUTOEXEC_VERSION)),$(call mb_autoexec_append_cmd,$(1),ver))
$(if $(wildcard $(1)/utils),$(call mb_autoexec_append_cmd,$(1),PATH + A:\))
$(if $(wildcard $(1)/utils),$(call mb_autoexec_append_cmd,$(1),PATH + A:\UTILS))
$(if $(wildcard $(1)/utils),$(call mb_autoexec_append_cmd,$(1),PATH))
$(if $(filter on,$(MB_AUTOEXEC_VERSION)),$(call mb_autoexec_append_cmd,$(1),omsxctl boot_exec_config_info))
$(call mb_autoexec_append_echo,$(1),Run folder $(1))
$(call mb_autoexec_append_echo,$(1),Run target $@)
endef
define _mb_autoexec_show_gui
$(call mb_autoexec_write_default,$(1),$(2))
$(call mb_autoexec_append_stop_fail,$(1))
$(call mb_autoexec_append_show_gui,$(1))
$(if $(filter mouse,$(4)),$(call mb_autoexec_append_joyporta_mouse,$(1)))
$(call mb_autoexec_append_echo,$(1),Type shutdown to stop emulation)
$(if $(3),$(call mb_autoexec_append_echo,$(1),Running command: $(3)))
$(if $(3),$(call mb_autoexec_append_cmd,$(1),$(3)))
endef
define mb_autoexec_show_gui40
$(call _mb_autoexec_show_gui,$(1),40,$(2))
endef
define mb_autoexec_show_gui40_mouse
$(call _mb_autoexec_show_gui,$(1),40,$(2),mouse)
endef
define mb_autoexec_show_gui80
$(call _mb_autoexec_show_gui,$(1),80,$(2))
endef
define mb_autoexec_show_gui80_mouse
$(call _mb_autoexec_show_gui,$(1),80,$(2),mouse)
endef
define mb_autoexec_safe_cmd
$(call mb_autoexec_write_default,$(1),$(3))
$(call mb_autoexec_append_safe_cmd,$(1),$(2))
$(call mb_autoexec_append_exit,$(1))
endef
define mb_autoexec_safe_test
$(call mb_autoexec_write_default,$(1),$(3))
$(call mb_autoexec_append_safe_test,$(1),$(2))
$(call mb_autoexec_append_exit,$(1))
endef