Bug 746151 - re-add approved patch edits that were merged away - r=coop

This commit is contained in:
Joey Armstrong 2012-04-26 18:12:20 -04:00
parent 3acc91ede6
commit 09aeb22041
3 changed files with 68 additions and 2 deletions

View File

@ -34,3 +34,20 @@ argv +=)
## $(call banner,ref) ; ref=foo bar tans
## getarglist() would be a more accurate name but is longer to type
getargv = $(if $(call isvar,$(1)),$($(1)),$(argv))
## http://www.gnu.org/software/make/manual/make.html#Call-Function
## Usage: o = $(call map,origin,o map $(MAKE))
map = $(foreach val,$(2),$(call $(1),$(val)))
## Disable checking for clean targets
ifeq (,$(filter %clean clean%,$(MAKECMDGOALS)))
# Usage: $(call checkIfEmpty,[error|warning] foo NULL bar)
checkIfEmpty =$(foreach var,$(wordlist 2,100,$(argv)),$(if $(strip $($(var))),$(NOP),$(call $(1),Variable $(var) does not contain a value)))
# Usage: $(call errorIfEmpty,foo NULL bar)
errorIfEmpty =$(call checkIfEmpty,error $(argv))
warnIfEmpty =$(call checkIfEmpty,warning $(argv))
endif

View File

@ -30,12 +30,21 @@ check::
@true
## Logic processed at compile time so be selective about when to test
ifneq ($(NULL),$(findstring check,$(MAKECMDGOALS)))
ifneq ($(NULL),$(findstring check,$(MAKECMDGOALS))) #{
ifdef VERBOSE
$(info ===========================================================================)
$(info Running test: $(MAKECMDGOALS): pwd=$(CURDIR))
$(info ===========================================================================)
$(info )
$(info ===========================================================================)
$(info Running test: istype, getargv)
$(info ===========================================================================)
endif
## Silent errors are oh so much fun
ifndef istype
$(error makeutils.mk was not included)
@ -90,6 +99,29 @@ ifneq (arg_list,$(call getargv,arg_ref))
$(error getargv(arg_ref)=list, found [$(call getargv,arg_ref)])
endif
endif # check in MAKECMDGOALS
ifdef MANUAL_TEST #{
# For automated testing a callback is needed that can set an external status
# variable that can be tested. Syntax is tricky to get correct functionality.
ifdef VERBOSE
$(info )
$(info ===========================================================================)
$(info Running test: checkIfEmpty)
$(info ===========================================================================)
endif
#status =
#setTRUE =status=true
#setFALSE =status=$(NULL)
#$(call checkIfEmpty,setFALSE NULL)
#$(if $(status),$(error checkIfEmpty(xyz) failed))
#$(call checkIfEmpty,setTRUE xyz)
#$(if $(status),$(error checkIfEmpty(xyz) failed))
xyz=abc
$(info STATUS: warnIfEmpty - two vars)
$(call warnIfEmpty,foo xyz bar)
$(info STATUS: errorIfEmpty - on first var)
$(call errorIfEmpty,foo xyz bar)
$(error TEST FAILED: processing should not reach this point)
endif #}
endif #} check in MAKECMDGOALS

View File

@ -34,3 +34,20 @@ argv +=)
## $(call banner,ref) ; ref=foo bar tans
## getarglist() would be a more accurate name but is longer to type
getargv = $(if $(call isvar,$(1)),$($(1)),$(argv))
## http://www.gnu.org/software/make/manual/make.html#Call-Function
## Usage: o = $(call map,origin,o map $(MAKE))
map = $(foreach val,$(2),$(call $(1),$(val)))
## Disable checking for clean targets
ifeq (,$(filter %clean clean%,$(MAKECMDGOALS)))
# Usage: $(call checkIfEmpty,[error|warning] foo NULL bar)
checkIfEmpty =$(foreach var,$(wordlist 2,100,$(argv)),$(if $(strip $($(var))),$(NOP),$(call $(1),Variable $(var) does not contain a value)))
# Usage: $(call errorIfEmpty,foo NULL bar)
errorIfEmpty =$(call checkIfEmpty,error $(argv))
warnIfEmpty =$(call checkIfEmpty,warning $(argv))
endif