Bug 1669129 - [devtools] Enable devtools.overflow.debugging.enabled. r=jdescottes
[gecko.git] / config / recurse.mk
bloba1567ae3cd196e993049d32fd7a5ca7e01c0d62b
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 # Get current tier and corresponding subtiers from the data in root.mk.
42 CURRENT_TIER := $(filter $(foreach tier,$(RUNNABLE_TIERS) $(non_default_tiers),recurse_$(tier) $(tier)-deps),$(MAKECMDGOALS))
43 ifneq (,$(filter-out 0 1,$(words $(CURRENT_TIER))))
44 $(error $(CURRENT_TIER) not supported on the same make command line)
45 endif
46 CURRENT_TIER := $(subst recurse_,,$(CURRENT_TIER:-deps=))
48 # The rules here are doing directory traversal, so we don't want further
49 # recursion to happen when running make -C subdir $tier. But some make files
50 # further call make -C something else, and sometimes expect recursion to
51 # happen in that case.
52 # Conveniently, every invocation of make increases MAKELEVEL, so only stop
53 # recursion from happening at current MAKELEVEL + 1.
54 ifdef CURRENT_TIER
55 ifeq (0,$(MAKELEVEL))
56 export NO_RECURSE_MAKELEVEL=1
57 else
58 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)
59 endif
60 endif
62 RECURSE = $(if $(RECURSE_TRACE_ONLY),@echo $2/$1,$(call SUBMAKE,$1,$2))
64 # Use the $(*_dirs) variables available in root.mk
65 CURRENT_DIRS := $($(CURRENT_TIER)_dirs)
67 # Need a list of compile targets because we can't use pattern rules:
68 # https://savannah.gnu.org/bugs/index.php?42833
69 # Only recurse the paths starting with RECURSE_BASE_DIR when provided.
70 .PHONY: $(pre_compile_targets) $(compile_targets) $(syms_targets)
71 $(pre_compile_targets) $(compile_targets) $(syms_targets):
72 $(if $(filter $(RECURSE_BASE_DIR)%,$@),$(call RECURSE,$(@F),$(@D)))
74 $(syms_targets): %/syms: %/target
76 # Only hook symbols targets into the main compile graph in automation.
77 ifdef MOZ_AUTOMATION
78 ifeq (1,$(MOZ_AUTOMATION_BUILD_SYMBOLS))
79 recurse_compile: $(syms_targets)
80 endif
81 endif
83 # Create a separate rule that depends on every 'syms' target so that
84 # symbols can be dumped on demand locally.
85 .PHONY: recurse_syms
86 recurse_syms: $(syms_targets)
88 # Ensure dump_syms gets built before any syms targets, all of which depend on it.
89 ifneq (,$(filter toolkit/crashreporter/google-breakpad/src/tools/%/dump_syms/host,$(compile_targets)))
90 $(syms_targets): $(filter toolkit/crashreporter/google-breakpad/src/tools/%/dump_syms/host,$(compile_targets))
91 endif
93 # The compile tier has different rules from other tiers.
94 ifneq ($(CURRENT_TIER),compile)
96 # Recursion rule for all directories traversed for all subtiers in the
97 # current tier.
98 $(addsuffix /$(CURRENT_TIER),$(CURRENT_DIRS)): %/$(CURRENT_TIER):
99 $(call RECURSE,$(CURRENT_TIER),$*)
101 .PHONY: $(addsuffix /$(CURRENT_TIER),$(CURRENT_DIRS))
103 # Dummy rules for possibly inexisting dependencies for the above tier targets
104 $(addsuffix /Makefile,$(CURRENT_DIRS)) $(addsuffix /backend.mk,$(CURRENT_DIRS)):
106 ifeq ($(CURRENT_TIER),export)
107 # At least build/export requires config/export for buildid, but who knows what
108 # else, so keep this global dependency to make config/export first for now.
109 $(addsuffix /$(CURRENT_TIER),$(filter-out config,$(CURRENT_DIRS))): config/$(CURRENT_TIER)
111 # The export tier requires nsinstall, which is built from config. So every
112 # subdirectory traversal needs to happen after building nsinstall in config, which
113 # is done with the config/host target. Note the config/host target only exists if
114 # nsinstall is actually built, which it is not on Windows, because we use
115 # nsinstall.py there.
116 ifdef COMPILE_ENVIRONMENT
117 ifneq (,$(filter config/host, $(compile_targets)))
118 $(addsuffix /$(CURRENT_TIER),$(CURRENT_DIRS)): config/host
119 endif
120 endif
121 endif
123 endif # ifeq ($(CURRENT_TIER),compile)
125 else
127 # Don't recurse if MAKELEVEL is NO_RECURSE_MAKELEVEL as defined above
128 ifeq ($(NO_RECURSE_MAKELEVEL),$(MAKELEVEL))
130 $(RUNNABLE_TIERS)::
132 else
133 #########################
134 # Tier traversal handling
135 #########################
137 define CREATE_SUBTIER_TRAVERSAL_RULE
138 .PHONY: $(1)
140 $(1):: $$(SUBMAKEFILES)
141 $$(LOOP_OVER_DIRS)
143 endef
145 $(foreach subtier,$(filter-out compile,$(RUNNABLE_TIERS)),$(eval $(call CREATE_SUBTIER_TRAVERSAL_RULE,$(subtier))))
147 ifndef TOPLEVEL_BUILD
148 ifdef COMPILE_ENVIRONMENT
149 compile::
150 @$(MAKE) -C $(DEPTH) compile RECURSE_BASE_DIR=$(relativesrcdir)/
151 endif # COMPILE_ENVIRONMENT
152 endif
154 endif # ifeq ($(NO_RECURSE_MAKELEVEL),$(MAKELEVEL))
156 endif # ifeq (.,$(DEPTH))
158 recurse:
159 @$(RECURSED_COMMAND)
160 $(LOOP_OVER_DIRS)
162 ifeq (.,$(DEPTH))
163 # The Android SDK bindings needs to build the Java generator code
164 # source code in order to write the SDK bindings.
165 widget/android/bindings/export: mobile/android/base/export
167 # The widget JNI wrapper generator code needs to build the GeckoView
168 # source code in order to find JNI wrapper annotations.
169 widget/android/export: mobile/android/base/export
171 # android_apks is not built on artifact builds without this dependency.
172 mobile/android/base/export: mobile/android/base/android_apks
174 # CSS2Properties.webidl needs ServoCSSPropList.py from layout/style
175 dom/bindings/export: layout/style/ServoCSSPropList.py
177 # Various telemetry histogram files need ServoCSSPropList.py from layout/style
178 toolkit/components/telemetry/export: layout/style/ServoCSSPropList.py
180 # The update agent needs to link to the updatecommon library, but the build system does not
181 # currently have a good way of expressing this dependency.
182 toolkit/components/updateagent/target: toolkit/mozapps/update/common/target
184 ifeq ($(TARGET_ENDIANNESS),big)
185 config/external/icu/data/target-objects: config/external/icu/data/$(MDDEPDIR)/icudt$(MOZ_ICU_VERSION)b.dat.stub
186 config/external/icu/data/$(MDDEPDIR)/icudt$(MOZ_ICU_VERSION)b.dat.stub: config/external/icu/icupkg/host
187 endif
189 ifdef ENABLE_CLANG_PLUGIN
190 # Only target rules use the clang plugin.
191 $(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
192 build/clang-plugin/tests/target-objects: build/clang-plugin/host
193 # clang-plugin tests require js-confdefs.h on js standalone builds and mozilla-config.h on
194 # other builds, because they are -include'd.
195 ifdef JS_STANDALONE
196 # The js/src/export target only exists when CURRENT_TIER is export. If we're in a later tier,
197 # we can assume js/src/export has happened anyways.
198 ifeq ($(CURRENT_TIER),export)
199 build/clang-plugin/tests/target-objects: js/src/export
200 endif
201 else
202 build/clang-plugin/tests/target-objects: mozilla-config.h
203 endif
204 endif
206 # Interdependencies that moz.build world don't know about yet for compilation.
207 # Note some others are hardcoded or "guessed" in recursivemake.py and emitter.py
208 ifeq ($(MOZ_WIDGET_TOOLKIT),gtk)
209 toolkit/library/target: widget/gtk/mozgtk/gtk3/target
210 endif
212 ifndef MOZ_FOLD_LIBS
213 ifndef MOZ_SYSTEM_NSS
214 netwerk/test/http3server/target: security/nss/lib/nss/nss_nss3/target security/nss/lib/ssl/ssl_ssl3/target
215 endif
216 ifndef MOZ_SYSTEM_NSPR
217 netwerk/test/http3server/target: config/external/nspr/pr/target
218 endif
219 else
220 ifndef MOZ_SYSTEM_NSS
221 netwerk/test/http3server/target: security/target
222 endif
223 endif
225 # Most things are built during compile (target/host), but some things happen during export
226 # Those need to depend on config/export for system wrappers.
227 $(addprefix build/unix/stdc++compat/,target host) build/clang-plugin/host: config/export
229 # Rust targets, and export targets that run cbindgen need
230 # $topobjdir/.cargo/config to be preprocessed first. Ideally, we'd only set it
231 # as a dependency of the rust targets, but unfortunately, that pushes Make to
232 # execute them much later than we'd like them to be when the file doesn't exist
233 # prior to Make running. So we also set it as a dependency of pre-export, which
234 # ensures it exists before recursing the rust targets and the export targets
235 # that run cbindgen, tricking Make into keeping them early.
236 $(rust_targets): $(DEPTH)/.cargo/config
237 ifndef TEST_MOZBUILD
238 pre-export:: $(DEPTH)/.cargo/config
239 endif
241 # When building gtest as part of the build (LINK_GTEST_DURING_COMPILE),
242 # force the build system to get to it first, so that it can be linked
243 # quickly without LTO, allowing the build system to go ahead with
244 # plain gkrust and libxul while libxul-gtest is being linked and
245 # dump-sym'ed.
246 ifneq (,$(filter toolkit/library/gtest/rust/target,$(compile_targets)))
247 toolkit/library/rust/target: toolkit/library/gtest/rust/target
248 endif
249 endif