bug 757855: move xpidl* logic into a named makefile - batch #1
authorJoey Armstrong <joey@mozilla.com>
Fri, 01 Jun 2012 11:13:07 -0400
changeset 101755 30da794ae32ca71964099e32577ef8f370036ded
parent 101754 1a1e2787b55a8d780f678d00629eada2d01428c1
child 101756 a112cf3d055d8930f8bdb7f40b8537cc26bab787
push idunknown
push userunknown
push dateunknown
bugs757855
milestone16.0a1
bug 757855: move xpidl* logic into a named makefile - batch #1
config/makefiles/test/Makefile.in
config/makefiles/test/check-xpidl.mk
config/makefiles/xpidl.mk
config/rules.mk
js/src/config/makefiles/xpidl.mk
js/src/config/rules.mk
--- a/config/makefiles/test/Makefile.in
+++ b/config/makefiles/test/Makefile.in
@@ -15,31 +15,34 @@ USE_AUTOTARGETS_MK  = 1
 MAKEUTILS_UNIT_TEST = 1
 include $(topsrcdir)/config/makefiles/makeutils.mk
 
 dir-ts = .deps/test
 check-arglist        = $(dir-ts)/arglist.ts
 check-autotargets    = $(dir-ts)/autotargets_mk.ts
 check-export-targets = $(dir-ts)/export-targets-mk.ts
 check-XinY           = $(dir-ts)/check_XinY_mk.ts
+check-xpidl          = $(dir-ts)/xpidl-mk.ts
 check-tests =\
   $(check-arglist) \
   $(check-autotargets) \
   $(check-export-targets) \
   $(check-XinY) \
+  $(check-xpidl) \
   $(NULL)
 
 
 ##------------------_##
 ##---]  TARGETS  [---##
 ##------------------_##
 all::
 
 clean:
 	$(RM) $(check-tests)
+	@$(MAKE) --no-print-directory -f $(srcdir)/check-xpidl.mk clean-xpidl topsrcdir=$(topsrcdir)
 
 ###########################################################################
 ## Logic processed at compile time so be selective about when to test
 ## $(MAKE) check VERBOSE=1
 ifneq ($(NULL),$(findstring check,$(MAKECMDGOALS))) #
 
 check-preqs =\
   $(call mkdir_deps,$(dir-ts)) \
@@ -116,9 +119,27 @@ check-export-targets-preqs=\
 
 # include then test
 checkup: $(eval include $(srcdir)/check-export-targets.mk)
 
 $(check-export-targets): $(check-export-targets-preqs)
 	@$(TOUCH) $@
 # </CHECK: export-targets.mk>
 
-endif #} findstring check
+###########################################################################
+##{ <CHECK: xpidl.mk>
+check-xpidl-preqs=\
+  $(call mkdir_deps,$(dir-ts)) \
+  $(topsrcdir)/config/makefiles/makeutils.mk \
+  $(topsrcdir)/config/makefiles/xpidl.mk \
+  $(srcdir)/check-xpidl.mk \
+  $(NULL)
+
+check-xpidl-args =\
+  "topsrcdir=$(topsrcdir)" \
+  "srcdir=$(srcdir)" \
+  $(NULL)
+$(check-xpidl): $(check-xpidl-preqs)
+	$(MAKE) -f $(srcdir)/check-xpidl.mk check-xpidl $(check-xpidl-args)
+	@$(TOUCH) $@
+#} </check-xpidl.mk>
+
+endif #} findstring MAKECMDGOAL
new file mode 100644
--- /dev/null
+++ b/config/makefiles/test/check-xpidl.mk
@@ -0,0 +1,38 @@
+# -*- makefile -*-
+#
+# 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/.
+
+ifdef VERBOSE
+  $(warning loading test)
+endif
+
+USE_AUTOTARGETS_MK = 1
+include $(topsrcdir)/config/makefiles/makeutils.mk
+
+basedir  = blah
+DIST     = $(basedir)/dist
+DI       = $(DIST)/include
+IDL_DIR  = $(basedir)/idl
+INSTALL := cp
+
+XPIDLSRCS = $(srcdir)/check-xpidl.mk
+
+include $(topsrcdir)/config/makefiles/xpidl.mk
+
+$(call requiredfunction,topsrcdir)
+$(call requiredfunction,XPIDL_GEN_DIR)
+
+HIDE=@
+check-xpidl: xpidl-install-src xpidl-install-headers
+	$(HIDE)test -d $(DIST)                   || exit 90
+	$(HIDE)test -f $(DI)/check-xpidl.mk      || exit 91
+	$(HIDE)test -f $(IDL_DIR)/check-xpidl.mk || exit 92
+
+# Declare targets to avoid including rules.mk
+$(DI) $(IDL_DIR):
+	mkdir -p $@
+
+clean-xpidl:
+	$(RM) -r $(basedir)
new file mode 100644
--- /dev/null
+++ b/config/makefiles/xpidl.mk
@@ -0,0 +1,58 @@
+# -*- makefile -*-
+# vim:set ts=8 sw=8 sts=8 noet:
+#
+# 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/.
+#
+
+# Always declared, general use by:
+# js/xpconnect/tests/idl/Makefile.in:libs
+# toolkit/crashreporter/test/Makefile.in
+XPIDL_GEN_DIR ?= _xpidlgen
+GARBAGE_DIRS  += $(XPIDL_GEN_DIR)
+
+
+###########################################################################
+## Conditional logic
+###########################################################################
+ifndef INCLUDED_XPIDL_MK #{
+  INCLUDED_XPIDL_MK = 1
+
+  ifneq (,$(XPIDLSRCS)) #{
+
+    ifndef NO_DIST_INSTALL #{
+      _xpidl-todo_ += xpidl-install-src
+      _xpidl-todo_ += xpidl-install-headers
+    endif #}
+
+  endif #} XPIDLSRCS
+
+  export:: $(_xpidl-todo_)
+
+  $(call requiredfunction,mkdir_deps)
+endif #} INCLUDED_XPIDL_MK
+
+
+###########################################################################
+## processing targets
+###########################################################################
+ifdef _xpidl-todo_ #{
+
+## Logic batch #1
+xpidl-install-src-preqs=\
+  $(XPIDLSRCS) \
+  $(call mkdir_deps,$(IDL_DIR)) \
+  $(NULL)
+
+xpidl-install-src: $(xpidl-install-src-preqs)
+	$(INSTALL) $(IFLAGS1) $(foreach val,$^,$(call mkdir_stem,$(val)))
+
+xpidl-install-headers-preqs =\
+  $(patsubst %.idl,$(XPIDL_GEN_DIR)/%.h, $(XPIDLSRCS)) \
+  $(call mkdir_deps,$(DIST)/include) \
+  $(NULL)
+xpidl-install-headers: $(xpidl-install-headers-preqs)
+	$(INSTALL) $(IFLAGS1) $(foreach val,$^,$(call mkdir_stem,$(val)))
+
+endif #} _xpidl-todo_
--- a/config/rules.mk
+++ b/config/rules.mk
@@ -1243,17 +1243,17 @@ export:: $(AUTOCFG_JS_EXPORTS) $(FINAL_T
 endif
 
 endif
 
 ################################################################################
 # Export the elements of $(XPIDLSRCS)
 # generating .h and .xpt files and moving them to the appropriate places.
 
-ifneq ($(XPIDLSRCS),)
+ifneq ($(XPIDLSRCS),) #{
 
 export:: $(patsubst %.idl,$(XPIDL_GEN_DIR)/%.h, $(XPIDLSRCS))
 
 ifndef XPIDL_MODULE
 XPIDL_MODULE		= $(MODULE)
 endif
 
 ifeq ($(XPIDL_MODULE),) # we need $(XPIDL_MODULE) to make $(XPIDL_MODULE).xpt
@@ -1311,30 +1311,22 @@ ifndef NO_INTERFACES_MANIFEST
 	@$(PYTHON) $(MOZILLA_DIR)/config/buildlist.py $(FINAL_TARGET)/chrome.manifest "manifest components/interfaces.manifest"
 endif
 endif
 
 endif # NO_GEN_XPT
 
 GARBAGE_DIRS		+= $(XPIDL_GEN_DIR)
 
-endif # XPIDLSRCS
+endif #} XPIDLSRCS
+
 
-ifneq ($(XPIDLSRCS),)
-# export .idl files to $(IDL_DIR)
-ifndef NO_DIST_INSTALL
-export:: $(XPIDLSRCS) $(IDL_DIR)
-	$(INSTALL) $(IFLAGS1) $^
-
-export:: $(patsubst %.idl,$(XPIDL_GEN_DIR)/%.h, $(XPIDLSRCS)) $(DIST)/include
-	$(INSTALL) $(IFLAGS1) $^
-endif # NO_DIST_INSTALL
-
-endif # XPIDLSRCS
-
+ifndef INCLUDED_XPIDL_MK
+  include $(topsrcdir)/config/makefiles/xpidl.mk
+endif
 
 
 # General rules for exporting idl files.
 $(IDL_DIR):
 	$(NSINSTALL) -D $@
 
 export-idl:: $(SUBMAKEFILES) $(MAKE_DIRS)
 
new file mode 100644
--- /dev/null
+++ b/js/src/config/makefiles/xpidl.mk
@@ -0,0 +1,58 @@
+# -*- makefile -*-
+# vim:set ts=8 sw=8 sts=8 noet:
+#
+# 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/.
+#
+
+# Always declared, general use by:
+# js/xpconnect/tests/idl/Makefile.in:libs
+# toolkit/crashreporter/test/Makefile.in
+XPIDL_GEN_DIR ?= _xpidlgen
+GARBAGE_DIRS  += $(XPIDL_GEN_DIR)
+
+
+###########################################################################
+## Conditional logic
+###########################################################################
+ifndef INCLUDED_XPIDL_MK #{
+  INCLUDED_XPIDL_MK = 1
+
+  ifneq (,$(XPIDLSRCS)) #{
+
+    ifndef NO_DIST_INSTALL #{
+      _xpidl-todo_ += xpidl-install-src
+      _xpidl-todo_ += xpidl-install-headers
+    endif #}
+
+  endif #} XPIDLSRCS
+
+  export:: $(_xpidl-todo_)
+
+  $(call requiredfunction,mkdir_deps)
+endif #} INCLUDED_XPIDL_MK
+
+
+###########################################################################
+## processing targets
+###########################################################################
+ifdef _xpidl-todo_ #{
+
+## Logic batch #1
+xpidl-install-src-preqs=\
+  $(XPIDLSRCS) \
+  $(call mkdir_deps,$(IDL_DIR)) \
+  $(NULL)
+
+xpidl-install-src: $(xpidl-install-src-preqs)
+	$(INSTALL) $(IFLAGS1) $(foreach val,$^,$(call mkdir_stem,$(val)))
+
+xpidl-install-headers-preqs =\
+  $(patsubst %.idl,$(XPIDL_GEN_DIR)/%.h, $(XPIDLSRCS)) \
+  $(call mkdir_deps,$(DIST)/include) \
+  $(NULL)
+xpidl-install-headers: $(xpidl-install-headers-preqs)
+	$(INSTALL) $(IFLAGS1) $(foreach val,$^,$(call mkdir_stem,$(val)))
+
+endif #} _xpidl-todo_
--- a/js/src/config/rules.mk
+++ b/js/src/config/rules.mk
@@ -1243,17 +1243,17 @@ export:: $(AUTOCFG_JS_EXPORTS) $(FINAL_T
 endif
 
 endif
 
 ################################################################################
 # Export the elements of $(XPIDLSRCS)
 # generating .h and .xpt files and moving them to the appropriate places.
 
-ifneq ($(XPIDLSRCS),)
+ifneq ($(XPIDLSRCS),) #{
 
 export:: $(patsubst %.idl,$(XPIDL_GEN_DIR)/%.h, $(XPIDLSRCS))
 
 ifndef XPIDL_MODULE
 XPIDL_MODULE		= $(MODULE)
 endif
 
 ifeq ($(XPIDL_MODULE),) # we need $(XPIDL_MODULE) to make $(XPIDL_MODULE).xpt
@@ -1311,30 +1311,22 @@ ifndef NO_INTERFACES_MANIFEST
 	@$(PYTHON) $(MOZILLA_DIR)/config/buildlist.py $(FINAL_TARGET)/chrome.manifest "manifest components/interfaces.manifest"
 endif
 endif
 
 endif # NO_GEN_XPT
 
 GARBAGE_DIRS		+= $(XPIDL_GEN_DIR)
 
-endif # XPIDLSRCS
+endif #} XPIDLSRCS
+
 
-ifneq ($(XPIDLSRCS),)
-# export .idl files to $(IDL_DIR)
-ifndef NO_DIST_INSTALL
-export:: $(XPIDLSRCS) $(IDL_DIR)
-	$(INSTALL) $(IFLAGS1) $^
-
-export:: $(patsubst %.idl,$(XPIDL_GEN_DIR)/%.h, $(XPIDLSRCS)) $(DIST)/include
-	$(INSTALL) $(IFLAGS1) $^
-endif # NO_DIST_INSTALL
-
-endif # XPIDLSRCS
-
+ifndef INCLUDED_XPIDL_MK
+  include $(topsrcdir)/config/makefiles/xpidl.mk
+endif
 
 
 # General rules for exporting idl files.
 $(IDL_DIR):
 	$(NSINSTALL) -D $@
 
 export-idl:: $(SUBMAKEFILES) $(MAKE_DIRS)