michael@0: # This Source Code Form is subject to the terms of the Mozilla Public michael@0: # License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: # file, You can obtain one at http://mozilla.org/MPL/2.0/. michael@0: michael@0: STANDALONE_MAKEFILE := 1 michael@0: michael@0: include $(topsrcdir)/config/rules.mk michael@0: michael@0: # Building XPIDLs effectively consists of two steps: michael@0: # michael@0: # 1) Staging all .idl files to a common directory. michael@0: # 2) Doing everything with the .idl files. michael@0: # michael@0: # Each .idl file is processed into a .h file and typelib information. michael@0: # The .h file shares the same stem as the input file and is installed michael@0: # in the common headers include directory. michael@0: # michael@0: # XPIDL files are logically grouped together by modules. The typelib michael@0: # information for all XPIDLs in the same module is linked together into michael@0: # an .xpt file having the name of the module. michael@0: # michael@0: # As an optimization to reduce overall CPU usage, we process all .idl michael@0: # belonging to a module with a single command invocation. This prevents michael@0: # redundant parsing of .idl files and significantly reduces CPU cycles. michael@0: # michael@0: # Future improvement: Headers are currently written to a local directory then michael@0: # installed in the distribution directory. It is preferable to write headers michael@0: # directly into the distribution directory. However, PGO builds remove the dist michael@0: # directory via rm -rf (with no regards to manifests). Since the cost of michael@0: # processing XPIDL files is not trivial, it is preferrable to cache the headers michael@0: # and reinstall them rather than regenerate them. Ideally the dist pruning is michael@0: # performed with manifests. At that time we can write headers directly to the michael@0: # dist directory. michael@0: michael@0: # For dependency files. michael@0: idl_deps_dir := .deps michael@0: michael@0: # Where we put our final, linked .xpt files. michael@0: idl_xpt_dir := xpt michael@0: michael@0: dist_idl_dir := $(DIST)/idl michael@0: dist_include_dir := $(DIST)/include michael@0: process_py := $(topsrcdir)/python/mozbuild/mozbuild/action/xpidl-process.py michael@0: michael@0: # TODO we should use py_action, but that would require extra directories to be michael@0: # in the virtualenv. michael@0: idlprocess := $(PYTHON_PATH) $(PLY_INCLUDE) -I$(IDL_PARSER_DIR) -I$(IDL_PARSER_CACHE_DIR) \ michael@0: $(process_py) --cache-dir $(IDL_PARSER_CACHE_DIR) $(dist_idl_dir) \ michael@0: $(dist_include_dir) $(idl_xpt_dir) $(idl_deps_dir) michael@0: michael@0: ifdef LIBXUL_SDK michael@0: idlprocess += -I$(LIBXUL_SDK)/idl michael@0: endif michael@0: michael@0: xpidl_modules := @xpidl_modules@ michael@0: michael@0: @xpidl_rules@ michael@0: michael@0: linked_xpt_files := $(addprefix $(idl_xpt_dir)/,$(addsuffix .xpt,$(xpidl_modules))) michael@0: depends_files := $(foreach root,$(xpidl_modules),$(idl_deps_dir)/$(root).pp) michael@0: michael@0: GARBAGE += $(linked_xpt_files) $(depends_files) michael@0: michael@0: xpidl:: $(linked_xpt_files) michael@0: michael@0: $(linked_xpt_files): $(process_py) $(call mkdir_deps,$(idl_deps_dir) $(dist_include_dir) $(idl_xpt_dir)) michael@0: michael@0: $(call include_deps,$(depends_files)) michael@0: michael@0: .PHONY: xpidl