From 5f26a4588d21622ff50003f465d224adce8ba8c4 Mon Sep 17 00:00:00 2001 From: Willem Date: Sun, 7 Jul 2024 23:45:25 +0200 Subject: [PATCH] Added basic argument check on flow templates. --- lib/make/mb_assert.mk | 10 ++-------- lib/make/mb_make.mk | 40 ++++++++++++++++++++++++++++++++++++++++ lib/make/mb_proj.mk | 2 +- lib/make/mb_tool.mk | 8 ++------ 4 files changed, 45 insertions(+), 15 deletions(-) diff --git a/lib/make/mb_assert.mk b/lib/make/mb_assert.mk index 69d28ff..7c378df 100644 --- a/lib/make/mb_assert.mk +++ b/lib/make/mb_assert.mk @@ -8,10 +8,7 @@ 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)) + $(call mb_make_call,mb_make_check_args_4,mb_assert_flow_grep_binary,$(1),$(2),$(3),$(4)) $(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."," ") @@ -29,10 +26,7 @@ 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)) + $(call mb_make_call,mb_make_check_args_4,mb_assert_flow_bdos_grep,$(1),$(2),$(3),$(4)) $(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_make.mk b/lib/make/mb_make.mk index e175419..073e6d6 100644 --- a/lib/make/mb_make.mk +++ b/lib/make/mb_make.mk @@ -100,6 +100,46 @@ endef $(call mb_make_call,mb_doc_function_flow,mb_make_flow_0module,"Prints flow of recursive 0module.mk include.","") +define mb_make_check_args_1 +$(if $(2),,$(error $(1): Argument 1 missing)) +endef + + +$(call mb_make_call,mb_doc_function_deep,mb_make_check_args_1,"Checks that a function has a given argument."," ") +define mb_make_check_args_2 +$(if $(2),,$(error $(1): Argument 1 missing)) +$(if $(3),,$(error $(1): Argument 2 missing)) +endef + + +$(call mb_make_call,mb_doc_function_deep,mb_make_check_args_2,"Checks that a function has the given arguments."," ") +define mb_make_check_args_3 +$(if $(2),,$(error $(1): Argument 1 missing)) +$(if $(3),,$(error $(1): Argument 2 missing)) +$(if $(4),,$(error $(1): Argument 3 missing)) +endef + + +$(call mb_make_call,mb_doc_function_deep,mb_make_check_args_3,"Checks that a function has the given arguments."," ") +define mb_make_check_args_4 +$(if $(2),,$(error $(1): Argument 1 missing)) +$(if $(3),,$(error $(1): Argument 2 missing)) +$(if $(4),,$(error $(1): Argument 3 missing)) +$(if $(5),,$(error $(1): Argument 4 missing)) +endef + + +$(call mb_make_call,mb_doc_function_deep,mb_make_check_args_4,"Checks that a function has the given arguments."," ") +define mb_make_check_args_5 +$(if $(2),,$(error $(1): Argument 1 missing)) +$(if $(3),,$(error $(1): Argument 2 missing)) +$(if $(4),,$(error $(1): Argument 3 missing)) +$(if $(5),,$(error $(1): Argument 4 missing)) +$(if $(6),,$(error $(1): Argument 5 missing)) +endef +$(call mb_make_call,mb_doc_function_deep,mb_make_check_args_5,"Checks that a function has the given arguments."," ") + + define mb_make_echo_good $(if $(filter -1,$(MB_OS_COLORS)),@echo $(MB_MAKE_ECHO_CRAYON) $(1),$(MB_OS_ECHO) -e "\x1B[32m$(MB_MAKE_ECHO_CRAYON)$$1\x1B[39m $(1)") endef diff --git a/lib/make/mb_proj.mk b/lib/make/mb_proj.mk index ea809a8..e38e6c8 100644 --- a/lib/make/mb_proj.mk +++ b/lib/make/mb_proj.mk @@ -193,7 +193,7 @@ $$(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)) + $(call mb_make_call,mb_make_check_args_1,mb_proj_flow_setup,$(1)) $(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.","") diff --git a/lib/make/mb_tool.mk b/lib/make/mb_tool.mk index b14be5a..14ace00 100644 --- a/lib/make/mb_tool.mk +++ b/lib/make/mb_tool.mk @@ -44,9 +44,7 @@ $$(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)) + $(call mb_make_call,mb_make_check_args_3,mb_tool_m80_flow_bdos_mono,$(1),$(2),$(3)) $(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."," ") @@ -88,9 +86,7 @@ $$(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)) + $(call mb_make_call,mb_make_check_args_3,mb_tool_sdcc_flow_bdos_mono,$(1),$(2),$(3)) $(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."," ")