msxbuild/lib/make/mb_autoexec.mk

97 lines
4 KiB
Makefile
Raw Normal View History

2020-12-23 17:14:13 +00:00
MB_AUTOEXEC_VERSION ?= on
2020-12-23 17:14:13 +00:00
MB_AUTOEXEC_STARTUP_TIMEOUT ?= 60
MB_AUTOEXEC_STARTUP_EXITCODE ?= 124
MB_AUTOEXEC_TEST_TIMEOUT ?= 120
MB_AUTOEXEC_TEST_EXITCODE ?= 1
2021-07-06 18:56:16 +00:00
MB_AUTOEXEC_CMD_TIMEOUT ?= 300
MB_AUTOEXEC_CMD_EXITCODE ?= 1
2020-12-23 17:14:13 +00:00
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)))
2020-12-23 17:14:13 +00:00
endef
define mb_autoexec_append_rem
$(call mb_autoexec_append_cmd,$(1),rem $(2))
endef
define mb_autoexec_append_show_gui
2024-06-30 11:52:33 +00:00
$(call mb_autoexec_append_cmd,$(1),omsxctl headless_show_gui)
2020-12-23 17:14:13 +00:00
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 headless_exit)
2020-12-23 17:14:13 +00:00
endef
define mb_autoexec_append_joyporta_mouse
$(call mb_autoexec_append_cmd,$(1),omsxctl plug joyporta mouse)
endef
define mb_autoexec_append_save_screenshot
2024-06-30 11:52:33 +00:00
$(call mb_autoexec_append_cmd,$(1),omsxctl night_flight_save_screenshot $(2))
endef
define mb_autoexec_append_save_video
2024-06-30 11:52:33 +00:00
$(call mb_autoexec_append_cmd,$(1),omsxctl night_flight_save_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
2020-12-23 17:14:13 +00:00
define mb_autoexec_write_default
2024-06-29 22:12:21 +00:00
@echo === Writing autoexec.bat for $@
2024-06-27 17:09:38 +00:00
@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))
2024-06-30 14:13:44 +00:00
$(call mb_autoexec_append_cmd,$(1),omsxctl boot_exec_color_vdp)
2024-06-29 14:04:44 +00:00
$(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))
2024-06-30 03:32:02 +00:00
$(if $(wildcard $(1)/utils),$(call mb_autoexec_append_cmd,$(1),PATH + A:\; 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 $@)
2020-12-23 17:14:13 +00:00
endef
define _mb_autoexec_show_gui
2024-06-27 17:09:38 +00:00
$(call mb_autoexec_write_default,$(1),$(2))
2020-12-23 17:14:13 +00:00
$(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)))
2024-06-27 17:09:38 +00:00
$(if $(3),$(call mb_autoexec_append_cmd,$(1),$(3)))
2020-12-23 17:14:13 +00:00
endef
define mb_autoexec_show_gui40
$(call _mb_autoexec_show_gui,$(1),40,$(2))
2024-06-27 17:09:38 +00:00
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))
2024-06-27 17:09:38 +00:00
endef
define mb_autoexec_show_gui80_mouse
$(call _mb_autoexec_show_gui,$(1),80,$(2),mouse)
endef
2024-06-27 17:09:38 +00:00
define mb_autoexec_safe_cmd
$(call mb_autoexec_write_default,$(1),$(3))
$(call mb_autoexec_append_safe_cmd,$(1),$(2))
2020-12-23 17:14:13 +00:00
$(call mb_autoexec_append_exit,$(1))
endef
2024-06-27 17:09:38 +00:00
define mb_autoexec_safe_test
$(call mb_autoexec_write_default,$(1),$(3))
$(call mb_autoexec_append_safe_test,$(1),$(2))
2020-12-23 17:14:13 +00:00
$(call mb_autoexec_append_exit,$(1))
endef