| 1 |
# This Source Code Form is subject to the terms of the Mozilla Public |
| 2 |
# License, v. 2.0. If a copy of the MPL was not distributed with this |
| 3 |
# file, You can obtain one at http://mozilla.org/MPL/2.0/. |
| 4 |
|
| 5 |
STANDALONE_MAKEFILE := 1 |
| 6 |
|
| 7 |
include $(topsrcdir)/config/rules.mk |
| 8 |
|
| 9 |
# Building XPIDLs effectively consists of two steps: |
| 10 |
# |
| 11 |
# 1) Staging all .idl files to a common directory. |
| 12 |
# 2) Doing everything with the .idl files. |
| 13 |
# |
| 14 |
# Each .idl file is processed into a .h file and typelib information. |
| 15 |
# The .h file shares the same stem as the input file and is installed |
| 16 |
# in the common headers include directory. |
| 17 |
# |
| 18 |
# XPIDL files are logically grouped together by modules. The typelib |
| 19 |
# information for all XPIDLs in the same module is linked together into |
| 20 |
# an .xpt file having the name of the module. |
| 21 |
# |
| 22 |
# As an optimization to reduce overall CPU usage, we process all .idl |
| 23 |
# belonging to a module with a single command invocation. This prevents |
| 24 |
# redundant parsing of .idl files and significantly reduces CPU cycles. |
| 25 |
|
| 26 |
# For dependency files. |
| 27 |
idl_deps_dir := .deps |
| 28 |
|
| 29 |
dist_idl_dir := $(DIST)/idl |
| 30 |
dist_include_dir := $(DIST)/include |
| 31 |
dist_xpcrs_dir := $(DIST)/xpcrs |
| 32 |
stub_file := xptdata.stub |
| 33 |
process_py := $(topsrcdir)/python/mozbuild/mozbuild/action/xpidl-process.py |
| 34 |
target_file := $(topobjdir)/xpcom/reflect/xptinfo/xptdata.cpp |
| 35 |
xptdata_h := $(dist_include_dir)/xptdata.h |
| 36 |
generated_files := $(target_file) $(xptdata_h) |
| 37 |
code_gen_py := $(topsrcdir)/xpcom/reflect/xptinfo/xptcodegen.py |
| 38 |
code_gen_deps := $(topsrcdir)/xpcom/ds/tools/perfecthash.py |
| 39 |
|
| 40 |
# TODO we should use py_action, but that would require extra directories to be |
| 41 |
# in the virtualenv. |
| 42 |
%.xpt: |
| 43 |
$(REPORT_BUILD) |
| 44 |
$(call BUILDSTATUS,START_xpt $@) |
| 45 |
$(PYTHON3) $(process_py) --depsdir $(idl_deps_dir) \ |
| 46 |
--bindings-conf $(topsrcdir)/dom/bindings/Bindings.conf \ |
| 47 |
$(foreach dir,$(all_idl_dirs),-I $(dir)) \ |
| 48 |
$(dist_include_dir) $(dist_xpcrs_dir) $(@D) \ |
| 49 |
$(basename $(notdir $@)) $($(basename $(notdir $@))_deps) |
| 50 |
# When some IDL is added or removed, if the actual IDL file was already, or |
| 51 |
# still is, in the tree, simple dependencies can't detect that the XPT needs |
| 52 |
# to be rebuilt. |
| 53 |
# Add the current value of $($(xpidl_module)_deps) in the depend file, such that |
| 54 |
# we can later check if the value has changed since last build, which will |
| 55 |
# indicate whether IDLs were added or removed. |
| 56 |
# Note that removing previously built files is not covered. |
| 57 |
@echo $(basename $(notdir $@))_deps_built = $($(basename $(notdir $@))_deps) >> $(idl_deps_dir)/$(basename $(notdir $@)).pp |
| 58 |
$(call BUILDSTATUS,END_xpt $@) |
| 59 |
|
| 60 |
xpidl_modules := @xpidl_modules@ |
| 61 |
xpt_files := $(addsuffix .xpt,$(xpidl_modules)) |
| 62 |
|
| 63 |
@xpidl_rules@ |
| 64 |
|
| 65 |
depends_files := $(foreach root,$(xpidl_modules),$(idl_deps_dir)/$(root).pp) |
| 66 |
|
| 67 |
ifdef COMPILE_ENVIRONMENT |
| 68 |
xpidl:: $(generated_files) |
| 69 |
endif |
| 70 |
|
| 71 |
# See bug 1420119 for why we need the semicolon. |
| 72 |
$(target_file) $(xptdata_h) : $(stub_file) ; |
| 73 |
|
| 74 |
$(xpt_files): $(process_py) $(call mkdir_deps,$(idl_deps_dir) $(dist_include_dir) $(dist_xpcrs_dir)) |
| 75 |
|
| 76 |
$(stub_file) : $(xpt_files) $(code_gen_py) $(code_gen_deps) |
| 77 |
$(REPORT_BUILD) |
| 78 |
$(call BUILDSTATUS,START_xpt $(notdir $(generated_files))) |
| 79 |
$(PYTHON3) $(code_gen_py) $(generated_files) $(xpt_files) |
| 80 |
@touch $@ |
| 81 |
$(call BUILDSTATUS,END_xpt $(notdir $(generated_files))) |
| 82 |
|
| 83 |
-include $(depends_files) |
| 84 |
|
| 85 |
define xpt_deps |
| 86 |
$(1): $(call mkdir_deps,$(dir $(1))) |
| 87 |
ifneq ($($(basename $(notdir $(1)))_deps),$($(basename $(notdir $(1)))_deps_built)) |
| 88 |
$(1): FORCE |
| 89 |
endif |
| 90 |
endef |
| 91 |
|
| 92 |
$(foreach xpt,$(xpt_files),$(eval $(call xpt_deps,$(xpt)))) |
| 93 |
|
| 94 |
.PHONY: xpidl |