Allow multiple vars to be embedded.
All checks were successful
Run test asserts / Test-Asserts (push) Successful in 1s

This commit is contained in:
Willem Cazander 2024-07-03 13:30:35 +02:00
parent 6be8161ff4
commit e48337d6ef
3 changed files with 19 additions and 10 deletions

View file

@ -4,6 +4,10 @@ on:
branches:
- master
pull_request:
env:
MB_AUTOEXEC_STARTUP_NOTE: ${{vars.GITHUB_WORKFLOW}}
MB_AUTOEXEC_EMBED_USER: GITHUB_ACTOR
MB_AUTOEXEC_EMBED_VARS: GITHUB_EVENT_NAME GITHUB_REF_NAME GITHUB_REF_TYPE GITHUB_REPOSITORY GITHUB_REPOSITORY_OWNER
jobs:
Test-Asserts:
runs-on: self-hosted

View file

@ -47,8 +47,11 @@ MB_DOC_HELP_VARIABLE += $(call mb_doc_variable,MB_AUTOEXEC_COLOR_FG,"Default for
MB_AUTOEXEC_COLOR_BG ?= 000
MB_DOC_HELP_VARIABLE += $(call mb_doc_variable,MB_AUTOEXEC_COLOR_BG,"Default background color if none if given.")
MB_AUTOEXEC_EMBED_VARIABLE ?=
MB_DOC_HELP_VARIABLE += $(call mb_doc_variable,MB_AUTOEXEC_EMBED_VARIABLE,"Embed the host env variable as msx env variable.")
MB_AUTOEXEC_EMBED_VARS ?=
MB_DOC_HELP_VARIABLE += $(call mb_doc_variable,MB_AUTOEXEC_EMBED_VARS,"List of host env variables to copy to msx as 'MB_x' variable.")
MB_AUTOEXEC_EMBED_USER ?= USER
MB_DOC_HELP_VARIABLE += $(call mb_doc_variable,MB_AUTOEXEC_EMBED_USER,"Embedds this host variable to the msx as 'MK_USER' variable.")
MB_AUTOEXEC_TIME_FORMAT ?= 24
MB_DOC_HELP_VARIABLE += $(call mb_doc_variable,MB_AUTOEXEC_TIME_FORMAT,"The time format the msx will get set to.")
@ -56,7 +59,7 @@ MB_DOC_HELP_VARIABLE += $(call mb_doc_variable,MB_AUTOEXEC_TIME_FORMAT,"The time
MB_AUTOEXEC_DATE_FORMAT ?= DD/MM/YY
MB_DOC_HELP_VARIABLE += $(call mb_doc_variable,MB_AUTOEXEC_DATE_FORMAT,"The time format the msx will get set to.")
MB_AUTOEXEC_PROMPT_FORMAT ?= %MB_USER%@%_CWD%$
MB_AUTOEXEC_PROMPT_FORMAT ?= %MK_USER%@%_CWD%$
MB_DOC_HELP_VARIABLE += $(call mb_doc_variable,MB_AUTOEXEC_PROMPT_FORMAT,"The prompt format for command 2.40 and higher.")
MB_AUTOEXEC_PROMPT_SPACE ?= on
@ -158,16 +161,17 @@ define mb_autoexec_write_default
$(if $(MB_AUTOEXEC_STARTUP_NOTE),$(call mb_autoexec_append_echo,$(1),mb::note $(MB_AUTOEXEC_STARTUP_NOTE)))
$(if $(filter on,$(MB_FLIGHT_VIDEO)),$(call mb_autoexec_append_save_video,$(1)))
$(if $(filter on,$(MB_AUTOEXEC_SHOW_HOST)),$(call mb_autoexec_append_cmd,$(1),omsxctl boot_exec_show_host))
$(if $(MB_AUTOEXEC_EMBED_VARIABLE),$(call mb_autoexec_append_cmd,$(1),set MB_$(MB_AUTOEXEC_EMBED_VARIABLE)=$($(MB_AUTOEXEC_EMBED_VARIABLE))))
echo -n "$(subst $(MB_CHAR_SPACE)set,set,$(foreach var,$(MB_AUTOEXEC_EMBED_VARS),set MB_$(var)=$($(var))\r\n))" >> $(1)/autoexec.bat
$(call mb_autoexec_append_cmd,$(1),set TIME=$(MB_AUTOEXEC_TIME_FORMAT))
$(call mb_autoexec_append_cmd,$(1),set DATE=$(MB_AUTOEXEC_DATE_FORMAT))
$(call mb_autoexec_append_cmd,$(1),set MB_USER=$(USER))
$(if $(filter on,$(MB_AUTOEXEC_SHOW_PATH)),$(call mb_autoexec_append_cmd,$(1),echo mb::path %PATH%))
$(if $(filter on,$(MB_AUTOEXEC_SHOW_USER)),$(call mb_autoexec_append_echo,$(1),mb::user %MB_USER%))
$(call mb_autoexec_append_cmd,$(1),set MB_MAKE=$@)
$(call mb_autoexec_append_cmd,$(1),set MB_MAKE_PART=$(notdir $@))
$(if $(filter on,$(MB_AUTOEXEC_SHOW_FOLDER)),$(call mb_autoexec_append_echo,$(1),mb::bath $(1)))
$(if $(filter on,$(MB_AUTOEXEC_SHOW_TARGET)),$(call mb_autoexec_append_echo,$(1),mb::pipe %MB_MAKE%))
$(call mb_autoexec_append_cmd,$(1),set MK_SNAIL=$(notdir $@))
$(call mb_autoexec_append_cmd,$(1),set MK_USER=$($(MB_AUTOEXEC_EMBED_USER)))
$(if $(filter on,$(MB_AUTOEXEC_SHOW_USER)),$(call mb_autoexec_append_echo,$(1),mb::user %MK_USER%))
$(call mb_autoexec_append_cmd,$(1),set MK_SLIME=$(1))
$(call mb_autoexec_append_cmd,$(1),set MK_TARGET=$@)
$(if $(filter on,$(MB_AUTOEXEC_SHOW_FOLDER)),$(call mb_autoexec_append_echo,$(1),mb::bath %MK_SLIME%))
$(if $(filter on,$(MB_AUTOEXEC_SHOW_TARGET)),$(call mb_autoexec_append_echo,$(1),mb::pipe %MK_TARGET%))
$(if $(filter on,$(MB_AUTOEXEC_PROMPT_SPACE)),$(call mb_autoexec_append_cmd,$(1),set PROMPT \"$(MB_AUTOEXEC_PROMPT_FORMAT) \"),$(call mb_autoexec_append_cmd,$(1),set PROMPT \"$(MB_AUTOEXEC_PROMPT_FORMAT)\"))
endef
MB_DOC_HELP_FUNCTION += $(call mb_doc_function,mb_autoexec_write_default,"Write a default autoexec.bat file.","<dir> [fg-color] [bg-color]")

View file

@ -42,6 +42,7 @@ MB_PSEP = $(strip $(MB_SEP))
# Special chars call arguments (like for l80.com)
MB_CHAR_COMMA := ","
MB_CHAR_SPACE := $(subst ,, )
MB_CHAR_GT := ">"
MB_CHAR_LT := "<"
MB_CHAR_CDATA_START := "<![CDATA["