|
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 # Future improvement: Headers are currently written to a local directory then |
|
27 # installed in the distribution directory. It is preferable to write headers |
|
28 # directly into the distribution directory. However, PGO builds remove the dist |
|
29 # directory via rm -rf (with no regards to manifests). Since the cost of |
|
30 # processing XPIDL files is not trivial, it is preferrable to cache the headers |
|
31 # and reinstall them rather than regenerate them. Ideally the dist pruning is |
|
32 # performed with manifests. At that time we can write headers directly to the |
|
33 # dist directory. |
|
34 |
|
35 # For dependency files. |
|
36 idl_deps_dir := .deps |
|
37 |
|
38 # Where we put our final, linked .xpt files. |
|
39 idl_xpt_dir := xpt |
|
40 |
|
41 dist_idl_dir := $(DIST)/idl |
|
42 dist_include_dir := $(DIST)/include |
|
43 process_py := $(topsrcdir)/python/mozbuild/mozbuild/action/xpidl-process.py |
|
44 |
|
45 # TODO we should use py_action, but that would require extra directories to be |
|
46 # in the virtualenv. |
|
47 idlprocess := $(PYTHON_PATH) $(PLY_INCLUDE) -I$(IDL_PARSER_DIR) -I$(IDL_PARSER_CACHE_DIR) \ |
|
48 $(process_py) --cache-dir $(IDL_PARSER_CACHE_DIR) $(dist_idl_dir) \ |
|
49 $(dist_include_dir) $(idl_xpt_dir) $(idl_deps_dir) |
|
50 |
|
51 ifdef LIBXUL_SDK |
|
52 idlprocess += -I$(LIBXUL_SDK)/idl |
|
53 endif |
|
54 |
|
55 xpidl_modules := @xpidl_modules@ |
|
56 |
|
57 @xpidl_rules@ |
|
58 |
|
59 linked_xpt_files := $(addprefix $(idl_xpt_dir)/,$(addsuffix .xpt,$(xpidl_modules))) |
|
60 depends_files := $(foreach root,$(xpidl_modules),$(idl_deps_dir)/$(root).pp) |
|
61 |
|
62 GARBAGE += $(linked_xpt_files) $(depends_files) |
|
63 |
|
64 xpidl:: $(linked_xpt_files) |
|
65 |
|
66 $(linked_xpt_files): $(process_py) $(call mkdir_deps,$(idl_deps_dir) $(dist_include_dir) $(idl_xpt_dir)) |
|
67 |
|
68 $(call include_deps,$(depends_files)) |
|
69 |
|
70 .PHONY: xpidl |