mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 22:32:46 +00:00
Bug 735638 - add utility function checkIfEmpty - r=khuey
This commit is contained in:
parent
3713ef7a77
commit
978a5f6d8a
@ -1,14 +1,9 @@
|
||||
# -*- makefile -*-
|
||||
# vim:set ts=8 sw=8 sts=8 noet:
|
||||
#
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
# You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Joey Armstrong <joey@mozilla.com>
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
# Usage: $(call banner,foo bar tans)
|
||||
banner =\
|
||||
@ -39,3 +34,17 @@ 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)))
|
||||
|
||||
|
||||
# Usage: $(call checkIfEmpty,[error|warning] foo NULL bar)
|
||||
checkIfEmpty =$(foreach var,$(wordlist 2,100,$(getargv)),$(if $(strip $($(var))),$(NOP),$(call $(1),Variable $(var) does not contain a value)))
|
||||
|
||||
# Usage: $(call errorIfEmpty,foo NULL bar)
|
||||
errorIfEmpty =$(call checkIfEmpty,error $(getargv))
|
||||
warnIfEmpty =$(call checkIfEmpty,warning $(getargv))
|
||||
|
||||
|
||||
|
@ -1,13 +1,8 @@
|
||||
# -*- makefile -*-
|
||||
#
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
# You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Joey Armstrong <joey@mozilla.com>
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
DEPTH = ../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
@ -41,6 +36,14 @@ $(info =========================================================================
|
||||
$(info Running test: $(MAKECMDGOALS): pwd=$(CURDIR))
|
||||
$(info ===========================================================================)
|
||||
|
||||
|
||||
ifdef VERBOSE
|
||||
$(info )
|
||||
$(info ===========================================================================)
|
||||
$(info Running test: istype, getargv)
|
||||
$(info ===========================================================================)
|
||||
endif
|
||||
|
||||
## Silent errors are oh so much fun
|
||||
ifndef istype
|
||||
$(error makeutils.mk was not included)
|
||||
@ -95,6 +98,32 @@ ifneq (arg_list,$(call getargv,arg_ref))
|
||||
$(error getargv(arg_ref)=list, found [$(call getargv,arg_ref)])
|
||||
endif
|
||||
|
||||
|
||||
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
|
||||
|
||||
|
||||
|
@ -1,14 +1,9 @@
|
||||
# -*- makefile -*-
|
||||
# vim:set ts=8 sw=8 sts=8 noet:
|
||||
#
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
# You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Joey Armstrong <joey@mozilla.com>
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
# Usage: $(call banner,foo bar tans)
|
||||
banner =\
|
||||
@ -39,3 +34,17 @@ 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)))
|
||||
|
||||
|
||||
# Usage: $(call checkIfEmpty,[error|warning] foo NULL bar)
|
||||
checkIfEmpty =$(foreach var,$(wordlist 2,100,$(getargv)),$(if $(strip $($(var))),$(NOP),$(call $(1),Variable $(var) does not contain a value)))
|
||||
|
||||
# Usage: $(call errorIfEmpty,foo NULL bar)
|
||||
errorIfEmpty =$(call checkIfEmpty,error $(getargv))
|
||||
warnIfEmpty =$(call checkIfEmpty,warning $(getargv))
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user