зеркало из https://github.com/mozilla/pjs.git
Bug 734121 - helper macros for writing make user functions - r=khuey
This commit is contained in:
Родитель
d5e0d15763
Коммит
e01aa0deb9
|
@ -35,7 +35,6 @@ config/autoconf.mk
|
||||||
config/nspr/Makefile
|
config/nspr/Makefile
|
||||||
config/doxygen.cfg
|
config/doxygen.cfg
|
||||||
config/expandlibs_config.py
|
config/expandlibs_config.py
|
||||||
config/tests/src-simple/Makefile
|
|
||||||
mfbt/Makefile
|
mfbt/Makefile
|
||||||
probes/Makefile
|
probes/Makefile
|
||||||
extensions/Makefile
|
extensions/Makefile
|
||||||
|
@ -108,7 +107,9 @@ fi
|
||||||
if [ "$ENABLE_TESTS" ]; then
|
if [ "$ENABLE_TESTS" ]; then
|
||||||
add_makefiles "
|
add_makefiles "
|
||||||
build/autoconf/test/Makefile
|
build/autoconf/test/Makefile
|
||||||
|
config/makefiles/test/Makefile
|
||||||
config/tests/makefiles/autodeps/Makefile
|
config/tests/makefiles/autodeps/Makefile
|
||||||
|
config/tests/src-simple/Makefile
|
||||||
"
|
"
|
||||||
if [ ! "$LIBXUL_SDK" ]; then
|
if [ ! "$LIBXUL_SDK" ]; then
|
||||||
add_makefiles "
|
add_makefiles "
|
||||||
|
|
|
@ -0,0 +1,41 @@
|
||||||
|
# -*- 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 =\
|
||||||
|
$(info )\
|
||||||
|
$(info ***************************************************************************)\
|
||||||
|
$(info ** BANNER: $(1) $(2) $(3) $(4) $(5) $(6) $(7) $(8) $(9))\
|
||||||
|
$(info ***************************************************************************)\
|
||||||
|
|
||||||
|
## Identify function argument types
|
||||||
|
istype =$(if $(value ${1}),list,scalar)
|
||||||
|
isval =$(if $(filter-out list,$(call istype,${1})),true)
|
||||||
|
isvar =$(if $(filter-out scalar,$(call istype,${1})),true)
|
||||||
|
|
||||||
|
# Access up to 9 arguments passed, option needed to emulate $*
|
||||||
|
# Inline for function expansion, do not use $(call )
|
||||||
|
argv =$(strip
|
||||||
|
argv +=$(if $(1), $(1))$(if $(2), $(2))$(if $(3), $(3))$(if $(4), $(4))
|
||||||
|
argv +=$(if $(5), $(5))$(if $(6), $(6))$(if $(7), $(7))$(if $(8), $(8))
|
||||||
|
argv +=$(if $(9), $(9))
|
||||||
|
argv +=$(if $(10), $(error makeutils.mk::argv can only handle 9 arguments))
|
||||||
|
argv +=)
|
||||||
|
|
||||||
|
###########################################################################
|
||||||
|
## Access function args as a simple list, inline within user functions.
|
||||||
|
## Usage: $(info ** $(call banner,$(getargv)))
|
||||||
|
## $(call banner,scalar)
|
||||||
|
## $(call banner,list0 list1 list2)
|
||||||
|
## $(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))
|
|
@ -0,0 +1,100 @@
|
||||||
|
# -*- 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@
|
||||||
|
srcdir = @srcdir@
|
||||||
|
VPATH = @srcdir@
|
||||||
|
|
||||||
|
include $(DEPTH)/config/autoconf.mk
|
||||||
|
include $(topsrcdir)/config/makefiles/makeutils.mk
|
||||||
|
|
||||||
|
##------------------_##
|
||||||
|
##---] TARGETS [---##
|
||||||
|
##------------------_##
|
||||||
|
all::
|
||||||
|
|
||||||
|
###########################################################################
|
||||||
|
## This test target should really depend on a timestamp to only perform
|
||||||
|
## work when makeutils.mk is modified. That answer would require using a
|
||||||
|
## 2nd makefile imposing more shell overhead. Separate makefiles would be
|
||||||
|
## very handy for testing when pwd==$src/ but for now avoid the overhead.
|
||||||
|
##
|
||||||
|
## Test logic will be interpreted at compile time, 'fast' and 'required' so
|
||||||
|
## the test will always be run when testing is enabled.
|
||||||
|
###########################################################################
|
||||||
|
check::
|
||||||
|
@true
|
||||||
|
|
||||||
|
## Logic processed at compile time so be selective about when to test
|
||||||
|
ifneq ($(NULL),$(findstring check,$(MAKECMDGOALS)))
|
||||||
|
|
||||||
|
$(info ===========================================================================)
|
||||||
|
$(info Running test: $(MAKECMDGOALS): pwd=$(CURDIR))
|
||||||
|
$(info ===========================================================================)
|
||||||
|
|
||||||
|
## Silent errors are oh so much fun
|
||||||
|
ifndef istype
|
||||||
|
$(error makeutils.mk was not included)
|
||||||
|
endif
|
||||||
|
|
||||||
|
# arg_scalar = [scalar|literal]
|
||||||
|
arg_list = foo bar
|
||||||
|
arg_ref = arg_list
|
||||||
|
|
||||||
|
## Identify type of function argument(s)
|
||||||
|
########################################
|
||||||
|
ifneq (scalar,$(call istype,arg_scalar))
|
||||||
|
$(error istype(arg_scalar)=scalar, found [$(call istype,arg_scalar)])
|
||||||
|
endif
|
||||||
|
ifneq (list,$(call istype,arg_list))
|
||||||
|
$(error istype(arg_list)=list, found [$(call istype,arg_list)])
|
||||||
|
endif
|
||||||
|
ifneq (list,$(call istype,arg_ref))
|
||||||
|
$(error istype(arg_ref)=list, found [$(call istype,arg_ref)])
|
||||||
|
endif
|
||||||
|
|
||||||
|
## Type == scalar or a list of values
|
||||||
|
#####################################
|
||||||
|
ifneq (true,$(call isval,scalar))
|
||||||
|
$(error isval(scalar)=true, found [$(call isval,scalar)])
|
||||||
|
endif
|
||||||
|
ifneq ($(NULL),$(call isval,arg_list))
|
||||||
|
$(error isval(arg_list)=null, found [$(call isval,arg_list)])
|
||||||
|
endif
|
||||||
|
|
||||||
|
## type == reference: macro=>macro => $($(1))
|
||||||
|
#############################################
|
||||||
|
ifneq ($(NULL),$(call isvar,scalar))
|
||||||
|
$(error isvar(scalar)=$(NULL), found [$(call isvar,scalar)])
|
||||||
|
endif
|
||||||
|
ifneq (true,$(call isvar,arg_list))
|
||||||
|
$(error isvar(arg_list)=true, found [$(call isvar,arg_list)])
|
||||||
|
endif
|
||||||
|
ifneq (true,$(call isvar,arg_ref))
|
||||||
|
$(error isvar(arg_ref)=true, found [$(call isvar,arg_ref)])
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Verify getargv expansion
|
||||||
|
##########################
|
||||||
|
ifneq (scalar,$(call getargv,scalar))
|
||||||
|
$(error getargv(scalar)=scalar, found [$(call getargv,scalar)])
|
||||||
|
endif
|
||||||
|
ifneq ($(arg_list),$(call getargv,arg_list))
|
||||||
|
$(error getargv(arg_list)=list, found [$(call getargv,arg_list)])
|
||||||
|
endif
|
||||||
|
ifneq (arg_list,$(call getargv,arg_ref))
|
||||||
|
$(error getargv(arg_ref)=list, found [$(call getargv,arg_ref)])
|
||||||
|
endif
|
||||||
|
|
||||||
|
endif # check in MAKECMDGOALS
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,41 @@
|
||||||
|
# -*- 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 =\
|
||||||
|
$(info )\
|
||||||
|
$(info ***************************************************************************)\
|
||||||
|
$(info ** BANNER: $(1) $(2) $(3) $(4) $(5) $(6) $(7) $(8) $(9))\
|
||||||
|
$(info ***************************************************************************)\
|
||||||
|
|
||||||
|
## Identify function argument types
|
||||||
|
istype =$(if $(value ${1}),list,scalar)
|
||||||
|
isval =$(if $(filter-out list,$(call istype,${1})),true)
|
||||||
|
isvar =$(if $(filter-out scalar,$(call istype,${1})),true)
|
||||||
|
|
||||||
|
# Access up to 9 arguments passed, option needed to emulate $*
|
||||||
|
# Inline for function expansion, do not use $(call )
|
||||||
|
argv =$(strip
|
||||||
|
argv +=$(if $(1), $(1))$(if $(2), $(2))$(if $(3), $(3))$(if $(4), $(4))
|
||||||
|
argv +=$(if $(5), $(5))$(if $(6), $(6))$(if $(7), $(7))$(if $(8), $(8))
|
||||||
|
argv +=$(if $(9), $(9))
|
||||||
|
argv +=$(if $(10), $(error makeutils.mk::argv can only handle 9 arguments))
|
||||||
|
argv +=)
|
||||||
|
|
||||||
|
###########################################################################
|
||||||
|
## Access function args as a simple list, inline within user functions.
|
||||||
|
## Usage: $(info ** $(call banner,$(getargv)))
|
||||||
|
## $(call banner,scalar)
|
||||||
|
## $(call banner,list0 list1 list2)
|
||||||
|
## $(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))
|
Загрузка…
Ссылка в новой задаче