Bug 1609564 [wpt PR 21209] - Update wpt metadata, a=testonly
[gecko.git] / config / recurse.mk
blob0d6102fac2f0db5a3b761b6bcd292ae370bbd1de
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 file,
3 # You can obtain one at http://mozilla.org/MPL/2.0/.
5 ifndef INCLUDED_RULES_MK
6 include $(topsrcdir)/config/rules.mk
7 endif
9 # The traditional model of directory traversal with make is as follows:
10 # make -C foo
11 # Entering foo
12 # make -C bar
13 # Entering foo/bar
14 # make -C baz
15 # Entering foo/baz
16 # make -C qux
17 # Entering qux
19 # Pseudo derecurse transforms the above into:
20 # make -C foo
21 # make -C foo/bar
22 # make -C foo/baz
23 # make -C qux
25 ifeq (.,$(DEPTH))
27 include root.mk
29 # Main rules (export, compile, libs and tools) call recurse_* rules.
30 # This wrapping is only really useful for build status.
31 $(RUNNABLE_TIERS)::
32 $(if $(filter $@,$(MAKECMDGOALS)),$(call BUILDSTATUS,TIERS $@),)
33 $(call BUILDSTATUS,TIER_START $@)
34 +$(MAKE) recurse_$@
35 $(call BUILDSTATUS,TIER_FINISH $@)
37 # Special rule that does install-manifests (cf. Makefile.in) + compile
38 binaries::
39 +$(MAKE) recurse_compile
41 # Carefully avoid $(eval) type of rule generation, which makes pymake slower
42 # than necessary.
43 # Get current tier and corresponding subtiers from the data in root.mk.
44 CURRENT_TIER := $(filter $(foreach tier,$(RUNNABLE_TIERS) $(non_default_tiers),recurse_$(tier) $(tier)-deps),$(MAKECMDGOALS))
45 ifneq (,$(filter-out 0 1,$(words $(CURRENT_TIER))))
46 $(error $(CURRENT_TIER) not supported on the same make command line)
47 endif
48 CURRENT_TIER := $(subst recurse_,,$(CURRENT_TIER:-deps=))
50 # The rules here are doing directory traversal, so we don't want further
51 # recursion to happen when running make -C subdir $tier. But some make files
52 # further call make -C something else, and sometimes expect recursion to
53 # happen in that case.
54 # Conveniently, every invocation of make increases MAKELEVEL, so only stop
55 # recursion from happening at current MAKELEVEL + 1.
56 ifdef CURRENT_TIER
57 ifeq (0,$(MAKELEVEL))
58 export NO_RECURSE_MAKELEVEL=1
59 else
60 export NO_RECURSE_MAKELEVEL=$(word $(MAKELEVEL),2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20)
61 endif
62 endif
64 RECURSE = $(if $(RECURSE_TRACE_ONLY),@echo $2/$1,$(call SUBMAKE,$1,$2))
66 # Use the $(*_dirs) variables available in root.mk
67 CURRENT_DIRS := $($(CURRENT_TIER)_dirs)
69 # Need a list of compile targets because we can't use pattern rules:
70 # https://savannah.gnu.org/bugs/index.php?42833
71 # Only recurse the paths starting with RECURSE_BASE_DIR when provided.
72 .PHONY: $(compile_targets) $(syms_targets)
73 $(compile_targets) $(syms_targets):
74 $(if $(filter $(RECURSE_BASE_DIR)%,$@),$(call RECURSE,$(@F),$(@D)))
76 $(syms_targets): %/syms: %/target
78 # Only hook symbols targets into the main compile graph in automation.
79 ifdef MOZ_AUTOMATION
80 ifeq (1,$(MOZ_AUTOMATION_BUILD_SYMBOLS))
81 recurse_compile: $(syms_targets)
82 endif
83 endif
85 # Create a separate rule that depends on every 'syms' target so that
86 # symbols can be dumped on demand locally.
87 .PHONY: recurse_syms
88 recurse_syms: $(syms_targets)
90 # Ensure dump_syms gets built before any syms targets, all of which depend on it.
91 ifneq (,$(filter toolkit/crashreporter/google-breakpad/src/tools/%/dump_syms/host,$(compile_targets)))
92 $(syms_targets): $(filter toolkit/crashreporter/google-breakpad/src/tools/%/dump_syms/host,$(compile_targets))
93 endif
95 # The compile tier has different rules from other tiers.
96 ifneq ($(CURRENT_TIER),compile)
98 # Recursion rule for all directories traversed for all subtiers in the
99 # current tier.
100 $(addsuffix /$(CURRENT_TIER),$(CURRENT_DIRS)): %/$(CURRENT_TIER):
101 $(call RECURSE,$(CURRENT_TIER),$*)
103 .PHONY: $(addsuffix /$(CURRENT_TIER),$(CURRENT_DIRS))
105 # Dummy rules for possibly inexisting dependencies for the above tier targets
106 $(addsuffix /Makefile,$(CURRENT_DIRS)) $(addsuffix /backend.mk,$(CURRENT_DIRS)):
108 ifeq ($(CURRENT_TIER),export)
109 # At least build/export requires config/export for buildid, but who knows what
110 # else, so keep this global dependency to make config/export first for now.
111 $(addsuffix /$(CURRENT_TIER),$(filter-out config,$(CURRENT_DIRS))): config/$(CURRENT_TIER)
113 # The export tier requires nsinstall, which is built from config. So every
114 # subdirectory traversal needs to happen after building nsinstall in config, which
115 # is done with the config/host target. Note the config/host target only exists if
116 # nsinstall is actually built, which it is not on Windows, because we use
117 # nsinstall.py there.
118 ifdef COMPILE_ENVIRONMENT
119 ifneq (,$(filter config/host, $(compile_targets)))
120 $(addsuffix /$(CURRENT_TIER),$(CURRENT_DIRS)): config/host
121 endif
122 endif
123 endif
125 endif # ifeq ($(CURRENT_TIER),compile)
127 else
129 # Don't recurse if MAKELEVEL is NO_RECURSE_MAKELEVEL as defined above
130 ifeq ($(NO_RECURSE_MAKELEVEL),$(MAKELEVEL))
132 $(RUNNABLE_TIERS)::
134 else
135 #########################
136 # Tier traversal handling
137 #########################
139 define CREATE_SUBTIER_TRAVERSAL_RULE
140 .PHONY: $(1)
142 $(1):: $$(SUBMAKEFILES)
143 $$(LOOP_OVER_DIRS)
145 endef
147 $(foreach subtier,$(filter-out compile,$(RUNNABLE_TIERS)),$(eval $(call CREATE_SUBTIER_TRAVERSAL_RULE,$(subtier))))
149 ifndef TOPLEVEL_BUILD
150 ifdef COMPILE_ENVIRONMENT
151 compile::
152 @$(MAKE) -C $(DEPTH) compile RECURSE_BASE_DIR=$(relativesrcdir)/
153 endif # COMPILE_ENVIRONMENT
154 endif
156 endif # ifeq ($(NO_RECURSE_MAKELEVEL),$(MAKELEVEL))
158 endif # ifeq (.,$(DEPTH))
160 recurse:
161 @$(RECURSED_COMMAND)
162 $(LOOP_OVER_DIRS)
164 ifeq (.,$(DEPTH))
165 # Interdependencies for parallel export.
166 js/xpconnect/src/export: dom/bindings/export xpcom/xpidl/export
167 accessible/xpcom/export: xpcom/xpidl/export
169 # The Android SDK bindings needs to build the Java generator code
170 # source code in order to write the SDK bindings.
171 widget/android/bindings/export: mobile/android/base/export
173 # The widget JNI wrapper generator code needs to build the GeckoView
174 # source code in order to find JNI wrapper annotations.
175 widget/android/export: mobile/android/base/export
177 # .xpt generation needs the xpidl lex/yacc files
178 xpcom/xpidl/export: xpcom/idl-parser/xpidl/export
180 # CSS2Properties.webidl needs ServoCSSPropList.py from layout/style
181 dom/bindings/export: layout/style/export
183 # Various telemetry histogram files need ServoCSSPropList.py from layout/style
184 toolkit/components/telemetry/export: layout/style/export
186 ifdef ENABLE_CLANG_PLUGIN
187 # Only target rules use the clang plugin.
188 $(filter %/target %/target-objects,$(filter-out config/export config/host build/unix/stdc++compat/% build/clang-plugin/%,$(compile_targets))): build/clang-plugin/host build/clang-plugin/tests/target-objects
189 build/clang-plugin/tests/target-objects: build/clang-plugin/host
190 # clang-plugin tests require js-confdefs.h on js standalone builds and mozilla-config.h on
191 # other builds, because they are -include'd.
192 ifdef JS_STANDALONE
193 # The js/src/export target only exists when CURRENT_TIER is export. If we're in a later tier,
194 # we can assume js/src/export has happened anyways.
195 ifeq ($(CURRENT_TIER),export)
196 build/clang-plugin/tests/target-objects: js/src/export
197 endif
198 else
199 build/clang-plugin/tests/target-objects: mozilla-config.h
200 endif
201 endif
203 # Interdependencies that moz.build world don't know about yet for compilation.
204 # Note some others are hardcoded or "guessed" in recursivemake.py and emitter.py
205 ifeq ($(MOZ_WIDGET_TOOLKIT),gtk)
206 toolkit/library/target: widget/gtk/mozgtk/gtk3/target
207 endif
209 # Most things are built during compile (target/host), but some things happen during export
210 # Those need to depend on config/export for system wrappers.
211 $(addprefix build/unix/stdc++compat/,target host) build/clang-plugin/host: config/export
213 # Rust targets, and export targets that run cbindgen need
214 # $topobjdir/.cargo/config to be preprocessed first. Ideally, we'd only set it
215 # as a dependency of the rust targets, but unfortunately, that pushes Make to
216 # execute them much later than we'd like them to be when the file doesn't exist
217 # prior to Make running. So we also set it as a dependency of pre-export, which
218 # ensures it exists before recursing the rust targets and the export targets
219 # that run cbindgen, tricking Make into keeping them early.
220 $(rust_targets) gfx/webrender_bindings/export layout/style/export xpcom/base/export: $(DEPTH)/.cargo/config
221 ifndef TEST_MOZBUILD
222 pre-export:: $(DEPTH)/.cargo/config
223 endif
225 # When building gtest as part of the build (LINK_GTEST_DURING_COMPILE),
226 # force the build system to get to it first, so that it can be linked
227 # quickly without LTO, allowing the build system to go ahead with
228 # plain gkrust and libxul while libxul-gtest is being linked and
229 # dump-sym'ed.
230 ifneq (,$(filter toolkit/library/gtest/rust/target,$(compile_targets)))
231 toolkit/library/rust/target: toolkit/library/gtest/rust/target
232 endif
233 endif