author Gregory Szorc <>
Wed, 14 Aug 2013 08:40:25 -0700
changeset 155597 13f3b8949f63adc20b0725fd3a3b3917f66c2d63
child 155603 0d9bf482b0d0bb2988910978a6b1712365bb789d
permissions -rw-r--r--
Bug 850380 - Derecursify and optimize XPIDL processing and move into precompile tier; r=glandium

# 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

topsrcdir := @top_srcdir@
srcdir := @srcdir@
VPATH := @srcdir@

include $(DEPTH)/config/


include $(topsrcdir)/config/

# Building XPIDLs effectively consists of two steps:
#   1) Staging all .idl files to a common directory.
#   2) Doing everything with the .idl files.
# Each .idl file is processed into a .h file and typelib information.
# The .h file shares the same stem as the input file and is installed
# in the common headers include directory.
# XPIDL files are logically grouped together by modules. The typelib
# information for all XPIDLs in the same module is linked together into
# an .xpt file having the name of the module.
# As an optimization to reduce overall CPU usage, we process all .idl
# belonging to a module with a single command invocation. This prevents
# redundant parsing of .idl files and significantly reduces CPU cycles.
# Future improvement: Headers are currently written to a local directory then
# installed in the distribution directory. It is preferable to write headers
# directly into the distribution directory. However, PGO builds remove the dist
# directory via rm -rf (with no regards to manifests). Since the cost of
# processing XPIDL files is not trivial, it is preferrable to cache the headers
# and reinstall them rather than regenerate them. Ideally the dist pruning is
# performed with manifests. At that time we can write headers directly to the
# dist directory.

# For dependency files.
idl_deps_dir := .deps

# Where generated headers go.
idl_headers_dir := headers

# Where we put our final, linked .xpt files.
idl_xpt_dir := xpt

dist_idl_dir := $(DIST)/idl
dist_include_dir := $(DIST)/include
process_py := $(topsrcdir)/python/mozbuild/mozbuild/action/

# TODO we should use py_action, but that would require extra directories to be
# in the virtualenv.
    $(process_py) --cache-dir $(IDL_PARSER_CACHE_DIR) $(dist_idl_dir) \
        $(idl_headers_dir) $(idl_xpt_dir) $(idl_deps_dir)

xpidl_headers := @xpidl_headers@
xpidl_modules := @xpidl_modules@


dist_headers := $(addprefix $(dist_include_dir)/,$(xpidl_headers))
linked_xpt_files := $(addprefix $(idl_xpt_dir)/,$(addsuffix .xpt,$(xpidl_modules)))
depends_files := $(foreach root,$(xpidl_modules),$(idl_deps_dir)/$(root).pp)

$(dist_headers): $(dist_include_dir)/%.h: $(idl_headers_dir)/%.h
	$(INSTALL) $< $(dist_include_dir)

xpidl:: $(linked_xpt_files) $(dist_headers)

$(linked_xpt_files): $(process_py) $(call mkdir_deps,$(idl_deps_dir) $(idl_headers_dir) $(idl_xpt_dir))

ifdef .PYMAKE
-includedeps $(depends_files)
-include $(depends_files)

.PHONY: xpidl