From 8a07c9de8d5ed33392d68c83105611a8117d3d7d Mon Sep 17 00:00:00 2001 From: Willem Date: Sun, 7 Jul 2024 23:26:47 +0200 Subject: [PATCH] Moved all eval over own function for argument validation. --- Makefile | 11 +++++------ README.md | 8 +++----- lib/make/mb_assert.mk | 18 ++++++++++++++++-- lib/make/mb_doc.mk | 6 +++++- lib/make/mb_flight.mk | 6 +++++- lib/make/mb_make.mk | 12 +++++------- lib/make/mb_proj.mk | 27 +++++++++++++++++---------- lib/make/mb_tool.mk | 16 ++++++++++++++-- src/ahello-m80/0module.mk | 6 +++--- src/ahello-sdcc/0module.mk | 6 +++--- src/mbboot80/0module.mk | 4 ++-- 11 files changed, 78 insertions(+), 42 deletions(-) diff --git a/Makefile b/Makefile index ebd5043..6403feb 100644 --- a/Makefile +++ b/Makefile @@ -100,11 +100,10 @@ endif # Generate project flow include $(PATH_MSXBUILD)/lib/make/msxbuild.mk -$(call mb_make_call_eval,mb_doc_flow_help,MSXBUILD-Example) -$(call mb_make_call_eval,mb_make_flow_0module,$(PATH_SRC)) -$(call mb_make_call_eval,mb_proj_flow_setup,$(PATH_BIN)) -$(call mb_make_call_eval,mb_flight_proj_flow_video,$(PATH_BIN)) - +$(call mb_make_call,mb_doc_flow_help,MSXBUILD-Example) +$(call mb_make_call,mb_make_flow_0module,$(PATH_SRC)) +$(call mb_make_call,mb_proj_flow_setup,$(PATH_BIN)) +$(call mb_make_call,mb_flight_proj_flow_video,$(PATH_BIN)) # Add japanese support ifdef LANG_JP @@ -115,6 +114,6 @@ MB_PROJ_STEP_AFTER_PREFIX = "フェーズ後 " MB_PROJ_STEP_DONE_PREFIX = "プライムパイターゲットの実行を終了しました " MB_OPENMSX_LOG_PREFIX = "オープンメッカシステム拡張を開始しましょう!のために" MB_AUTOEXEC_LOG_PREFIX = "自動実行の書き込み" -$(call mb_make_call_eval,mb_proj_flow_setup_jp) +$(call mb_make_call,mb_proj_flow_setup_jp) endif diff --git a/README.md b/README.md index f13341e..d0ae916 100644 --- a/README.md +++ b/README.md @@ -148,11 +148,9 @@ When you want to see whats happening do a debug run; * Add function `call_real` which exits on undefined call argument * Add -e option to make internal echo command for escaped sequences * Add native OS functions for `os_copy,os_rmfile,rmdir,mkdir,touch,delfile,deldir` -* Add string str_lenght function -* Add string str_is_ascii function (death with unicode) -* Add str_lowercase and str_uppercase functions (full 21bit unicode support) -* Add `call_eval` fail on undefined argument and puts result in eval to parse flow rules -* Add `define_eval` which reverses dollar escaping so write $$(1) for $(1) and other are like normal +* Add string letters function +* Add string isascii function (death with unicode) +* Add lowercase and uppercase functions (full 21bit unicode support) * Add XML output for help system for integration with IDE's * Add rwildcard for deeper searches * Add namespace support for variables/functions/targets like: moduleX::bin/prog.o: moduleX::src/prog.c diff --git a/lib/make/mb_assert.mk b/lib/make/mb_assert.mk index 83fa70e..69d28ff 100644 --- a/lib/make/mb_assert.mk +++ b/lib/make/mb_assert.mk @@ -1,5 +1,5 @@ -define mb_assert_flow_grep_binary +define __mb_assert_flow_grep_binary $(1)/@assert-$(2): $(1)/@build grep -q -U $(4) $(1)/$(3) $$(call mb_make_call,mb_make_echo_assert,Assert succesfully @assert-$(2)) @@ -7,10 +7,17 @@ $$(call mb_make_call,mb_doc_target,$(1)/@assert-$(2),"Asserts that $(3) output m MB_PROJ_PHASE_TEST_DEPS += $(1)/@assert-$(2) .PHONY: $(1)/@assert-$(2) endef +define mb_assert_flow_grep_binary + $(if $(1),,$(error Argument 1 missing)) + $(if $(2),,$(error Argument 2 missing)) + $(if $(3),,$(error Argument 3 missing)) + $(if $(4),,$(error Argument 4 missing)) + $(eval $(call mb_make_call,__mb_assert_flow_grep_binary,$(1),$(2),$(3),$(4))) +endef $(call mb_make_call,mb_doc_function_flow,mb_assert_flow_grep_binary,"Prints flow of single binary grep assert."," ") #$$(call mb_delete,$(1)/$(3).out) -define mb_assert_flow_bdos_grep +define __mb_assert_flow_bdos_grep $(1)-test-$(2)/@assert: $(1)/@build $$(call mb_make_call,mb_os_dir_create,$(1)-test-$(2)) $$(call mb_make_call,mb_os_file_copy,$(1)/$(3).com,$(1)-test-$(2)) @@ -21,4 +28,11 @@ $$(call mb_make_call,mb_doc_target,$(1)-test-$(2)/@assert,"Asserts that $(3) out MB_PROJ_PHASE_TEST_DEPS += $(1)-test-$(2)/@assert .PHONY: $(1)-test-$(2)/@assert endef +define mb_assert_flow_bdos_grep + $(if $(1),,$(error mb_assert_flow_bdos_grep: Argument 1 missing)) + $(if $(2),,$(error Argument 2 missing)) + $(if $(3),,$(error Argument 3 missing)) + $(if $(4),,$(error Argument 4 missing)) + $(eval $(call mb_make_call,__mb_assert_flow_bdos_grep,$(1),$(2),$(3),$(4))) +endef $(call mb_make_call,mb_doc_function_flow,mb_assert_flow_bdos_grep,"Prints flow of single grep assert."," ") diff --git a/lib/make/mb_doc.mk b/lib/make/mb_doc.mk index 92e5e50..20e75bb 100644 --- a/lib/make/mb_doc.mk +++ b/lib/make/mb_doc.mk @@ -137,7 +137,7 @@ endef MB_DOC_FIRE_FUNCTION_DEEP += $(call mb_make_call,_mb_doc_function4u_deep,mb_doc_target_run,"Prints formatted documention of an run target."," [desc]") -define mb_doc_flow_help +define __mb_doc_flow_help @help: $$(if $$(filter txt,$$(MB_DOC_FORMAT)),@echo "Welcome to the $$(if $(1),$(1),MSXBUILD) help system.\\n\\nFor detailed fire help use one of the following targets;\\n") $$(if $$(filter xml,$$(MB_DOC_FORMAT)),@echo $$(call mb_make_xml_open,$$(MB_DOC_XML_ROOT))) @@ -272,5 +272,9 @@ $$(call mb_make_call,mb_doc_target_help,@help-all,"Lists all documented informat $$(call mb_make_call,mb_doc_target_help,@help-firemake,"Output all documention in XML for IDE integration.") .PHONY: @help-firemake endef +define mb_doc_flow_help + $(if $(1),,$(error $(1) missing)) + $(eval $(call mb_make_call,__mb_doc_flow_help,$(1))) +endef MB_DOC_FIRE_FUNCTION_FLOW += $(call mb_make_call,_mb_doc_function4u_flow,mb_doc_flow_help,"Prints flow of fire help target.","[project-name]") diff --git a/lib/make/mb_flight.mk b/lib/make/mb_flight.mk index 7704da1..f8b1b56 100644 --- a/lib/make/mb_flight.mk +++ b/lib/make/mb_flight.mk @@ -27,7 +27,7 @@ endef $(call mb_make_call,mb_doc_function,mb_flight_video_merge,"Merged all flight videos to one.","") -define mb_flight_proj_flow_video +define __mb_flight_proj_flow_video @@flight-video-build: @build $$(if $$(filter on,$$(MB_FLIGHT_VIDEO)),$$(call mb_make_call,mb_flight_video_merge,$(1))) @@ -63,5 +63,9 @@ $$(call mb_make_call,mb_doc_target_help,@flight-video-test,"Runs @clean and @tes $$(call mb_make_call,mb_doc_target_help,@flight-video-package-qa,"Runs @clean and @package-qa with recorder and merges flight videos to one.") .PHONY: @flight-video-package-qa endef +define mb_flight_proj_flow_video + $(if $(1),,$(error $(1) missing)) + $(eval $(call mb_make_call,__mb_flight_proj_flow_video,$(1))) +endef $(call mb_make_call,mb_doc_function_flow,mb_flight_proj_flow_video,"Prints flow for adding flight video targets in project build cycle.","") diff --git a/lib/make/mb_make.mk b/lib/make/mb_make.mk index 18f5e39..e175419 100644 --- a/lib/make/mb_make.mk +++ b/lib/make/mb_make.mk @@ -54,12 +54,6 @@ endef $(call mb_make_call,mb_doc_function_deep,mb_make_call,"Checked origin call function wrapper."," [args...]") -define mb_make_call_eval -$(eval $(call mb_make_call,$(1),$(2),$(3),$(4),$(5),$(6),$(7),$(8),$(9))) -endef -$(call mb_make_call,mb_doc_function_deep,mb_make_call_eval,"Eval and origin checked flow injector."," [args...]") - - define mb_make_lowercase $(subst A,a,$(subst B,b,$(subst C,c,$(subst D,d,$(subst E,e,$(subst F,f,$(subst G,g,$(subst H,h,$(subst I,i,$(subst J,j,$(subst K,k,$(subst L,l,$(subst M,m,$(subst N,n,$(subst O,o,$(subst P,p,$(subst Q,q,$(subst R,r,$(subst S,s,$(subst T,t,$(subst U,u,$(subst V,v,$(subst W,w,$(subst X,x,$(subst Y,y,$(subst Z,z,$(1))))))))))))))))))))))))))) endef @@ -96,9 +90,13 @@ endef $(call mb_make_call,mb_doc_function_deep,mb_make_xml_tag_value,"Print xml tag with value inside."," [value]") -define mb_make_flow_0module +define __mb_make_flow_0module include $$(call mb_make_call,mb_make_rwildcard,$(1),*/0module.mk) endef +define mb_make_flow_0module + $(if $(1),,$(error $(1) missing)) + $(eval $(call mb_make_call,__mb_make_flow_0module,$(1))) +endef $(call mb_make_call,mb_doc_function_flow,mb_make_flow_0module,"Prints flow of recursive 0module.mk include.","") diff --git a/lib/make/mb_proj.mk b/lib/make/mb_proj.mk index 26de6af..ea809a8 100644 --- a/lib/make/mb_proj.mk +++ b/lib/make/mb_proj.mk @@ -63,24 +63,24 @@ $(call mb_make_call,mb_doc_function_deep,mb_proj_module_deps,"Convert other file define _mb_proj_flow_step_before - $(call mb_make_call,mb_make_echo_phase,$(MB_PROJ_STEP_BEFORE_PREFIX)$@) +$(call mb_make_call,mb_make_echo_phase,$(MB_PROJ_STEP_BEFORE_PREFIX)$@) endef define _mb_proj_flow_step_done - $(call mb_make_call,mb_make_echo_phase,$(MB_PROJ_STEP_AFTER_PREFIX)$@) - $(if $(filter $@,$(MAKECMDGOALS)),$(call mb_make_call,mb_make_echo_good,$(MB_PROJ_STEP_DONE_PREFIX)$@)) +$(call mb_make_call,mb_make_echo_phase,$(MB_PROJ_STEP_AFTER_PREFIX)$@) +$(if $(filter $@,$(MAKECMDGOALS)),$(call mb_make_call,mb_make_echo_good,$(MB_PROJ_STEP_DONE_PREFIX)$@)) endef define _mb_proj_run_clean - $(foreach folder,$(1),$(if $(wildcard $(folder)),$(call mb_make_call,mb_make_echo_command,Removing folder $(folder));)) - $(foreach folder,$(1),$(if $(wildcard $(folder)),$(call mb_make_call,mb_os_dir_delete,$(folder)))) +$(foreach folder,$(1),$(if $(wildcard $(folder)),$(call mb_make_call,mb_make_echo_command,Removing folder $(folder));)) +$(foreach folder,$(1),$(if $(wildcard $(folder)),$(call mb_make_call,mb_os_dir_delete,$(folder)))) endef define _mb_proj_run_init - $(foreach folder,$(1),$(if $(wildcard $(folder)),,$(call mb_make_call,mb_make_echo_command,Creating folder $(folder));)) - $(foreach folder,$(1),$(if $(wildcard $(folder)),,$(call mb_make_call,mb_os_dir_create,$(folder)))) +$(foreach folder,$(1),$(if $(wildcard $(folder)),,$(call mb_make_call,mb_make_echo_command,Creating folder $(folder));)) +$(foreach folder,$(1),$(if $(wildcard $(folder)),,$(call mb_make_call,mb_os_dir_create,$(folder)))) endef -define mb_proj_flow_setup +define __mb_proj_flow_setup @@clean: $$(call mb_make_call,_mb_proj_flow_step_before) .PHONY: @@clean @@ -188,14 +188,18 @@ $$(call mb_make_call,mb_doc_target_help,@package-qa,"Run all packages QA of proj @package-deploy: @@package-deploy $$(MB_PROJ_PHASE_PACKAGE_DEPLOY_DEPS) - $$(call mb_make_call,_mb_proj_flow_step_done) + $$(call mb_make_call,__mb_proj_flow_step_done) $$(call mb_make_call,mb_doc_target_help,@package-deploy,"Deploy all the packages.") .PHONY: @package-deploy endef +define mb_proj_flow_setup + $(if $(1),,$(error $(1) missing)) + $(eval $(call mb_make_call,__mb_proj_flow_setup,$(1))) +endef $(call mb_make_call,mb_doc_function_flow,mb_proj_flow_setup,"Prints flow of abstract project build cycle.","") -define mb_proj_flow_setup_jp +define __mb_proj_flow_setup_jp @クリーン: @clean $$(call mb_make_call,_mb_proj_flow_step_done) $$(call mb_make_call,mb_doc_target_help,@クリーン,"プロジェクトのビルドフォルダーをクリーンアップします。") @@ -246,5 +250,8 @@ $$(call mb_make_call,mb_doc_target_help,@パッケージの品質保証,"すべ $$(call mb_make_call,mb_doc_target_help,@パッケージのデプロイ,"パッケージをデプロイします。") .PHONY: @パッケージのデプロイ endef +define mb_proj_flow_setup_jp + $(eval $(call mb_make_call,__mb_proj_flow_setup_jp)) +endef $(call mb_make_call,mb_doc_function_flow,mb_proj_flow_setup_jp,"Prints flow for japanese wrapper of project build cycle.") diff --git a/lib/make/mb_tool.mk b/lib/make/mb_tool.mk index c622ade..b14be5a 100644 --- a/lib/make/mb_tool.mk +++ b/lib/make/mb_tool.mk @@ -1,5 +1,5 @@ -define mb_tool_m80_flow_bdos_mono +define __mb_tool_m80_flow_bdos_mono $(1): | @init $$(call mb_make_call,mb_os_dir_create,$(1)) $$(call mb_make_call,mb_os_dir_create,$(1)/utils) @@ -43,10 +43,16 @@ $(1)/@run: $(1)/@build $$(call mb_make_call,mb_doc_target_run,$(1)/@run,"Run $(3).com manually with gui.") .PHONY: $(1)/@run endef +define mb_tool_m80_flow_bdos_mono + $(if $(1),,$(error Argument 1 missing)) + $(if $(2),,$(error Argument 2 missing)) + $(if $(3),,$(error Argument 3 missing)) + $(eval $(call mb_make_call,__mb_tool_m80_flow_bdos_mono,$(1),$(2),$(3))) +endef $(call mb_make_call,mb_doc_function_flow,mb_tool_m80_flow_bdos_mono,"Prints flow of m80 toolchain bdos mono file module."," ") -define mb_tool_sdcc_flow_bdos_mono +define __mb_tool_sdcc_flow_bdos_mono $(1): | @init $$(call mb_make_call,mb_os_dir_create,$(1)) $$(call mb_make_call,mb_doc_target_deep,$(1)) @@ -81,5 +87,11 @@ $(1)/@run: $(1)/@build $$(call mb_make_call,mb_doc_target_run,$(1)/@run,"Run $(3).com manually with gui.") .PHONY: $(1)/@run endef +define mb_tool_sdcc_flow_bdos_mono + $(if $(1),,$(error Argument 1 missing)) + $(if $(2),,$(error Argument 2 missing)) + $(if $(3),,$(error Argument 3 missing)) + $(eval $(call mb_make_call,__mb_tool_sdcc_flow_bdos_mono,$(1),$(2),$(3))) +endef $(call mb_make_call,mb_doc_function_flow,mb_tool_sdcc_flow_bdos_mono,"Prints flow of sdcc toolchain bdos mono file module."," ") diff --git a/src/ahello-m80/0module.mk b/src/ahello-m80/0module.mk index 97f6f55..b1fd34b 100644 --- a/src/ahello-m80/0module.mk +++ b/src/ahello-m80/0module.mk @@ -3,7 +3,7 @@ AHELLO_M80_SRC := $(call mb_make_call,mb_proj_module_path_src,$(PATH_SRC)) AHELLO_M80_BIN := $(call mb_make_call,mb_proj_module_path_bin,$(PATH_SRC),$(PATH_BIN)) -$(call mb_make_call_eval,mb_tool_m80_flow_bdos_mono,$(AHELLO_M80_BIN),$(AHELLO_M80_SRC),ahello) -$(call mb_make_call_eval,mb_assert_flow_bdos_grep,$(AHELLO_M80_BIN),check-m80,ahello,M80) -$(call mb_make_call_eval,mb_assert_flow_bdos_grep,$(AHELLO_M80_BIN),check-txt,ahello,"o world...") +$(call mb_make_call,mb_tool_m80_flow_bdos_mono,$(AHELLO_M80_BIN),$(AHELLO_M80_SRC),ahello) +$(call mb_make_call,mb_assert_flow_bdos_grep,$(AHELLO_M80_BIN),check-m80,ahello,M80) +$(call mb_make_call,mb_assert_flow_bdos_grep,$(AHELLO_M80_BIN),check-txt,ahello,"o world...") diff --git a/src/ahello-sdcc/0module.mk b/src/ahello-sdcc/0module.mk index 2a23b60..c8c5d83 100644 --- a/src/ahello-sdcc/0module.mk +++ b/src/ahello-sdcc/0module.mk @@ -3,7 +3,7 @@ AHELLO_SDCC_SRC := $(call mb_make_call,mb_proj_module_path_src,$(PATH_SRC)) AHELLO_SDCC_BIN := $(call mb_make_call,mb_proj_module_path_bin,$(PATH_SRC),$(PATH_BIN)) -$(call mb_make_call_eval,mb_tool_sdcc_flow_bdos_mono,$(AHELLO_SDCC_BIN),$(AHELLO_SDCC_SRC),ahello) -$(call mb_make_call_eval,mb_assert_flow_bdos_grep,$(AHELLO_SDCC_BIN),check-sdcc,ahello,SDCC) -$(call mb_make_call_eval,mb_assert_flow_bdos_grep,$(AHELLO_SDCC_BIN),check-hell,ahello,Hell) +$(call mb_make_call,mb_tool_sdcc_flow_bdos_mono,$(AHELLO_SDCC_BIN),$(AHELLO_SDCC_SRC),ahello) +$(call mb_make_call,mb_assert_flow_bdos_grep,$(AHELLO_SDCC_BIN),check-sdcc,ahello,SDCC) +$(call mb_make_call,mb_assert_flow_bdos_grep,$(AHELLO_SDCC_BIN),check-hell,ahello,Hell) diff --git a/src/mbboot80/0module.mk b/src/mbboot80/0module.mk index bd5e27c..6534d0d 100644 --- a/src/mbboot80/0module.mk +++ b/src/mbboot80/0module.mk @@ -3,8 +3,8 @@ MBBOOT80_SRC := $(call mb_make_call,mb_proj_module_path_src,$(PATH_SRC)) MBBOOT80_BIN := $(call mb_make_call,mb_proj_module_path_bin,$(PATH_SRC),$(PATH_BIN)) -$(call mb_make_call_eval,mb_tool_sdcc_flow_bdos_mono,$(MBBOOT80_BIN),$(MBBOOT80_SRC),mbboot80) -$(call mb_make_call_eval,mb_assert_flow_bdos_grep,$(MBBOOT80_BIN),check-boot80,mbboot80,"mb::boot mode 80") +$(call mb_make_call,mb_tool_sdcc_flow_bdos_mono,$(MBBOOT80_BIN),$(MBBOOT80_SRC),mbboot80) +$(call mb_make_call,mb_assert_flow_bdos_grep,$(MBBOOT80_BIN),check-boot80,mbboot80,"mb::boot mode 80") $(MBBOOT80_BIN)/@release-local: | $(MBBOOT80_BIN)/@build