зеркало из https://github.com/mozilla/pjs.git
Bug 735638 - add utility function checkIfEmpty - r=khuey
This commit is contained in:
Родитель
e01aa0deb9
Коммит
320d8471b1
|
@ -1,14 +1,9 @@
|
||||||
# -*- makefile -*-
|
# -*- makefile -*-
|
||||||
# vim:set ts=8 sw=8 sts=8 noet:
|
# 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
|
# 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,
|
# 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/.
|
# 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)
|
# Usage: $(call banner,foo bar tans)
|
||||||
banner =\
|
banner =\
|
||||||
|
@ -39,3 +34,17 @@ argv +=)
|
||||||
## $(call banner,ref) ; ref=foo bar tans
|
## $(call banner,ref) ; ref=foo bar tans
|
||||||
## getarglist() would be a more accurate name but is longer to type
|
## getarglist() would be a more accurate name but is longer to type
|
||||||
getargv = $(if $(call isvar,$(1)),$($(1)),$(argv))
|
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 -*-
|
# -*- makefile -*-
|
||||||
#
|
#
|
||||||
# ***** BEGIN LICENSE BLOCK *****
|
|
||||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
# 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,
|
# 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/.
|
# You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
#
|
|
||||||
# Contributor(s):
|
|
||||||
# Joey Armstrong <joey@mozilla.com>
|
|
||||||
# ***** END LICENSE BLOCK *****
|
|
||||||
|
|
||||||
DEPTH = ../../..
|
DEPTH = ../../..
|
||||||
topsrcdir = @top_srcdir@
|
topsrcdir = @top_srcdir@
|
||||||
|
@ -41,6 +36,14 @@ $(info =========================================================================
|
||||||
$(info Running test: $(MAKECMDGOALS): pwd=$(CURDIR))
|
$(info Running test: $(MAKECMDGOALS): pwd=$(CURDIR))
|
||||||
$(info ===========================================================================)
|
$(info ===========================================================================)
|
||||||
|
|
||||||
|
|
||||||
|
ifdef VERBOSE
|
||||||
|
$(info )
|
||||||
|
$(info ===========================================================================)
|
||||||
|
$(info Running test: istype, getargv)
|
||||||
|
$(info ===========================================================================)
|
||||||
|
endif
|
||||||
|
|
||||||
## Silent errors are oh so much fun
|
## Silent errors are oh so much fun
|
||||||
ifndef istype
|
ifndef istype
|
||||||
$(error makeutils.mk was not included)
|
$(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)])
|
$(error getargv(arg_ref)=list, found [$(call getargv,arg_ref)])
|
||||||
endif
|
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
|
endif # check in MAKECMDGOALS
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,9 @@
|
||||||
# -*- makefile -*-
|
# -*- makefile -*-
|
||||||
# vim:set ts=8 sw=8 sts=8 noet:
|
# 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
|
# 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,
|
# 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/.
|
# 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)
|
# Usage: $(call banner,foo bar tans)
|
||||||
banner =\
|
banner =\
|
||||||
|
@ -39,3 +34,17 @@ argv +=)
|
||||||
## $(call banner,ref) ; ref=foo bar tans
|
## $(call banner,ref) ; ref=foo bar tans
|
||||||
## getarglist() would be a more accurate name but is longer to type
|
## getarglist() would be a more accurate name but is longer to type
|
||||||
getargv = $(if $(call isvar,$(1)),$($(1)),$(argv))
|
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))
|
||||||
|
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче