Tue, 06 Jan 2015 21:39:09 +0100
Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.
michael@0 | 1 | # This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this file, |
michael@0 | 3 | # You can obtain one at http://mozilla.org/MPL/2.0/. |
michael@0 | 4 | |
michael@0 | 5 | ifndef INCLUDED_RULES_MK |
michael@0 | 6 | include $(topsrcdir)/config/rules.mk |
michael@0 | 7 | endif |
michael@0 | 8 | |
michael@0 | 9 | # The traditional model of directory traversal with make is as follows: |
michael@0 | 10 | # make -C foo |
michael@0 | 11 | # Entering foo |
michael@0 | 12 | # make -C bar |
michael@0 | 13 | # Entering foo/bar |
michael@0 | 14 | # make -C baz |
michael@0 | 15 | # Entering foo/baz |
michael@0 | 16 | # make -C qux |
michael@0 | 17 | # Entering qux |
michael@0 | 18 | # |
michael@0 | 19 | # Pseudo derecurse transforms the above into: |
michael@0 | 20 | # make -C foo |
michael@0 | 21 | # make -C foo/bar |
michael@0 | 22 | # make -C foo/baz |
michael@0 | 23 | # make -C qux |
michael@0 | 24 | |
michael@0 | 25 | # MOZ_PSEUDO_DERECURSE can have values other than 1. |
michael@0 | 26 | ifeq (1_.,$(if $(MOZ_PSEUDO_DERECURSE),1)_$(DEPTH)) |
michael@0 | 27 | |
michael@0 | 28 | include root.mk |
michael@0 | 29 | |
michael@0 | 30 | # Disable build status for mach in top directories without TIERS. |
michael@0 | 31 | # In practice this disables it when recursing under js/src, which confuses mach. |
michael@0 | 32 | ifndef TIERS |
michael@0 | 33 | BUILDSTATUS = |
michael@0 | 34 | endif |
michael@0 | 35 | |
michael@0 | 36 | # Main rules (export, compile, binaries, libs and tools) call recurse_* rules. |
michael@0 | 37 | # This wrapping is only really useful for build status. |
michael@0 | 38 | compile binaries libs export tools:: |
michael@0 | 39 | $(call BUILDSTATUS,TIER_START $@) |
michael@0 | 40 | +$(MAKE) recurse_$@ |
michael@0 | 41 | $(call BUILDSTATUS,TIER_FINISH $@) |
michael@0 | 42 | |
michael@0 | 43 | # Carefully avoid $(eval) type of rule generation, which makes pymake slower |
michael@0 | 44 | # than necessary. |
michael@0 | 45 | # Get current tier and corresponding subtiers from the data in root.mk. |
michael@0 | 46 | CURRENT_TIER := $(filter $(foreach tier,compile binaries libs export tools,recurse_$(tier) $(tier)-deps),$(MAKECMDGOALS)) |
michael@0 | 47 | ifneq (,$(filter-out 0 1,$(words $(CURRENT_TIER)))) |
michael@0 | 48 | $(error $(CURRENT_TIER) not supported on the same make command line) |
michael@0 | 49 | endif |
michael@0 | 50 | CURRENT_TIER := $(subst recurse_,,$(CURRENT_TIER:-deps=)) |
michael@0 | 51 | CURRENT_SUBTIERS := $($(CURRENT_TIER)_subtiers) |
michael@0 | 52 | |
michael@0 | 53 | # The rules here are doing directory traversal, so we don't want further |
michael@0 | 54 | # recursion to happen when running make -C subdir $tier. But some make files |
michael@0 | 55 | # further call make -C something else, and sometimes expect recursion to |
michael@0 | 56 | # happen in that case (see browser/metro/locales/Makefile.in for example). |
michael@0 | 57 | # Conveniently, every invocation of make increases MAKELEVEL, so only stop |
michael@0 | 58 | # recursion from happening at current MAKELEVEL + 1. |
michael@0 | 59 | ifdef CURRENT_TIER |
michael@0 | 60 | ifeq (0,$(MAKELEVEL)) |
michael@0 | 61 | export NO_RECURSE_MAKELEVEL=1 |
michael@0 | 62 | else |
michael@0 | 63 | 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) |
michael@0 | 64 | endif |
michael@0 | 65 | endif |
michael@0 | 66 | |
michael@0 | 67 | # Get all directories traversed for all subtiers in the current tier, or use |
michael@0 | 68 | # directly the $(*_dirs) variables available in root.mk when there is no |
michael@0 | 69 | # TIERS (like for js/src). |
michael@0 | 70 | TIER_DIRS = $(or $($(1)_dirs),$(foreach subtier,$($(1)_subtiers),$($(1)_subtier_$(subtier)))) |
michael@0 | 71 | CURRENT_DIRS := $(call TIER_DIRS,$(CURRENT_TIER)) |
michael@0 | 72 | |
michael@0 | 73 | ifneq (,$(filter binaries libs,$(CURRENT_TIER))) |
michael@0 | 74 | WANT_STAMPS = 1 |
michael@0 | 75 | STAMP_TOUCH = $(TOUCH) $(@D)/binaries |
michael@0 | 76 | endif |
michael@0 | 77 | |
michael@0 | 78 | # Subtier delimiter rules |
michael@0 | 79 | $(addprefix subtiers/,$(addsuffix _start/$(CURRENT_TIER),$(CURRENT_SUBTIERS))): subtiers/%_start/$(CURRENT_TIER): $(if $(WANT_STAMPS),$(call mkdir_deps,subtiers/%_start)) |
michael@0 | 80 | @$(STAMP_TOUCH) |
michael@0 | 81 | |
michael@0 | 82 | $(addprefix subtiers/,$(addsuffix _finish/$(CURRENT_TIER),$(CURRENT_SUBTIERS))): subtiers/%_finish/$(CURRENT_TIER): $(if $(WANT_STAMPS),$(call mkdir_deps,subtiers/%_finish)) |
michael@0 | 83 | @$(STAMP_TOUCH) |
michael@0 | 84 | |
michael@0 | 85 | $(addprefix subtiers/,$(addsuffix /$(CURRENT_TIER),$(CURRENT_SUBTIERS))): %/$(CURRENT_TIER): $(if $(WANT_STAMPS),$(call mkdir_deps,%)) |
michael@0 | 86 | @$(STAMP_TOUCH) |
michael@0 | 87 | |
michael@0 | 88 | GARBAGE_DIRS += subtiers |
michael@0 | 89 | |
michael@0 | 90 | # Recursion rule for all directories traversed for all subtiers in the |
michael@0 | 91 | # current tier. |
michael@0 | 92 | # root.mk defines subtier_of_* variables, that map a normalized subdir path to |
michael@0 | 93 | # a subtier name (e.g. subtier_of_memory_jemalloc = base) |
michael@0 | 94 | $(addsuffix /$(CURRENT_TIER),$(CURRENT_DIRS)): %/$(CURRENT_TIER): |
michael@0 | 95 | +@$(MAKE) -C $* $(if $(filter $*,$(tier_$(subtier_of_$(subst /,_,$*))_staticdirs)),,$(CURRENT_TIER)) |
michael@0 | 96 | # Ensure existing stamps are up-to-date, but don't create one if submake didn't create one. |
michael@0 | 97 | $(if $(wildcard $@),@$(STAMP_TOUCH)) |
michael@0 | 98 | |
michael@0 | 99 | # Dummy rules for possibly inexisting dependencies for the above tier targets |
michael@0 | 100 | $(addsuffix /Makefile,$(CURRENT_DIRS)) $(addsuffix /backend.mk,$(CURRENT_DIRS)): |
michael@0 | 101 | |
michael@0 | 102 | # The export tier requires nsinstall, which is built from config. So every |
michael@0 | 103 | # subdirectory traversal needs to happen after traversing config. |
michael@0 | 104 | ifeq ($(CURRENT_TIER),export) |
michael@0 | 105 | $(addsuffix /$(CURRENT_TIER),$(filter-out config,$(CURRENT_DIRS))): config/$(CURRENT_TIER) |
michael@0 | 106 | endif |
michael@0 | 107 | |
michael@0 | 108 | ifdef COMPILE_ENVIRONMENT |
michael@0 | 109 | ifneq (,$(filter libs binaries,$(CURRENT_TIER))) |
michael@0 | 110 | # When doing a "libs" build, target_libs.mk ensures the interesting dependency data |
michael@0 | 111 | # is available in the "binaries" stamp. Once recursion is done, aggregate all that |
michael@0 | 112 | # dependency info so that stamps depend on relevant files and relevant other stamps. |
michael@0 | 113 | # When doing a "binaries" build, the aggregate dependency file and those stamps are |
michael@0 | 114 | # used and allow to skip recursing directories where changes are not going to require |
michael@0 | 115 | # rebuild. A few directories, however, are still traversed all the time, mostly, the |
michael@0 | 116 | # gyp managed ones and js/src. |
michael@0 | 117 | # A few things that are not traversed by a "binaries" build, but should, in an ideal |
michael@0 | 118 | # world, are nspr, nss, icu and ffi. |
michael@0 | 119 | recurse_$(CURRENT_TIER): |
michael@0 | 120 | @$(MAKE) binaries-deps |
michael@0 | 121 | |
michael@0 | 122 | # Creating binaries-deps.mk directly would make us build it twice: once when beginning |
michael@0 | 123 | # the build because of the include, and once at the end because of the stamps. |
michael@0 | 124 | binaries-deps: $(addsuffix /binaries,$(CURRENT_DIRS)) |
michael@0 | 125 | @$(call py_action,link_deps,-o $@.mk --group-by-depfile --topsrcdir $(topsrcdir) --topobjdir $(DEPTH) --dist $(DIST) --guard $(addprefix ',$(addsuffix ',$^))) |
michael@0 | 126 | @$(TOUCH) $@ |
michael@0 | 127 | |
michael@0 | 128 | ifeq (recurse_binaries,$(MAKECMDGOALS)) |
michael@0 | 129 | $(call include_deps,binaries-deps.mk) |
michael@0 | 130 | endif |
michael@0 | 131 | |
michael@0 | 132 | endif |
michael@0 | 133 | |
michael@0 | 134 | DIST_GARBAGE += binaries-deps.mk binaries-deps |
michael@0 | 135 | |
michael@0 | 136 | endif |
michael@0 | 137 | |
michael@0 | 138 | else |
michael@0 | 139 | |
michael@0 | 140 | # Don't recurse if MAKELEVEL is NO_RECURSE_MAKELEVEL as defined above |
michael@0 | 141 | ifeq ($(NO_RECURSE_MAKELEVEL),$(MAKELEVEL)) |
michael@0 | 142 | |
michael@0 | 143 | compile binaries libs export tools:: |
michael@0 | 144 | |
michael@0 | 145 | else |
michael@0 | 146 | ######################### |
michael@0 | 147 | # Tier traversal handling |
michael@0 | 148 | ######################### |
michael@0 | 149 | |
michael@0 | 150 | ifdef TIERS |
michael@0 | 151 | |
michael@0 | 152 | libs export tools:: |
michael@0 | 153 | $(call BUILDSTATUS,TIER_START $@) |
michael@0 | 154 | $(foreach tier,$(TIERS), $(if $(filter-out libs_precompile tools_precompile,$@_$(tier)), \ |
michael@0 | 155 | $(if $(filter libs,$@),$(foreach dir, $(tier_$(tier)_staticdirs), $(call TIER_DIR_SUBMAKE,$@,$(tier),$(dir),,1))) \ |
michael@0 | 156 | $(foreach dir, $(tier_$(tier)_dirs), $(call TIER_DIR_SUBMAKE,$@,$(tier),$(dir),$@)))) |
michael@0 | 157 | $(call BUILDSTATUS,TIER_FINISH $@) |
michael@0 | 158 | |
michael@0 | 159 | else |
michael@0 | 160 | |
michael@0 | 161 | define CREATE_SUBTIER_TRAVERSAL_RULE |
michael@0 | 162 | PARALLEL_DIRS_$(1) = $$(addsuffix _$(1),$$(PARALLEL_DIRS)) |
michael@0 | 163 | |
michael@0 | 164 | .PHONY: $(1) $$(PARALLEL_DIRS_$(1)) |
michael@0 | 165 | |
michael@0 | 166 | ifdef PARALLEL_DIRS |
michael@0 | 167 | $$(PARALLEL_DIRS_$(1)): %_$(1): %/Makefile |
michael@0 | 168 | +@$$(call SUBMAKE,$(1),$$*) |
michael@0 | 169 | endif |
michael@0 | 170 | |
michael@0 | 171 | $(1):: $$(SUBMAKEFILES) |
michael@0 | 172 | ifdef PARALLEL_DIRS |
michael@0 | 173 | +@$(MAKE) $$(PARALLEL_DIRS_$(1)) |
michael@0 | 174 | endif |
michael@0 | 175 | $$(LOOP_OVER_DIRS) |
michael@0 | 176 | |
michael@0 | 177 | endef |
michael@0 | 178 | |
michael@0 | 179 | $(foreach subtier,export compile binaries libs tools,$(eval $(call CREATE_SUBTIER_TRAVERSAL_RULE,$(subtier)))) |
michael@0 | 180 | |
michael@0 | 181 | tools export:: $(SUBMAKEFILES) |
michael@0 | 182 | $(LOOP_OVER_TOOL_DIRS) |
michael@0 | 183 | |
michael@0 | 184 | endif # ifdef TIERS |
michael@0 | 185 | |
michael@0 | 186 | endif # ifeq ($(NO_RECURSE_MAKELEVEL),$(MAKELEVEL)) |
michael@0 | 187 | |
michael@0 | 188 | endif # ifeq (1_.,$(MOZ_PSEUDO_DERECURSE)_$(DEPTH)) |
michael@0 | 189 | |
michael@0 | 190 | ifdef MOZ_PSEUDO_DERECURSE |
michael@0 | 191 | |
michael@0 | 192 | ifdef COMPILE_ENVIRONMENT |
michael@0 | 193 | |
michael@0 | 194 | # Aggregate all dependency files relevant to a binaries build except in |
michael@0 | 195 | # the mozilla top-level directory. |
michael@0 | 196 | ifneq (.,$(DEPTH)) |
michael@0 | 197 | ALL_DEP_FILES := \ |
michael@0 | 198 | $(BINARIES_PP) \ |
michael@0 | 199 | $(addsuffix .pp,$(addprefix $(MDDEPDIR)/,$(sort \ |
michael@0 | 200 | $(TARGETS) \ |
michael@0 | 201 | $(filter-out $(SOBJS) $(ASOBJS) $(EXCLUDED_OBJS),$(OBJ_TARGETS)) \ |
michael@0 | 202 | ))) \ |
michael@0 | 203 | $(NULL) |
michael@0 | 204 | endif |
michael@0 | 205 | |
michael@0 | 206 | binaries libs:: $(TARGETS) $(BINARIES_PP) |
michael@0 | 207 | ifneq (.,$(DEPTH)) |
michael@0 | 208 | @$(if $^,$(call py_action,link_deps,-o binaries --group-all --topsrcdir $(topsrcdir) --topobjdir $(DEPTH) --dist $(DIST) $(ALL_DEP_FILES))) |
michael@0 | 209 | endif |
michael@0 | 210 | |
michael@0 | 211 | endif |
michael@0 | 212 | |
michael@0 | 213 | endif # ifdef MOZ_PSEUDO_DERECURSE |
michael@0 | 214 | |
michael@0 | 215 | recurse: |
michael@0 | 216 | @$(RECURSED_COMMAND) |
michael@0 | 217 | $(LOOP_OVER_PARALLEL_DIRS) |
michael@0 | 218 | $(LOOP_OVER_DIRS) |
michael@0 | 219 | $(LOOP_OVER_TOOL_DIRS) |