• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1ifndef KATI
2$(warning Calling make directly is no longer supported.)
3$(warning Either use 'envsetup.sh; m' or 'build/soong/soong_ui.bash --make-mode')
4$(error done)
5endif
6
7$(info [1/1] initializing build system ...)
8
9# Absolute path of the present working direcotry.
10# This overrides the shell variable $PWD, which does not necessarily points to
11# the top of the source tree, for example when "make -C" is used in m/mm/mmm.
12PWD := $(shell pwd)
13
14# This is the default target.  It must be the first declared target.
15.PHONY: droid
16DEFAULT_GOAL := droid
17$(DEFAULT_GOAL): droid_targets
18
19.PHONY: droid_targets
20droid_targets:
21
22# Set up various standard variables based on configuration
23# and host information.
24include build/make/core/config.mk
25
26ifneq ($(filter $(dont_bother_goals), $(MAKECMDGOALS)),)
27dont_bother := true
28endif
29
30.KATI_READONLY := SOONG_CONFIG_NAMESPACES
31.KATI_READONLY := $(foreach n,$(SOONG_CONFIG_NAMESPACES),SOONG_CONFIG_$(n))
32.KATI_READONLY := $(foreach n,$(SOONG_CONFIG_NAMESPACES),$(foreach k,$(SOONG_CONFIG_$(n)),SOONG_CONFIG_$(n)_$(k)))
33
34include $(SOONG_MAKEVARS_MK)
35
36YACC :=$= $(BISON) -d
37
38include $(BUILD_SYSTEM)/clang/config.mk
39
40# Write the build number to a file so it can be read back in
41# without changing the command line every time.  Avoids rebuilds
42# when using ninja.
43$(shell mkdir -p $(SOONG_OUT_DIR) && \
44    echo -n $(BUILD_NUMBER) > $(SOONG_OUT_DIR)/build_number.tmp; \
45    if ! cmp -s $(SOONG_OUT_DIR)/build_number.tmp $(SOONG_OUT_DIR)/build_number.txt; then \
46        mv $(SOONG_OUT_DIR)/build_number.tmp $(SOONG_OUT_DIR)/build_number.txt; \
47    else \
48        rm $(SOONG_OUT_DIR)/build_number.tmp; \
49    fi)
50BUILD_NUMBER_FILE := $(SOONG_OUT_DIR)/build_number.txt
51.KATI_READONLY := BUILD_NUMBER_FILE
52$(KATI_obsolete_var BUILD_NUMBER,See https://android.googlesource.com/platform/build/+/master/Changes.md#BUILD_NUMBER)
53$(BUILD_NUMBER_FILE):
54	touch $@
55
56DATE_FROM_FILE := date -d @$(BUILD_DATETIME_FROM_FILE)
57.KATI_READONLY := DATE_FROM_FILE
58
59# Pick a reasonable string to use to identify files.
60ifeq ($(strip $(HAS_BUILD_NUMBER)),false)
61  # BUILD_NUMBER has a timestamp in it, which means that
62  # it will change every time.  Pick a stable value.
63  FILE_NAME_TAG := eng.$(BUILD_USERNAME)
64else
65  FILE_NAME_TAG := $(file <$(BUILD_NUMBER_FILE))
66endif
67.KATI_READONLY := FILE_NAME_TAG
68
69# Make an empty directory, which can be used to make empty jars
70EMPTY_DIRECTORY := $(OUT_DIR)/empty
71$(shell mkdir -p $(EMPTY_DIRECTORY) && rm -rf $(EMPTY_DIRECTORY)/*)
72
73# CTS-specific config.
74-include cts/build/config.mk
75# VTS-specific config.
76-include test/vts/tools/vts-tradefed/build/config.mk
77# device-tests-specific-config.
78-include tools/tradefederation/build/suites/device-tests/config.mk
79# general-tests-specific-config.
80-include tools/tradefederation/build/suites/general-tests/config.mk
81# STS-specific config.
82-include test/sts/tools/sts-tradefed/build/config.mk
83# CTS-Instant-specific config
84-include test/suite_harness/tools/cts-instant-tradefed/build/config.mk
85# MTS-specific config.
86-include test/mts/tools/build/config.mk
87# VTS-Core-specific config.
88-include test/vts/tools/vts-core-tradefed/build/config.mk
89# CSUITE-specific config.
90-include test/app_compat/csuite/tools/build/config.mk
91# CATBox-specific config.
92-include test/catbox/tools/build/config.mk
93# CTS-Root-specific config.
94-include test/cts-root/tools/build/config.mk
95
96# Clean rules
97.PHONY: clean-dex-files
98clean-dex-files:
99	$(hide) find $(OUT_DIR) -name "*.dex" | xargs rm -f
100	$(hide) for i in `find $(OUT_DIR) -name "*.jar" -o -name "*.apk"` ; do ((unzip -l $$i 2> /dev/null | \
101				grep -q "\.dex$$" && rm -f $$i) || continue ) ; done
102	@echo "All dex files and archives containing dex files have been removed."
103
104# Include the google-specific config
105-include vendor/google/build/config.mk
106
107# These are the modifier targets that don't do anything themselves, but
108# change the behavior of the build.
109# (must be defined before including definitions.make)
110INTERNAL_MODIFIER_TARGETS := all
111
112# EMMA_INSTRUMENT_STATIC merges the static jacoco library to each
113# jacoco-enabled module.
114ifeq (true,$(EMMA_INSTRUMENT_STATIC))
115EMMA_INSTRUMENT := true
116endif
117
118ifdef TARGET_ARCH_SUITE
119  # TODO(b/175577370): Enable this error.
120  # $(error TARGET_ARCH_SUITE is not supported in kati/make builds)
121endif
122
123# ADDITIONAL_<partition>_PROPERTIES are properties that are determined by the
124# build system itself. Don't let it be defined from outside of the core build
125# system like Android.mk or <product>.mk files.
126_additional_prop_var_names := \
127    ADDITIONAL_SYSTEM_PROPERTIES \
128    ADDITIONAL_VENDOR_PROPERTIES \
129    ADDITIONAL_ODM_PROPERTIES \
130    ADDITIONAL_PRODUCT_PROPERTIES
131
132$(foreach name, $(_additional_prop_var_names),\
133  $(if $($(name)),\
134    $(error $(name) must not set before here. $($(name)))\
135  ,)\
136  $(eval $(name) :=)\
137)
138_additional_prop_var_names :=
139
140$(KATI_obsolete_var ADDITIONAL_BUILD_PROPERTIES, Please use ADDITIONAL_SYSTEM_PROPERTIES)
141
142#
143# -----------------------------------------------------------------
144# Add the product-defined properties to the build properties.
145ifneq ($(BOARD_PROPERTY_OVERRIDES_SPLIT_ENABLED), true)
146  ADDITIONAL_SYSTEM_PROPERTIES += $(PRODUCT_PROPERTY_OVERRIDES)
147else
148  ifndef BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE
149    ADDITIONAL_SYSTEM_PROPERTIES += $(PRODUCT_PROPERTY_OVERRIDES)
150  endif
151endif
152
153
154# Bring in standard build system definitions.
155include $(BUILD_SYSTEM)/definitions.mk
156
157ifneq ($(filter user userdebug eng,$(MAKECMDGOALS)),)
158$(info ***************************************************************)
159$(info ***************************************************************)
160$(info Do not pass '$(filter user userdebug eng,$(MAKECMDGOALS))' on \
161       the make command line.)
162$(info Set TARGET_BUILD_VARIANT in buildspec.mk, or use lunch or)
163$(info choosecombo.)
164$(info ***************************************************************)
165$(info ***************************************************************)
166$(error stopping)
167endif
168
169# These are the valid values of TARGET_BUILD_VARIANT.
170INTERNAL_VALID_VARIANTS := user userdebug eng
171ifneq ($(filter-out $(INTERNAL_VALID_VARIANTS),$(TARGET_BUILD_VARIANT)),)
172$(info ***************************************************************)
173$(info ***************************************************************)
174$(info Invalid variant: $(TARGET_BUILD_VARIANT))
175$(info Valid values are: $(INTERNAL_VALID_VARIANTS))
176$(info ***************************************************************)
177$(info ***************************************************************)
178$(error stopping)
179endif
180
181# -----------------------------------------------------------------
182# PDK builds are no longer supported, this is always platform
183TARGET_BUILD_JAVA_SUPPORT_LEVEL :=$= platform
184
185# -----------------------------------------------------------------
186
187ADDITIONAL_SYSTEM_PROPERTIES += ro.treble.enabled=${PRODUCT_FULL_TREBLE}
188
189$(KATI_obsolete_var PRODUCT_FULL_TREBLE,\
190	Code should be written to work regardless of a device being Treble or \
191	variables like PRODUCT_SEPOLICY_SPLIT should be used until that is \
192	possible.)
193
194# Sets ro.actionable_compatible_property.enabled to know on runtime whether the
195# allowed list of actionable compatible properties is enabled or not.
196ADDITIONAL_SYSTEM_PROPERTIES += ro.actionable_compatible_property.enabled=true
197
198# Add the system server compiler filter if they are specified for the product.
199ifneq (,$(PRODUCT_SYSTEM_SERVER_COMPILER_FILTER))
200ADDITIONAL_PRODUCT_PROPERTIES += dalvik.vm.systemservercompilerfilter=$(PRODUCT_SYSTEM_SERVER_COMPILER_FILTER)
201endif
202
203# Enable core platform API violation warnings on userdebug and eng builds.
204ifneq ($(TARGET_BUILD_VARIANT),user)
205ADDITIONAL_SYSTEM_PROPERTIES += persist.debug.dalvik.vm.core_platform_api_policy=just-warn
206endif
207
208# Define ro.sanitize.<name> properties for all global sanitizers.
209ADDITIONAL_SYSTEM_PROPERTIES += $(foreach s,$(SANITIZE_TARGET),ro.sanitize.$(s)=true)
210
211# Sets the default value of ro.postinstall.fstab.prefix to /system.
212# Device board config should override the value to /product when needed by:
213#
214#     PRODUCT_PRODUCT_PROPERTIES += ro.postinstall.fstab.prefix=/product
215#
216# It then uses ${ro.postinstall.fstab.prefix}/etc/fstab.postinstall to
217# mount system_other partition.
218ADDITIONAL_SYSTEM_PROPERTIES += ro.postinstall.fstab.prefix=/system
219
220# -----------------------------------------------------------------
221# ADDITIONAL_VENDOR_PROPERTIES will be installed in vendor/build.prop if
222# property_overrides_split_enabled is true. Otherwise it will be installed in
223# /system/build.prop
224ifdef BOARD_VNDK_VERSION
225  ifeq ($(BOARD_VNDK_VERSION),current)
226    ADDITIONAL_VENDOR_PROPERTIES := ro.vndk.version=$(PLATFORM_VNDK_VERSION)
227  else
228    ADDITIONAL_VENDOR_PROPERTIES := ro.vndk.version=$(BOARD_VNDK_VERSION)
229  endif
230endif
231
232# Add cpu properties for bionic and ART.
233ADDITIONAL_VENDOR_PROPERTIES += ro.bionic.arch=$(TARGET_ARCH)
234ADDITIONAL_VENDOR_PROPERTIES += ro.bionic.cpu_variant=$(TARGET_CPU_VARIANT_RUNTIME)
235ADDITIONAL_VENDOR_PROPERTIES += ro.bionic.2nd_arch=$(TARGET_2ND_ARCH)
236ADDITIONAL_VENDOR_PROPERTIES += ro.bionic.2nd_cpu_variant=$(TARGET_2ND_CPU_VARIANT_RUNTIME)
237
238ADDITIONAL_VENDOR_PROPERTIES += persist.sys.dalvik.vm.lib.2=libart.so
239ADDITIONAL_VENDOR_PROPERTIES += dalvik.vm.isa.$(TARGET_ARCH).variant=$(DEX2OAT_TARGET_CPU_VARIANT_RUNTIME)
240ifneq ($(DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES),)
241  ADDITIONAL_VENDOR_PROPERTIES += dalvik.vm.isa.$(TARGET_ARCH).features=$(DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES)
242endif
243
244ifdef TARGET_2ND_ARCH
245  ADDITIONAL_VENDOR_PROPERTIES += dalvik.vm.isa.$(TARGET_2ND_ARCH).variant=$($(TARGET_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_CPU_VARIANT_RUNTIME)
246  ifneq ($($(TARGET_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES),)
247    ADDITIONAL_VENDOR_PROPERTIES += dalvik.vm.isa.$(TARGET_2ND_ARCH).features=$($(TARGET_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES)
248  endif
249endif
250
251# Although these variables are prefixed with TARGET_RECOVERY_, they are also needed under charger
252# mode (via libminui).
253ifdef TARGET_RECOVERY_DEFAULT_ROTATION
254ADDITIONAL_VENDOR_PROPERTIES += \
255    ro.minui.default_rotation=$(TARGET_RECOVERY_DEFAULT_ROTATION)
256endif
257ifdef TARGET_RECOVERY_OVERSCAN_PERCENT
258ADDITIONAL_VENDOR_PROPERTIES += \
259    ro.minui.overscan_percent=$(TARGET_RECOVERY_OVERSCAN_PERCENT)
260endif
261ifdef TARGET_RECOVERY_PIXEL_FORMAT
262ADDITIONAL_VENDOR_PROPERTIES += \
263    ro.minui.pixel_format=$(TARGET_RECOVERY_PIXEL_FORMAT)
264endif
265
266ifdef PRODUCT_USE_DYNAMIC_PARTITIONS
267ADDITIONAL_VENDOR_PROPERTIES += \
268    ro.boot.dynamic_partitions=$(PRODUCT_USE_DYNAMIC_PARTITIONS)
269endif
270
271ifdef PRODUCT_RETROFIT_DYNAMIC_PARTITIONS
272ADDITIONAL_VENDOR_PROPERTIES += \
273    ro.boot.dynamic_partitions_retrofit=$(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS)
274endif
275
276ifdef PRODUCT_SHIPPING_API_LEVEL
277ADDITIONAL_VENDOR_PROPERTIES += \
278    ro.product.first_api_level=$(PRODUCT_SHIPPING_API_LEVEL)
279endif
280
281ifneq ($(TARGET_BUILD_VARIANT),user)
282  ifdef PRODUCT_SET_DEBUGFS_RESTRICTIONS
283    ADDITIONAL_VENDOR_PROPERTIES += \
284      ro.product.debugfs_restrictions.enabled=$(PRODUCT_SET_DEBUGFS_RESTRICTIONS)
285  endif
286endif
287
288# Vendors with GRF must define BOARD_SHIPPING_API_LEVEL for the vendor API level.
289# This must not be defined for the non-GRF devices.
290ifdef BOARD_SHIPPING_API_LEVEL
291ADDITIONAL_VENDOR_PROPERTIES += \
292    ro.board.first_api_level=$(BOARD_SHIPPING_API_LEVEL)
293
294# To manually set the vendor API level of the vendor modules, BOARD_API_LEVEL can be used.
295# The values of the GRF properties will be verified by post_process_props.py
296ifdef BOARD_API_LEVEL
297ADDITIONAL_VENDOR_PROPERTIES += \
298    ro.board.api_level=$(BOARD_API_LEVEL)
299endif
300endif
301
302# Set build prop. This prop is read by ota_from_target_files when generating OTA,
303# to decide if VABC should be disabled.
304ifeq ($(BOARD_DONT_USE_VABC_OTA),true)
305ADDITIONAL_VENDOR_PROPERTIES += \
306    ro.vendor.build.dont_use_vabc=true
307endif
308
309# Set the flag in vendor. So VTS would know if the new fingerprint format is in use when
310# the system images are replaced by GSI.
311ifeq ($(BOARD_USE_VBMETA_DIGTEST_IN_FINGERPRINT),true)
312ADDITIONAL_VENDOR_PROPERTIES += \
313    ro.vendor.build.fingerprint_has_digest=1
314endif
315
316ADDITIONAL_VENDOR_PROPERTIES += \
317    ro.vendor.build.security_patch=$(VENDOR_SECURITY_PATCH) \
318    ro.product.board=$(TARGET_BOOTLOADER_BOARD_NAME) \
319    ro.board.platform=$(TARGET_BOARD_PLATFORM) \
320    ro.hwui.use_vulkan=$(TARGET_USES_VULKAN)
321
322ifdef TARGET_SCREEN_DENSITY
323ADDITIONAL_VENDOR_PROPERTIES += \
324    ro.sf.lcd_density=$(TARGET_SCREEN_DENSITY)
325endif
326
327ifdef AB_OTA_UPDATER
328ADDITIONAL_VENDOR_PROPERTIES += \
329    ro.build.ab_update=$(AB_OTA_UPDATER)
330endif
331
332# Set ro.product.vndk.version to know the VNDK version required by product
333# modules. It uses the version in PRODUCT_PRODUCT_VNDK_VERSION. If the value
334# is "current", use PLATFORM_VNDK_VERSION.
335ifdef PRODUCT_PRODUCT_VNDK_VERSION
336ifeq ($(PRODUCT_PRODUCT_VNDK_VERSION),current)
337ADDITIONAL_PRODUCT_PROPERTIES += ro.product.vndk.version=$(PLATFORM_VNDK_VERSION)
338else
339ADDITIONAL_PRODUCT_PROPERTIES += ro.product.vndk.version=$(PRODUCT_PRODUCT_VNDK_VERSION)
340endif
341endif
342
343ADDITIONAL_PRODUCT_PROPERTIES += ro.build.characteristics=$(TARGET_AAPT_CHARACTERISTICS)
344
345ifeq ($(AB_OTA_UPDATER),true)
346ADDITIONAL_PRODUCT_PROPERTIES += ro.product.ab_ota_partitions=$(subst $(space),$(comma),$(sort $(AB_OTA_PARTITIONS)))
347endif
348
349# -----------------------------------------------------------------
350###
351### In this section we set up the things that are different
352### between the build variants
353###
354
355is_sdk_build :=
356
357ifneq ($(filter sdk sdk_addon,$(MAKECMDGOALS)),)
358is_sdk_build := true
359endif
360
361## user/userdebug ##
362
363user_variant := $(filter user userdebug,$(TARGET_BUILD_VARIANT))
364enable_target_debugging := true
365tags_to_install :=
366ifneq (,$(user_variant))
367  # Target is secure in user builds.
368  ADDITIONAL_SYSTEM_PROPERTIES += ro.secure=1
369  ADDITIONAL_SYSTEM_PROPERTIES += security.perf_harden=1
370
371  ifeq ($(user_variant),user)
372    ADDITIONAL_SYSTEM_PROPERTIES += ro.adb.secure=1
373  endif
374
375  ifeq ($(user_variant),userdebug)
376    # Pick up some extra useful tools
377    tags_to_install += debug
378  else
379    # Disable debugging in plain user builds.
380    enable_target_debugging :=
381  endif
382
383  # Disallow mock locations by default for user builds
384  ADDITIONAL_SYSTEM_PROPERTIES += ro.allow.mock.location=0
385
386else # !user_variant
387  # Turn on checkjni for non-user builds.
388  ADDITIONAL_SYSTEM_PROPERTIES += ro.kernel.android.checkjni=1
389  # Set device insecure for non-user builds.
390  ADDITIONAL_SYSTEM_PROPERTIES += ro.secure=0
391  # Allow mock locations by default for non user builds
392  ADDITIONAL_SYSTEM_PROPERTIES += ro.allow.mock.location=1
393endif # !user_variant
394
395ifeq (true,$(strip $(enable_target_debugging)))
396  # Target is more debuggable and adbd is on by default
397  ADDITIONAL_SYSTEM_PROPERTIES += ro.debuggable=1
398  # Enable Dalvik lock contention logging.
399  ADDITIONAL_SYSTEM_PROPERTIES += dalvik.vm.lockprof.threshold=500
400else # !enable_target_debugging
401  # Target is less debuggable and adbd is off by default
402  ADDITIONAL_SYSTEM_PROPERTIES += ro.debuggable=0
403endif # !enable_target_debugging
404
405## eng ##
406
407ifeq ($(TARGET_BUILD_VARIANT),eng)
408tags_to_install := debug eng
409ifneq ($(filter ro.setupwizard.mode=ENABLED, $(call collapse-pairs, $(ADDITIONAL_SYSTEM_PROPERTIES))),)
410  # Don't require the setup wizard on eng builds
411  ADDITIONAL_SYSTEM_PROPERTIES := $(filter-out ro.setupwizard.mode=%,\
412          $(call collapse-pairs, $(ADDITIONAL_SYSTEM_PROPERTIES))) \
413          ro.setupwizard.mode=OPTIONAL
414endif
415ifndef is_sdk_build
416  # To speedup startup of non-preopted builds, don't verify or compile the boot image.
417  ADDITIONAL_SYSTEM_PROPERTIES += dalvik.vm.image-dex2oat-filter=extract
418endif
419endif
420
421## asan ##
422
423# Install some additional tools on ASAN builds IFF we are also installing debug tools
424ifneq ($(filter address,$(SANITIZE_TARGET)),)
425ifneq (,$(filter debug,$(tags_to_install)))
426  tags_to_install += asan
427endif
428endif
429
430## java coverage ##
431# Install additional tools on java coverage builds
432ifeq (true,$(EMMA_INSTRUMENT))
433ifneq (,$(filter debug,$(tags_to_install)))
434  tags_to_install += java_coverage
435endif
436endif
437
438
439## sdk ##
440
441ifdef is_sdk_build
442
443# Detect if we want to build a repository for the SDK
444sdk_repo_goal := $(strip $(filter sdk_repo,$(MAKECMDGOALS)))
445MAKECMDGOALS := $(strip $(filter-out sdk_repo,$(MAKECMDGOALS)))
446
447ifneq ($(words $(sort $(filter-out $(INTERNAL_MODIFIER_TARGETS) checkbuild emulator_tests,$(MAKECMDGOALS)))),1)
448$(error The 'sdk' target may not be specified with any other targets)
449endif
450
451# TODO: this should be eng I think.  Since the sdk is built from the eng
452# variant.
453tags_to_install := debug eng
454ADDITIONAL_SYSTEM_PROPERTIES += xmpp.auto-presence=true
455ADDITIONAL_SYSTEM_PROPERTIES += ro.config.nocheckin=yes
456else # !sdk
457endif
458
459BUILD_WITHOUT_PV := true
460
461ADDITIONAL_SYSTEM_PROPERTIES += net.bt.name=Android
462
463# ------------------------------------------------------------
464# Define a function that, given a list of module tags, returns
465# non-empty if that module should be installed in /system.
466
467# For most goals, anything not tagged with the "tests" tag should
468# be installed in /system.
469define should-install-to-system
470$(if $(filter tests,$(1)),,true)
471endef
472
473ifdef is_sdk_build
474# For the sdk goal, anything with the "samples" tag should be
475# installed in /data even if that module also has "eng"/"debug"/"user".
476define should-install-to-system
477$(if $(filter samples tests,$(1)),,true)
478endef
479endif
480
481
482# If they only used the modifier goals (all, etc), we'll actually
483# build the default target.
484ifeq ($(filter-out $(INTERNAL_MODIFIER_TARGETS),$(MAKECMDGOALS)),)
485.PHONY: $(INTERNAL_MODIFIER_TARGETS)
486$(INTERNAL_MODIFIER_TARGETS): $(DEFAULT_GOAL)
487endif
488
489#
490# Typical build; include any Android.mk files we can find.
491#
492
493# Bring in dex_preopt.mk
494# This creates some modules so it needs to be included after
495# should-install-to-system is defined (in order for base_rules.mk to function
496# properly), but before readonly-final-product-vars is called.
497include $(BUILD_SYSTEM)/dex_preopt.mk
498
499# Strip and readonly a few more variables so they won't be modified.
500$(readonly-final-product-vars)
501ADDITIONAL_SYSTEM_PROPERTIES := $(strip $(ADDITIONAL_SYSTEM_PROPERTIES))
502.KATI_READONLY := ADDITIONAL_SYSTEM_PROPERTIES
503ADDITIONAL_PRODUCT_PROPERTIES := $(strip $(ADDITIONAL_PRODUCT_PROPERTIES))
504.KATI_READONLY := ADDITIONAL_PRODUCT_PROPERTIES
505
506ifneq ($(PRODUCT_ENFORCE_RRO_TARGETS),)
507ENFORCE_RRO_SOURCES :=
508endif
509
510# Color-coded warnings including current module info
511# $(1): message to print
512define pretty-warning
513$(shell $(call echo-warning,$(LOCAL_MODULE_MAKEFILE),$(LOCAL_MODULE): $(1)))
514endef
515
516# Color-coded errors including current module info
517# $(1): message to print
518define pretty-error
519$(shell $(call echo-error,$(LOCAL_MODULE_MAKEFILE),$(LOCAL_MODULE): $(1)))
520$(error done)
521endef
522
523subdir_makefiles_inc := .
524FULL_BUILD :=
525
526ifneq ($(dont_bother),true)
527FULL_BUILD := true
528#
529# Include all of the makefiles in the system
530#
531
532subdir_makefiles := $(SOONG_OUT_DIR)/installs-$(TARGET_PRODUCT).mk $(SOONG_ANDROID_MK)
533# Android.mk files are only used on Linux builds, Mac only supports Android.bp
534ifeq ($(HOST_OS),linux)
535  subdir_makefiles += $(file <$(OUT_DIR)/.module_paths/Android.mk.list)
536endif
537subdir_makefiles += $(SOONG_OUT_DIR)/late-$(TARGET_PRODUCT).mk
538subdir_makefiles_total := $(words int $(subdir_makefiles) post finish)
539.KATI_READONLY := subdir_makefiles_total
540
541$(foreach mk,$(subdir_makefiles),$(info [$(call inc_and_print,subdir_makefiles_inc)/$(subdir_makefiles_total)] including $(mk) ...)$(eval include $(mk)))
542
543# For an unbundled image, we can skip blueprint_tools because unbundled image
544# aims to remove a large number framework projects from the manifest, the
545# sources or dependencies for these tools may be missing from the tree.
546ifeq (,$(TARGET_BUILD_UNBUNDLED_IMAGE))
547droid_targets : blueprint_tools
548endif
549
550endif # dont_bother
551
552ifndef subdir_makefiles_total
553subdir_makefiles_total := $(words init post finish)
554endif
555
556$(info [$(call inc_and_print,subdir_makefiles_inc)/$(subdir_makefiles_total)] finishing build rules ...)
557
558# -------------------------------------------------------------------
559# All module makefiles have been included at this point.
560# -------------------------------------------------------------------
561
562# -------------------------------------------------------------------
563# Use basic warning/error messages now that LOCAL_MODULE_MAKEFILE
564# and LOCAL_MODULE aren't useful anymore.
565# -------------------------------------------------------------------
566define pretty-warning
567$(warning $(1))
568endef
569
570define pretty-error
571$(error $(1))
572endef
573
574# -------------------------------------------------------------------
575# Enforce to generate all RRO packages for modules having resource
576# overlays.
577# -------------------------------------------------------------------
578ifneq ($(PRODUCT_ENFORCE_RRO_TARGETS),)
579$(call generate_all_enforce_rro_packages)
580endif
581
582# -------------------------------------------------------------------
583# Sort ALL_MODULES to remove duplicate entries.
584# -------------------------------------------------------------------
585ALL_MODULES := $(sort $(ALL_MODULES))
586# Cannot set to readonly because Makefile extends ALL_MODULES
587# .KATI_READONLY := ALL_MODULES
588
589# -------------------------------------------------------------------
590# Fix up CUSTOM_MODULES to refer to installed files rather than
591# just bare module names.  Leave unknown modules alone in case
592# they're actually full paths to a particular file.
593known_custom_modules := $(filter $(ALL_MODULES),$(CUSTOM_MODULES))
594unknown_custom_modules := $(filter-out $(ALL_MODULES),$(CUSTOM_MODULES))
595CUSTOM_MODULES := \
596	$(call module-installed-files,$(known_custom_modules)) \
597	$(unknown_custom_modules)
598
599# -------------------------------------------------------------------
600# Define dependencies for modules that require other modules.
601# This can only happen now, after we've read in all module makefiles.
602#
603# TODO: deal with the fact that a bare module name isn't
604# unambiguous enough.  Maybe declare short targets like
605# APPS:Quake or HOST:SHARED_LIBRARIES:libutils.
606# BUG: the system image won't know to depend on modules that are
607# brought in as requirements of other modules.
608#
609# Resolve the required module name to 32-bit or 64-bit variant.
610
611# Get a list of corresponding module names for the second arch, if they exist.
612# $(1): TARGET, HOST or HOST_CROSS
613# $(2): A list of module names
614define get-modules-for-2nd-arch
615$(strip \
616  $(foreach m,$(2), \
617    $(if $(filter true,$(ALL_MODULES.$(m)$($(1)_2ND_ARCH_MODULE_SUFFIX).FOR_2ND_ARCH)), \
618      $(m)$($(1)_2ND_ARCH_MODULE_SUFFIX) \
619    ) \
620  ) \
621)
622endef
623
624# Resolves module bitness for PRODUCT_PACKAGES and PRODUCT_HOST_PACKAGES.
625# The returned list of module names can be used to access
626# ALL_MODULES.<module>.<*> variables.
627# Name resolution for PRODUCT_PACKAGES / PRODUCT_HOST_PACKAGES:
628#   foo:32 resolves to foo_32;
629#   foo:64 resolves to foo;
630#   foo resolves to both foo and foo_32 (if foo_32 is defined).
631#
632# Name resolution for HOST_CROSS modules:
633#   foo:32 resolves to foo;
634#   foo:64 resolves to foo_64;
635#   foo resolves to both foo and foo_64 (if foo_64 is defined).
636#
637# $(1): TARGET, HOST or HOST_CROSS
638# $(2): A list of simple module names with :32 and :64 suffix
639define resolve-bitness-for-modules
640$(strip \
641  $(eval modules_32 := $(patsubst %:32,%,$(filter %:32,$(2)))) \
642  $(eval modules_64 := $(patsubst %:64,%,$(filter %:64,$(2)))) \
643  $(eval modules_both := $(filter-out %:32 %:64,$(2))) \
644  $(eval ### if 2ND_HOST_CROSS_IS_64_BIT, then primary/secondary are reversed for HOST_CROSS modules) \
645  $(if $(filter HOST_CROSS_true,$(1)_$(2ND_HOST_CROSS_IS_64_BIT)), \
646    $(eval modules_1st_arch := $(modules_32)) \
647    $(eval modules_2nd_arch := $(modules_64)), \
648    $(eval modules_1st_arch := $(modules_64)) \
649    $(eval modules_2nd_arch := $(modules_32))) \
650  $(eval ### Note for 32-bit product, 32 and 64 will be added as their original module names.) \
651  $(eval modules := $(modules_1st_arch)) \
652  $(if $($(1)_2ND_ARCH), \
653    $(eval modules += $(call get-modules-for-2nd-arch,$(1),$(modules_2nd_arch))), \
654    $(eval modules += $(modules_2nd_arch))) \
655  $(eval ### For the rest we add both) \
656  $(eval modules += $(modules_both)) \
657  $(if $($(1)_2ND_ARCH), \
658    $(eval modules += $(call get-modules-for-2nd-arch,$(1),$(modules_both)))) \
659  $(modules) \
660)
661endef
662
663# Resolve the required module names to 32-bit or 64-bit variant for:
664#   ALL_MODULES.<*>.REQUIRED_FROM_TARGET
665#   ALL_MODULES.<*>.REQUIRED_FROM_HOST
666#   ALL_MODULES.<*>.REQUIRED_FROM_HOST_CROSS
667#
668# If a module is for cross host OS, the required modules are also for that OS.
669# Required modules explicitly suffixed with :32 or :64 resolve to that bitness.
670# Otherwise if the requiring module is native and the required module is shared
671# library or native test, then the required module resolves to the same bitness.
672# Otherwise the required module resolves to both variants, if they exist.
673# $(1): TARGET, HOST or HOST_CROSS
674define select-bitness-of-required-modules
675$(foreach m,$(ALL_MODULES), \
676  $(eval r := $(ALL_MODULES.$(m).REQUIRED_FROM_$(1))) \
677  $(if $(r), \
678    $(if $(filter HOST_CROSS,$(1)), \
679      $(if $(ALL_MODULES.$(m).FOR_HOST_CROSS),,$(error Only expected REQUIRED_FROM_HOST_CROSS on FOR_HOST_CROSS modules - $(m))) \
680      $(eval r := $(addprefix host_cross_,$(r)))) \
681    $(eval module_is_native := \
682      $(filter EXECUTABLES SHARED_LIBRARIES NATIVE_TESTS,$(ALL_MODULES.$(m).CLASS))) \
683    $(eval r_r := \
684      $(foreach r_i,$(r), \
685        $(if $(filter %:32 %:64,$(r_i)), \
686          $(eval r_m := $(call resolve-bitness-for-modules,$(1),$(r_i))), \
687          $(eval r_m := \
688            $(eval r_i_2nd := $(call get-modules-for-2nd-arch,$(1),$(r_i))) \
689            $(eval required_is_shared_library_or_native_test := \
690              $(filter SHARED_LIBRARIES NATIVE_TESTS, \
691                $(ALL_MODULES.$(r_i).CLASS) $(ALL_MODULES.$(r_i_2nd).CLASS))) \
692            $(if $(and $(module_is_native),$(required_is_shared_library_or_native_test)), \
693              $(if $(ALL_MODULES.$(m).FOR_2ND_ARCH),$(r_i_2nd),$(r_i)), \
694              $(r_i) $(r_i_2nd)))) \
695        $(eval r_m := $(foreach r_j,$(r_m),$(if $(ALL_MODULES.$(r_j).PATH),$(r_j)))) \
696        $(if $(r_m),,$(eval _nonexistent_required += $(1)$(comma)$(m)$(comma)$(1)$(comma)$(r_i))) \
697        $(r_m))) \
698    $(eval ALL_MODULES.$(m).REQUIRED_FROM_$(1) := $(sort $(r_r))) \
699  ) \
700)
701endef
702
703# Resolve the required module names to 32-bit or 64-bit variant for:
704#   ALL_MODULES.<*>.TARGET_REQUIRED_FROM_HOST
705#   ALL_MODULES.<*>.HOST_REQUIRED_FROM_TARGET
706#
707# This is like select-bitness-of-required-modules, but it doesn't have
708# complicated logic for various module types.
709# Calls resolve-bitness-for-modules to resolve module names.
710# $(1): TARGET or HOST
711# $(2): HOST or TARGET
712define select-bitness-of-target-host-required-modules
713$(foreach m,$(ALL_MODULES), \
714  $(eval r := $(ALL_MODULES.$(m).$(1)_REQUIRED_FROM_$(2))) \
715  $(if $(r), \
716    $(eval r_r := \
717      $(foreach r_i,$(r), \
718        $(eval r_m := $(call resolve-bitness-for-modules,$(1),$(r_i))) \
719        $(eval r_m := $(foreach r_j,$(r_m),$(if $(ALL_MODULES.$(r_j).PATH),$(r_j)))) \
720        $(if $(r_m),,$(eval _nonexistent_required += $(2)$(comma)$(m)$(comma)$(1)$(comma)$(r_i))) \
721        $(r_m))) \
722    $(eval ALL_MODULES.$(m).$(1)_REQUIRED_FROM_$(2) := $(sort $(r_r))) \
723  ) \
724)
725endef
726
727_nonexistent_required :=
728$(call select-bitness-of-required-modules,TARGET)
729$(call select-bitness-of-required-modules,HOST)
730$(call select-bitness-of-required-modules,HOST_CROSS)
731$(call select-bitness-of-target-host-required-modules,TARGET,HOST)
732$(call select-bitness-of-target-host-required-modules,HOST,TARGET)
733_nonexistent_required := $(sort $(_nonexistent_required))
734
735check_missing_required_modules := true
736ifneq (,$(filter true,$(ALLOW_MISSING_DEPENDENCIES) $(BUILD_BROKEN_MISSING_REQUIRED_MODULES)))
737  check_missing_required_modules :=
738endif # ALLOW_MISSING_DEPENDENCIES == true || BUILD_BROKEN_MISSING_REQUIRED_MODULES == true
739
740# Some executables are skipped in ASAN SANITIZE_TARGET build, thus breaking their dependencies.
741ifneq (,$(filter address,$(SANITIZE_TARGET)))
742  check_missing_required_modules :=
743endif # SANITIZE_TARGET has ASAN
744
745# HOST OS darwin build is broken, disable this check for darwin for now.
746# TODO(b/162102724): Remove this when darwin host has no broken dependency.
747ifneq (,$(filter $(HOST_OS),darwin))
748  check_missing_required_modules :=
749endif # HOST_OS == darwin
750
751ifeq (true,$(check_missing_required_modules))
752ifneq (,$(_nonexistent_required))
753  $(warning Missing required dependencies:)
754  $(foreach r_i,$(_nonexistent_required), \
755    $(eval r := $(subst $(comma),$(space),$(r_i))) \
756    $(info $(word 1,$(r)) module $(word 2,$(r)) requires non-existent $(word 3,$(r)) module: $(word 4,$(r))) \
757  )
758  $(warning Set BUILD_BROKEN_MISSING_REQUIRED_MODULES := true to bypass this check if this is intentional)
759  $(error Build failed)
760endif # _nonexistent_required != empty
761endif # check_missing_required_modules == true
762
763define add-required-deps
764$(1): | $(2)
765endef
766
767# Use a normal dependency instead of an order-only dependency when installing
768# host dynamic binaries so that the timestamp of the final binary always
769# changes, even if the toc optimization has skipped relinking the binary
770# and its dependant shared libraries.
771define add-required-host-so-deps
772$(1): $(2)
773endef
774
775# Sets up dependencies such that whenever a host module is installed,
776# any other host modules listed in $(ALL_MODULES.$(m).REQUIRED_FROM_HOST) will also be installed
777define add-all-host-to-host-required-modules-deps
778$(foreach m,$(ALL_MODULES), \
779  $(eval r := $(ALL_MODULES.$(m).REQUIRED_FROM_HOST)) \
780  $(if $(r), \
781    $(eval r := $(call module-installed-files,$(r))) \
782    $(eval h_m := $(filter $(HOST_OUT)/%, $(ALL_MODULES.$(m).INSTALLED))) \
783    $(eval h_r := $(filter $(HOST_OUT)/%, $(r))) \
784    $(eval h_r := $(filter-out $(h_m), $(h_r))) \
785    $(if $(h_m), $(eval $(call add-required-deps, $(h_m),$(h_r)))) \
786  ) \
787)
788endef
789$(call add-all-host-to-host-required-modules-deps)
790
791# Sets up dependencies such that whenever a host cross module is installed,
792# any other host cross modules listed in $(ALL_MODULES.$(m).REQUIRED_FROM_HOST_CROSS) will also be installed
793define add-all-host-cross-to-host-cross-required-modules-deps
794$(foreach m,$(ALL_MODULES), \
795  $(eval r := $(ALL_MODULES.$(m).REQUIRED_FROM_HOST_CROSS)) \
796  $(if $(r), \
797    $(eval r := $(call module-installed-files,$(r))) \
798    $(eval hc_m := $(filter $(HOST_CROSS_OUT)/%, $(ALL_MODULES.$(m).INSTALLED))) \
799    $(eval hc_r := $(filter $(HOST_CROSS_OUT)/%, $(r))) \
800    $(eval hc_r := $(filter-out $(hc_m), $(hc_r))) \
801    $(if $(hc_m), $(eval $(call add-required-deps, $(hc_m),$(hc_r)))) \
802  ) \
803)
804endef
805$(call add-all-host-cross-to-host-cross-required-modules-deps)
806
807# Sets up dependencies such that whenever a target module is installed,
808# any other target modules listed in $(ALL_MODULES.$(m).REQUIRED_FROM_TARGET) will also be installed
809define add-all-target-to-target-required-modules-deps
810$(foreach m,$(ALL_MODULES), \
811  $(eval r := $(ALL_MODULES.$(m).REQUIRED_FROM_TARGET)) \
812  $(if $(r), \
813    $(eval r := $(call module-installed-files,$(r))) \
814    $(eval t_m := $(filter $(TARGET_OUT_ROOT)/%, $(ALL_MODULES.$(m).INSTALLED))) \
815    $(eval t_r := $(filter $(TARGET_OUT_ROOT)/%, $(r))) \
816    $(eval t_r := $(filter-out $(t_m), $(t_r))) \
817    $(if $(t_m), $(eval $(call add-required-deps, $(t_m),$(t_r)))) \
818  ) \
819)
820endef
821$(call add-all-target-to-target-required-modules-deps)
822
823# Sets up dependencies such that whenever a host module is installed,
824# any target modules listed in $(ALL_MODULES.$(m).TARGET_REQUIRED_FROM_HOST) will also be installed
825define add-all-host-to-target-required-modules-deps
826$(foreach m,$(ALL_MODULES), \
827  $(eval req_mods := $(ALL_MODULES.$(m).TARGET_REQUIRED_FROM_HOST))\
828  $(if $(req_mods), \
829    $(eval req_files := )\
830    $(foreach req_mod,$(req_mods), \
831      $(eval req_file := $(filter $(TARGET_OUT_ROOT)/%, $(call module-installed-files,$(req_mod)))) \
832      $(if $(filter true,$(ALLOW_MISSING_DEPENDENCIES)), \
833        , \
834        $(if $(strip $(req_file)), \
835          , \
836          $(error $(m).LOCAL_TARGET_REQUIRED_MODULES : illegal value $(req_mod) : not a device module. If you want to specify host modules to be required to be installed along with your host module, add those module names to LOCAL_REQUIRED_MODULES instead) \
837        ) \
838      ) \
839      $(eval req_files := $(req_files)$(space)$(req_file))\
840    )\
841    $(eval req_files := $(strip $(req_files)))\
842    $(eval mod_files := $(filter $(HOST_OUT)/%, $(call module-installed-files,$(m)))) \
843    $(if $(mod_files),\
844      $(eval $(call add-required-deps, $(mod_files),$(req_files))) \
845    )\
846  )\
847)
848endef
849$(call add-all-host-to-target-required-modules-deps)
850
851# Sets up dependencies such that whenever a target module is installed,
852# any host modules listed in $(ALL_MODULES.$(m).HOST_REQUIRED_FROM_TARGET) will also be installed
853define add-all-target-to-host-required-modules-deps
854$(foreach m,$(ALL_MODULES), \
855  $(eval req_mods := $(ALL_MODULES.$(m).HOST_REQUIRED_FROM_TARGET))\
856  $(if $(req_mods), \
857    $(eval req_files := )\
858    $(foreach req_mod,$(req_mods), \
859      $(eval req_file := $(filter $(HOST_OUT)/%, $(call module-installed-files,$(req_mod)))) \
860      $(if $(filter true,$(ALLOW_MISSING_DEPENDENCIES)), \
861        , \
862        $(if $(strip $(req_file)), \
863          , \
864          $(error $(m).LOCAL_HOST_REQUIRED_MODULES : illegal value $(req_mod) : not a host module. If you want to specify target modules to be required to be installed along with your target module, add those module names to LOCAL_REQUIRED_MODULES instead) \
865        ) \
866      ) \
867      $(eval req_files := $(req_files)$(space)$(req_file))\
868    )\
869    $(eval req_files := $(strip $(req_files)))\
870    $(eval mod_files := $(filter $(TARGET_OUT_ROOT)/%, $(call module-installed-files,$(m))))\
871    $(if $(mod_files),\
872      $(eval $(call add-required-deps, $(mod_files),$(req_files))) \
873    )\
874  )\
875)
876endef
877$(call add-all-target-to-host-required-modules-deps)
878
879t_m :=
880h_m :=
881hc_m :=
882t_r :=
883h_r :=
884hc_r :=
885
886# Establish the dependencies on the shared libraries.
887# It also adds the shared library module names to ALL_MODULES.$(m).REQUIRED_FROM_(TARGET|HOST|HOST_CROSS),
888# so they can be expanded to product_MODULES later.
889# $(1): TARGET_ or HOST_ or HOST_CROSS_.
890# $(2): non-empty for 2nd arch.
891# $(3): non-empty for host cross compile.
892define resolve-shared-libs-depes
893$(foreach m,$($(if $(2),$($(1)2ND_ARCH_VAR_PREFIX))$(1)DEPENDENCIES_ON_SHARED_LIBRARIES),\
894  $(eval p := $(subst :,$(space),$(m)))\
895  $(eval mod := $(firstword $(p)))\
896  $(eval deps := $(subst $(comma),$(space),$(lastword $(p))))\
897  $(eval root := $(1)OUT$(if $(call streq,$(1),TARGET_),_ROOT))\
898  $(if $(2),$(eval deps := $(addsuffix $($(1)2ND_ARCH_MODULE_SUFFIX),$(deps))))\
899  $(if $(3),$(eval deps := $(addprefix host_cross_,$(deps))))\
900  $(eval r := $(filter $($(root))/%,$(call module-installed-files,\
901    $(deps))))\
902  $(if $(filter $(1),HOST_),\
903    $(eval ALL_MODULES.$(mod).HOST_SHARED_LIBRARY_FILES := $$(ALL_MODULES.$(mod).HOST_SHARED_LIBRARY_FILES) $(word 2,$(p)) $(r))\
904    $(eval ALL_MODULES.$(mod).HOST_SHARED_LIBRARIES := $$(ALL_MODULES.$(mod).HOST_SHARED_LIBRARIES) $(deps))\
905    $(eval $(call add-required-host-so-deps,$(word 2,$(p)),$(r))),\
906    $(eval $(call add-required-deps,$(word 2,$(p)),$(r))))\
907  $(eval ALL_MODULES.$(mod).REQUIRED_FROM_$(patsubst %_,%,$(1)) += $(deps)))
908endef
909
910# Recursively resolve host shared library dependency for a given module.
911# $(1): module name
912# Returns all dependencies of shared library.
913define get-all-shared-libs-deps
914$(if $(_all_deps_for_$(1)_set_),$(_all_deps_for_$(1)_),\
915  $(eval _all_deps_for_$(1)_ :=) \
916  $(foreach dep,$(ALL_MODULES.$(1).HOST_SHARED_LIBRARIES),\
917    $(foreach m,$(call get-all-shared-libs-deps,$(dep)),\
918      $(eval _all_deps_for_$(1)_ := $$(_all_deps_for_$(1)_) $(m))\
919      $(eval _all_deps_for_$(1)_ := $(sort $(_all_deps_for_$(1)_))))\
920    $(eval _all_deps_for_$(1)_ := $$(_all_deps_for_$(1)_) $(dep))\
921    $(eval _all_deps_for_$(1)_ := $(sort $(_all_deps_for_$(1)_) $(dep)))\
922    $(eval _all_deps_for_$(1)_set_ := true))\
923$(_all_deps_for_$(1)_))
924endef
925
926# Scan all modules in general-tests, device-tests and other selected suites and
927# flatten the shared library dependencies.
928define update-host-shared-libs-deps-for-suites
929$(foreach suite,general-tests device-tests vts tvts art-host-tests host-unit-tests,\
930  $(foreach m,$(COMPATIBILITY.$(suite).MODULES),\
931    $(eval my_deps := $(call get-all-shared-libs-deps,$(m)))\
932    $(foreach dep,$(my_deps),\
933      $(foreach f,$(ALL_MODULES.$(dep).HOST_SHARED_LIBRARY_FILES),\
934        $(if $(filter $(suite),device-tests general-tests),\
935          $(eval my_testcases := $(HOST_OUT_TESTCASES)),\
936          $(eval my_testcases := $$(COMPATIBILITY_TESTCASES_OUT_$(suite))))\
937        $(eval target := $(my_testcases)/$(lastword $(subst /, ,$(dir $(f))))/$(notdir $(f)))\
938        $(if $(strip $(ALL_TARGETS.$(target).META_LIC)),,$(eval ALL_TARGETS.$(target).META_LIC:=$(module_license_metadata)))\
939        $(eval COMPATIBILITY.$(suite).HOST_SHARED_LIBRARY.FILES := \
940          $$(COMPATIBILITY.$(suite).HOST_SHARED_LIBRARY.FILES) $(f):$(target))\
941        $(eval COMPATIBILITY.$(suite).HOST_SHARED_LIBRARY.FILES := \
942          $(sort $(COMPATIBILITY.$(suite).HOST_SHARED_LIBRARY.FILES)))))))
943endef
944
945$(call resolve-shared-libs-depes,TARGET_)
946ifdef TARGET_2ND_ARCH
947$(call resolve-shared-libs-depes,TARGET_,true)
948endif
949$(call resolve-shared-libs-depes,HOST_)
950ifdef HOST_2ND_ARCH
951$(call resolve-shared-libs-depes,HOST_,true)
952endif
953# Update host side shared library dependencies for tests in suite device-tests and general-tests.
954# This should be called after calling resolve-shared-libs-depes for HOST_2ND_ARCH.
955$(call update-host-shared-libs-deps-for-suites)
956ifdef HOST_CROSS_OS
957$(call resolve-shared-libs-depes,HOST_CROSS_,,true)
958ifdef HOST_CROSS_2ND_ARCH
959$(call resolve-shared-libs-depes,HOST_CROSS_,true,true)
960endif
961endif
962
963# Pass the shared libraries dependencies to prebuilt ELF file check.
964define add-elf-file-check-shared-lib
965$(1): PRIVATE_SHARED_LIBRARY_FILES += $(2)
966$(1): $(2)
967endef
968
969define resolve-shared-libs-for-elf-file-check
970$(foreach m,$($(if $(2),$($(1)2ND_ARCH_VAR_PREFIX))$(1)DEPENDENCIES_ON_SHARED_LIBRARIES),\
971  $(eval p := $(subst :,$(space),$(m)))\
972  $(eval mod := $(firstword $(p)))\
973  \
974  $(eval deps := $(subst $(comma),$(space),$(lastword $(p))))\
975  $(if $(2),$(eval deps := $(addsuffix $($(1)2ND_ARCH_MODULE_SUFFIX),$(deps))))\
976  $(eval root := $(1)OUT$(if $(call streq,$(1),TARGET_),_ROOT))\
977  $(eval deps := $(filter $($(root))/%$($(1)SHLIB_SUFFIX),$(call module-built-files,$(deps))))\
978  \
979  $(eval r := $(firstword $(filter \
980    $($(if $(2),$($(1)2ND_ARCH_VAR_PREFIX))TARGET_OUT_INTERMEDIATES)/EXECUTABLES/%\
981    $($(if $(2),$($(1)2ND_ARCH_VAR_PREFIX))TARGET_OUT_INTERMEDIATES)/NATIVE_TESTS/%\
982    $($(if $(2),$($(1)2ND_ARCH_VAR_PREFIX))TARGET_OUT_INTERMEDIATES)/SHARED_LIBRARIES/%,\
983    $(call module-built-files,$(mod)))))\
984  \
985  $(if $(and $(r),$(deps)),\
986    $(eval stamp := $(dir $(r))check_elf_files.timestamp)\
987    $(if $(CHECK_ELF_FILES.$(stamp)),\
988      $(eval $(call add-elf-file-check-shared-lib,$(stamp),$(deps))))\
989  ))
990endef
991
992$(call resolve-shared-libs-for-elf-file-check,TARGET_)
993ifdef TARGET_2ND_ARCH
994$(call resolve-shared-libs-for-elf-file-check,TARGET_,true)
995endif
996
997m :=
998r :=
999p :=
1000stamp :=
1001deps :=
1002add-required-deps :=
1003
1004################################################################################
1005# Link type checking
1006#
1007# ALL_LINK_TYPES contains a list of all link type prefixes (generally one per
1008# module, but APKs can "link" to both java and native code). The link type
1009# prefix consists of all the information needed by intermediates-dir-for:
1010#
1011#  LINK_TYPE:TARGET:_:2ND:STATIC_LIBRARIES:libfoo
1012#
1013#   1: LINK_TYPE literal
1014#   2: prefix
1015#     - TARGET
1016#     - HOST
1017#     - HOST_CROSS
1018#   3: Whether to use the common intermediates directory or not
1019#     - _
1020#     - COMMON
1021#   4: Whether it's the second arch or not
1022#     - _
1023#     - 2ND_
1024#   5: Module Class
1025#     - STATIC_LIBRARIES
1026#     - SHARED_LIBRARIES
1027#     - ...
1028#   6: Module Name
1029#
1030# Then fields under that are separated by a period and the field name:
1031#   - TYPE: the link types for this module
1032#   - MAKEFILE: Where this module was defined
1033#   - BUILT: The built module location
1034#   - DEPS: the link type prefixes for the module's dependencies
1035#   - ALLOWED: the link types to allow in this module's dependencies
1036#   - WARN: the link types to warn about in this module's dependencies
1037#
1038# All of the dependency link types not listed in ALLOWED or WARN will become
1039# errors.
1040################################################################################
1041
1042link_type_error :=
1043
1044define link-type-prefix
1045$(word 2,$(subst :,$(space),$(1)))
1046endef
1047define link-type-common
1048$(patsubst _,,$(word 3,$(subst :,$(space),$(1))))
1049endef
1050define link-type-2ndarchprefix
1051$(patsubst _,,$(word 4,$(subst :,$(space),$(1))))
1052endef
1053define link-type-class
1054$(word 5,$(subst :,$(space),$(1)))
1055endef
1056define link-type-name
1057$(word 6,$(subst :,$(space),$(1)))
1058endef
1059define link-type-os
1060$(strip $(eval _p := $(link-type-prefix))\
1061  $(if $(filter HOST HOST_CROSS,$(_p)),\
1062    $($(_p)_OS),\
1063    android))
1064endef
1065define link-type-arch
1066$($(link-type-prefix)_$(link-type-2ndarchprefix)ARCH)
1067endef
1068define link-type-name-variant
1069$(link-type-name) ($(link-type-class) $(link-type-os)-$(link-type-arch))
1070endef
1071
1072# $(1): the prefix of the module doing the linking
1073# $(2): the prefix of the linked module
1074define link-type-warning
1075$(shell $(call echo-warning,$($(1).MAKEFILE),"$(call link-type-name,$(1)) ($($(1).TYPE)) should not link against $(call link-type-name,$(2)) ($(3))"))
1076endef
1077
1078# $(1): the prefix of the module doing the linking
1079# $(2): the prefix of the linked module
1080define link-type-error
1081$(shell $(call echo-error,$($(1).MAKEFILE),"$(call link-type-name,$(1)) ($($(1).TYPE)) can not link against $(call link-type-name,$(2)) ($(3))"))\
1082$(eval link_type_error := true)
1083endef
1084
1085link-type-missing :=
1086ifneq ($(ALLOW_MISSING_DEPENDENCIES),true)
1087  # Print an error message if the linked-to module is missing
1088  # $(1): the prefix of the module doing the linking
1089  # $(2): the prefix of the missing module
1090  define link-type-missing
1091    $(shell $(call echo-error,$($(1).MAKEFILE),"$(call link-type-name-variant,$(1)) missing $(call link-type-name-variant,$(2))"))\
1092    $(eval available_variants := $(filter %:$(call link-type-name,$(2)),$(ALL_LINK_TYPES)))\
1093    $(if $(available_variants),\
1094      $(info Available variants:)\
1095      $(foreach v,$(available_variants),$(info $(space)$(space)$(call link-type-name-variant,$(v)))))\
1096    $(info You can set ALLOW_MISSING_DEPENDENCIES=true in your environment if this is intentional, but that may defer real problems until later in the build.)\
1097    $(eval link_type_error := true)
1098  endef
1099else
1100  define link-type-missing
1101    $(eval $$(1).MISSING := true)
1102  endef
1103endif
1104
1105# Verify that $(1) can link against $(2)
1106# Both $(1) and $(2) are the link type prefix defined above
1107define verify-link-type
1108$(foreach t,$($(2).TYPE),\
1109  $(if $(filter-out $($(1).ALLOWED),$(t)),\
1110    $(if $(filter $(t),$($(1).WARN)),\
1111      $(call link-type-warning,$(1),$(2),$(t)),\
1112      $(call link-type-error,$(1),$(2),$(t)))))
1113endef
1114
1115$(foreach lt,$(ALL_LINK_TYPES),\
1116  $(foreach d,$($(lt).DEPS),\
1117    $(if $($(d).TYPE),\
1118      $(call verify-link-type,$(lt),$(d)),\
1119      $(call link-type-missing,$(lt),$(d)))))
1120
1121ifdef link_type_error
1122  $(error exiting from previous errors)
1123endif
1124
1125# -------------------------------------------------------------------
1126# Handle exported/imported includes
1127
1128# Recursively calculate flags
1129$(foreach export,$(EXPORTS_LIST), \
1130  $(eval EXPORTS.$$(export) = $$(EXPORTS.$(export).FLAGS) \
1131    $(foreach dep,$(EXPORTS.$(export).REEXPORT),$$(EXPORTS.$(dep)))))
1132
1133# Recursively calculate dependencies
1134$(foreach export,$(EXPORTS_LIST), \
1135  $(eval EXPORT_DEPS.$$(export) = $$(EXPORTS.$(export).DEPS) \
1136    $(foreach dep,$(EXPORTS.$(export).REEXPORT),$$(EXPORT_DEPS.$(dep)))))
1137
1138# Converts the recursive variables to simple variables so that we don't have to
1139# evaluate them for every .o rule
1140$(foreach export,$(EXPORTS_LIST),$(eval EXPORTS.$$(export) := $$(strip $$(EXPORTS.$$(export)))))
1141$(foreach export,$(EXPORTS_LIST),$(eval EXPORT_DEPS.$$(export) := $$(sort $$(EXPORT_DEPS.$$(export)))))
1142
1143# Add dependencies
1144$(foreach export,$(EXPORTS_LIST),$(eval $(call add-dependency,$$(EXPORTS.$$(export).USERS),$$(EXPORT_DEPS.$$(export)))))
1145
1146# -------------------------------------------------------------------
1147# Figure out our module sets.
1148#
1149# Of the modules defined by the component makefiles,
1150# determine what we actually want to build.
1151
1152
1153# Expand a list of modules to the modules that they override (if any)
1154# $(1): The list of modules.
1155define module-overrides
1156$(foreach m,$(1),\
1157  $(eval _mo_overrides := $(PACKAGES.$(m).OVERRIDES) $(EXECUTABLES.$(m).OVERRIDES) $(SHARED_LIBRARIES.$(m).OVERRIDES) $(ETC.$(m).OVERRIDES))\
1158  $(if $(filter $(m),$(_mo_overrides)),\
1159    $(error Module $(m) cannot override itself),\
1160    $(_mo_overrides)))
1161endef
1162
1163###########################################################
1164## Expand a module name list with REQUIRED modules
1165###########################################################
1166# $(1): The variable name that holds the initial module name list.
1167#       the variable will be modified to hold the expanded results.
1168# $(2): The initial module name list.
1169# $(3): The list of overridden modules.
1170# Returns empty string (maybe with some whitespaces).
1171define expand-required-modules
1172$(eval _erm_req := $(foreach m,$(2),$(ALL_MODULES.$(m).REQUIRED_FROM_TARGET))) \
1173$(eval _erm_new_modules := $(sort $(filter-out $($(1)),$(_erm_req)))) \
1174$(eval _erm_new_overrides := $(call module-overrides,$(_erm_new_modules))) \
1175$(eval _erm_all_overrides := $(3) $(_erm_new_overrides)) \
1176$(eval _erm_new_modules := $(filter-out $(_erm_all_overrides), $(_erm_new_modules))) \
1177$(eval $(1) := $(filter-out $(_erm_new_overrides),$($(1)))) \
1178$(eval $(1) += $(_erm_new_modules)) \
1179$(if $(_erm_new_modules),\
1180  $(call expand-required-modules,$(1),$(_erm_new_modules),$(_erm_all_overrides)))
1181endef
1182
1183# Same as expand-required-modules above, but does not handle module overrides, as
1184# we don't intend to support them on the host.
1185# $(1): The variable name that holds the initial module name list.
1186#       the variable will be modified to hold the expanded results.
1187# $(2): The initial module name list.
1188# $(3): HOST or HOST_CROSS depending on whether we're expanding host or host cross modules
1189# Returns empty string (maybe with some whitespaces).
1190define expand-required-host-modules
1191$(eval _erm_req := $(foreach m,$(2),$(ALL_MODULES.$(m).REQUIRED_FROM_$(3)))) \
1192$(eval _erm_new_modules := $(sort $(filter-out $($(1)),$(_erm_req)))) \
1193$(eval $(1) += $(_erm_new_modules)) \
1194$(if $(_erm_new_modules),\
1195  $(call expand-required-host-modules,$(1),$(_erm_new_modules),$(3)))
1196endef
1197
1198# Transforms paths relative to PRODUCT_OUT to absolute paths.
1199# $(1): list of relative paths
1200# $(2): optional suffix to append to paths
1201define resolve-product-relative-paths
1202  $(subst $(_vendor_path_placeholder),$(TARGET_COPY_OUT_VENDOR),\
1203    $(subst $(_product_path_placeholder),$(TARGET_COPY_OUT_PRODUCT),\
1204      $(subst $(_system_ext_path_placeholder),$(TARGET_COPY_OUT_SYSTEM_EXT),\
1205        $(subst $(_odm_path_placeholder),$(TARGET_COPY_OUT_ODM),\
1206          $(subst $(_vendor_dlkm_path_placeholder),$(TARGET_COPY_OUT_VENDOR_DLKM),\
1207            $(subst $(_odm_dlkm_path_placeholder),$(TARGET_COPY_OUT_ODM_DLKM),\
1208              $(subst $(_system_dlkm_path_placeholder),$(TARGET_COPY_OUT_SYSTEM_DLKM),\
1209                $(foreach p,$(1),$(call append-path,$(PRODUCT_OUT),$(p)$(2))))))))))
1210endef
1211
1212# Returns modules included automatically as a result of certain BoardConfig
1213# variables being set.
1214define auto-included-modules
1215  $(if $(BOARD_VNDK_VERSION),vndk_package) \
1216  $(if $(DEVICE_MANIFEST_FILE),vendor_manifest.xml) \
1217  $(if $(DEVICE_MANIFEST_SKUS),$(foreach sku, $(DEVICE_MANIFEST_SKUS),vendor_manifest_$(sku).xml)) \
1218  $(if $(ODM_MANIFEST_FILES),odm_manifest.xml) \
1219  $(if $(ODM_MANIFEST_SKUS),$(foreach sku, $(ODM_MANIFEST_SKUS),odm_manifest_$(sku).xml)) \
1220
1221endef
1222
1223# Lists most of the files a particular product installs, including:
1224# - PRODUCT_PACKAGES, and their LOCAL_REQUIRED_MODULES
1225# - PRODUCT_COPY_FILES
1226# The base list of modules to build for this product is specified
1227# by the appropriate product definition file, which was included
1228# by product_config.mk.
1229# Name resolution for PRODUCT_PACKAGES:
1230#   foo:32 resolves to foo_32;
1231#   foo:64 resolves to foo;
1232#   foo resolves to both foo and foo_32 (if foo_32 is defined).
1233#
1234# Name resolution for LOCAL_REQUIRED_MODULES:
1235#   See the select-bitness-of-required-modules definition.
1236# $(1): product makefile
1237
1238define product-installed-files
1239  $(eval _pif_modules := \
1240    $(call get-product-var,$(1),PRODUCT_PACKAGES) \
1241    $(if $(filter eng,$(tags_to_install)),$(call get-product-var,$(1),PRODUCT_PACKAGES_ENG)) \
1242    $(if $(filter debug,$(tags_to_install)),$(call get-product-var,$(1),PRODUCT_PACKAGES_DEBUG)) \
1243    $(if $(filter tests,$(tags_to_install)),$(call get-product-var,$(1),PRODUCT_PACKAGES_TESTS)) \
1244    $(if $(filter asan,$(tags_to_install)),$(call get-product-var,$(1),PRODUCT_PACKAGES_DEBUG_ASAN)) \
1245    $(if $(filter java_coverage,$(tags_to_install)),$(call get-product-var,$(1),PRODUCT_PACKAGES_DEBUG_JAVA_COVERAGE)) \
1246    $(call auto-included-modules) \
1247  ) \
1248  $(eval ### Filter out the overridden packages and executables before doing expansion) \
1249  $(eval _pif_overrides := $(call module-overrides,$(_pif_modules))) \
1250  $(eval _pif_modules := $(filter-out $(_pif_overrides), $(_pif_modules))) \
1251  $(eval ### Resolve the :32 :64 module name) \
1252  $(eval _pif_modules := $(sort $(call resolve-bitness-for-modules,TARGET,$(_pif_modules)))) \
1253  $(call expand-required-modules,_pif_modules,$(_pif_modules),$(_pif_overrides)) \
1254  $(filter-out $(HOST_OUT_ROOT)/%,$(call module-installed-files, $(_pif_modules))) \
1255  $(call resolve-product-relative-paths,\
1256    $(foreach cf,$(call get-product-var,$(1),PRODUCT_COPY_FILES),$(call word-colon,2,$(cf))))
1257endef
1258
1259# Similar to product-installed-files above, but handles PRODUCT_HOST_PACKAGES instead
1260# This does support the :32 / :64 syntax, but does not support module overrides.
1261define host-installed-files
1262  $(eval _hif_modules := $(call get-product-var,$(1),PRODUCT_HOST_PACKAGES)) \
1263  $(eval ### Split host vs host cross modules) \
1264  $(eval _hcif_modules := $(filter host_cross_%,$(_hif_modules))) \
1265  $(eval _hif_modules := $(filter-out host_cross_%,$(_hif_modules))) \
1266  $(eval ### Resolve the :32 :64 module name) \
1267  $(eval _hif_modules := $(sort $(call resolve-bitness-for-modules,HOST,$(_hif_modules)))) \
1268  $(eval _hcif_modules := $(sort $(call resolve-bitness-for-modules,HOST_CROSS,$(_hcif_modules)))) \
1269  $(call expand-required-host-modules,_hif_modules,$(_hif_modules),HOST) \
1270  $(call expand-required-host-modules,_hcif_modules,$(_hcif_modules),HOST_CROSS) \
1271  $(filter $(HOST_OUT)/%,$(call module-installed-files, $(_hif_modules))) \
1272  $(filter $(HOST_CROSS_OUT)/%,$(call module-installed-files, $(_hcif_modules)))
1273endef
1274
1275# Fails the build if the given list is non-empty, and prints it entries (stripping PRODUCT_OUT).
1276# $(1): list of files to print
1277# $(2): heading to print on failure
1278define maybe-print-list-and-error
1279$(if $(strip $(1)), \
1280  $(warning $(2)) \
1281  $(info Offending entries:) \
1282  $(foreach e,$(sort $(1)),$(info    $(patsubst $(PRODUCT_OUT)/%,%,$(e)))) \
1283  $(error Build failed) \
1284)
1285endef
1286
1287ifeq ($(HOST_OS),darwin)
1288  # Target builds are not supported on Mac
1289  product_target_FILES :=
1290  product_host_FILES := $(call host-installed-files,$(INTERNAL_PRODUCT))
1291else ifdef FULL_BUILD
1292  ifneq (true,$(ALLOW_MISSING_DEPENDENCIES))
1293    # Check to ensure that all modules in PRODUCT_PACKAGES exist (opt in per product)
1294    ifeq (true,$(PRODUCT_ENFORCE_PACKAGES_EXIST))
1295      _allow_list := $(PRODUCT_ENFORCE_PACKAGES_EXIST_ALLOW_LIST)
1296      _modules := $(PRODUCT_PACKAGES)
1297      # Strip :32 and :64 suffixes
1298      _modules := $(patsubst %:32,%,$(_modules))
1299      _modules := $(patsubst %:64,%,$(_modules))
1300      # Quickly check all modules in PRODUCT_PACKAGES exist. We check for the
1301      # existence if either <module> or the <module>_32 variant.
1302      _nonexistent_modules := $(foreach m,$(_modules), \
1303        $(if $(or $(ALL_MODULES.$(m).PATH),$(call get-modules-for-2nd-arch,TARGET,$(m))),,$(m)))
1304      $(call maybe-print-list-and-error,$(filter-out $(_allow_list),$(_nonexistent_modules)),\
1305        $(INTERNAL_PRODUCT) includes non-existent modules in PRODUCT_PACKAGES)
1306      # TODO(b/182105280): Consider re-enabling this check when the ART modules
1307      # have been cleaned up from the allowed_list in target/product/generic.mk.
1308      #$(call maybe-print-list-and-error,$(filter-out $(_nonexistent_modules),$(_allow_list)),\
1309      #  $(INTERNAL_PRODUCT) includes redundant allow list entries for non-existent PRODUCT_PACKAGES)
1310    endif
1311
1312    # Check to ensure that all modules in PRODUCT_HOST_PACKAGES exist
1313    #
1314    # Many host modules are Linux-only, so skip this check on Mac. If we ever have Mac-only modules,
1315    # maybe it would make sense to have PRODUCT_HOST_PACKAGES_LINUX/_DARWIN?
1316    ifneq ($(HOST_OS),darwin)
1317      _modules := $(PRODUCT_HOST_PACKAGES)
1318      # Strip :32 and :64 suffixes
1319      _modules := $(patsubst %:32,%,$(_modules))
1320      _modules := $(patsubst %:64,%,$(_modules))
1321      _nonexistent_modules := $(foreach m,$(_modules),\
1322        $(if $(ALL_MODULES.$(m).REQUIRED_FROM_HOST)$(filter $(HOST_OUT_ROOT)/%,$(ALL_MODULES.$(m).INSTALLED)),,$(m)))
1323      $(call maybe-print-list-and-error,$(_nonexistent_modules),\
1324        $(INTERNAL_PRODUCT) includes non-existent modules in PRODUCT_HOST_PACKAGES)
1325    endif
1326  endif
1327
1328  # Modules may produce only host installed files in unbundled builds.
1329  ifeq (,$(TARGET_BUILD_UNBUNDLED))
1330    _modules := $(call resolve-bitness-for-modules,TARGET, \
1331      $(PRODUCT_PACKAGES) \
1332      $(PRODUCT_PACKAGES_DEBUG) \
1333      $(PRODUCT_PACKAGES_DEBUG_ASAN) \
1334      $(PRODUCT_PACKAGES_ENG) \
1335      $(PRODUCT_PACKAGES_TESTS))
1336    _host_modules := $(foreach m,$(_modules), \
1337                  $(if $(ALL_MODULES.$(m).INSTALLED),\
1338                    $(if $(filter-out $(HOST_OUT_ROOT)/%,$(ALL_MODULES.$(m).INSTALLED)),,\
1339                      $(m))))
1340    $(call maybe-print-list-and-error,$(sort $(_host_modules)),\
1341      Host modules should be in PRODUCT_HOST_PACKAGES$(comma) not PRODUCT_PACKAGES)
1342  endif
1343
1344  product_host_FILES := $(call host-installed-files,$(INTERNAL_PRODUCT))
1345  product_target_FILES := $(call product-installed-files, $(INTERNAL_PRODUCT))
1346  # WARNING: The product_MODULES variable is depended on by external files.
1347  product_MODULES := $(_pif_modules)
1348
1349  # Verify the artifact path requirements made by included products.
1350  is_asan := $(if $(filter address,$(SANITIZE_TARGET)),true)
1351  ifeq (,$(or $(is_asan),$(DISABLE_ARTIFACT_PATH_REQUIREMENTS)))
1352    include $(BUILD_SYSTEM)/artifact_path_requirements.mk
1353  endif
1354else
1355  # We're not doing a full build, and are probably only including
1356  # a subset of the module makefiles.  Don't try to build any modules
1357  # requested by the product, because we probably won't have rules
1358  # to build them.
1359  product_target_FILES :=
1360  product_host_FILES :=
1361endif
1362
1363# TODO: Remove the 3 places in the tree that use ALL_DEFAULT_INSTALLED_MODULES
1364# and get rid of it from this list.
1365modules_to_install := $(sort \
1366    $(ALL_DEFAULT_INSTALLED_MODULES) \
1367    $(product_target_FILES) \
1368    $(product_host_FILES) \
1369    $(CUSTOM_MODULES) \
1370  )
1371
1372ifdef FULL_BUILD
1373#
1374# Used by the cleanup logic in soong_ui to remove files that should no longer
1375# be installed.
1376#
1377
1378# Include all tests, so that we remove them from the test suites / testcase
1379# folders when they are removed.
1380test_files := $(foreach ts,$(ALL_COMPATIBILITY_SUITES),$(COMPATIBILITY.$(ts).FILES))
1381
1382$(shell mkdir -p $(PRODUCT_OUT) $(HOST_OUT))
1383
1384$(file >$(PRODUCT_OUT)/.installable_files$(if $(filter address,$(SANITIZE_TARGET)),_asan), \
1385  $(sort $(patsubst $(PRODUCT_OUT)/%,%,$(filter $(PRODUCT_OUT)/%, \
1386    $(modules_to_install) $(test_files)))))
1387
1388$(file >$(HOST_OUT)/.installable_test_files,$(sort \
1389  $(patsubst $(HOST_OUT)/%,%,$(filter $(HOST_OUT)/%, \
1390    $(test_files)))))
1391
1392test_files :=
1393endif
1394
1395# Dedpulicate compatibility suite dist files across modules and packages before
1396# copying them to their requested locations. Assign the eval result to an unused
1397# var to prevent Make from trying to make a sense of it.
1398_unused := $(call copy-many-files, $(sort $(ALL_COMPATIBILITY_DIST_FILES)))
1399
1400# Don't include any GNU General Public License shared objects or static
1401# libraries in SDK images.  GPL executables (not static/dynamic libraries)
1402# are okay if they don't link against any closed source libraries (directly
1403# or indirectly)
1404
1405# It's ok (and necessary) to build the host tools, but nothing that's
1406# going to be installed on the target (including static libraries).
1407
1408ifdef is_sdk_build
1409  target_gnu_MODULES := \
1410              $(filter \
1411                      $(TARGET_OUT_INTERMEDIATES)/% \
1412                      $(TARGET_OUT)/% \
1413                      $(TARGET_OUT_DATA)/%, \
1414                              $(sort $(call get-tagged-modules,gnu)))
1415  target_gnu_MODULES := $(filter-out $(TARGET_OUT_EXECUTABLES)/%,$(target_gnu_MODULES))
1416  target_gnu_MODULES := $(filter-out %/libopenjdkjvmti.so,$(target_gnu_MODULES))
1417  target_gnu_MODULES := $(filter-out %/libopenjdkjvmtid.so,$(target_gnu_MODULES))
1418  $(info Removing from sdk:)$(foreach d,$(target_gnu_MODULES),$(info : $(d)))
1419  modules_to_install := \
1420              $(filter-out $(target_gnu_MODULES),$(modules_to_install))
1421
1422  # Ensure every module listed in PRODUCT_PACKAGES* gets something installed
1423  # TODO: Should we do this for all builds and not just the sdk?
1424  dangling_modules :=
1425  $(foreach m, $(PRODUCT_PACKAGES), \
1426    $(if $(strip $(ALL_MODULES.$(m).INSTALLED) $(ALL_MODULES.$(m)$(TARGET_2ND_ARCH_MODULE_SUFFIX).INSTALLED)),,\
1427      $(eval dangling_modules += $(m))))
1428  ifneq ($(dangling_modules),)
1429    $(warning: Modules '$(dangling_modules)' in PRODUCT_PACKAGES have nothing to install!)
1430  endif
1431  $(foreach m, $(PRODUCT_PACKAGES_DEBUG), \
1432    $(if $(strip $(ALL_MODULES.$(m).INSTALLED)),,\
1433      $(warning $(ALL_MODULES.$(m).MAKEFILE): Module '$(m)' in PRODUCT_PACKAGES_DEBUG has nothing to install!)))
1434  $(foreach m, $(PRODUCT_PACKAGES_ENG), \
1435    $(if $(strip $(ALL_MODULES.$(m).INSTALLED)),,\
1436      $(warning $(ALL_MODULES.$(m).MAKEFILE): Module '$(m)' in PRODUCT_PACKAGES_ENG has nothing to install!)))
1437  $(foreach m, $(PRODUCT_PACKAGES_TESTS), \
1438    $(if $(strip $(ALL_MODULES.$(m).INSTALLED)),,\
1439      $(warning $(ALL_MODULES.$(m).MAKEFILE): Module '$(m)' in PRODUCT_PACKAGES_TESTS has nothing to install!)))
1440endif
1441
1442# build/make/core/Makefile contains extra stuff that we don't want to pollute this
1443# top-level makefile with.  It expects that ALL_DEFAULT_INSTALLED_MODULES
1444# contains everything that's built during the current make, but it also further
1445# extends ALL_DEFAULT_INSTALLED_MODULES.
1446ALL_DEFAULT_INSTALLED_MODULES := $(modules_to_install)
1447ifeq ($(HOST_OS),linux)
1448  include $(BUILD_SYSTEM)/Makefile
1449endif
1450modules_to_install := $(sort $(ALL_DEFAULT_INSTALLED_MODULES))
1451ALL_DEFAULT_INSTALLED_MODULES :=
1452
1453
1454# Some notice deps refer to module names without prefix or arch suffix where
1455# only the variants with them get built.
1456# fix-notice-deps replaces those unadorned module names with every built variant.
1457$(call fix-notice-deps)
1458
1459# These are additional goals that we build, in order to make sure that there
1460# is as little code as possible in the tree that doesn't build.
1461modules_to_check := $(foreach m,$(ALL_MODULES),$(ALL_MODULES.$(m).CHECKED))
1462
1463# If you would like to build all goals, and not skip any intermediate
1464# steps, you can pass the "all" modifier goal on the commandline.
1465ifneq ($(filter all,$(MAKECMDGOALS)),)
1466modules_to_check += $(foreach m,$(ALL_MODULES),$(ALL_MODULES.$(m).BUILT))
1467endif
1468
1469# Build docs as part of checkbuild to catch more breakages.
1470modules_to_check += $(ALL_DOCS)
1471
1472# for easier debugging
1473modules_to_check := $(sort $(modules_to_check))
1474#$(error modules_to_check $(modules_to_check))
1475
1476# -------------------------------------------------------------------
1477# This is used to to get the ordering right, you can also use these,
1478# but they're considered undocumented, so don't complain if their
1479# behavior changes.
1480# An internal target that depends on all copied headers
1481# (see copy_headers.make).  Other targets that need the
1482# headers to be copied first can depend on this target.
1483.PHONY: all_copied_headers
1484all_copied_headers: ;
1485
1486$(ALL_C_CPP_ETC_OBJECTS): | all_copied_headers
1487
1488# All the droid stuff, in directories
1489.PHONY: files
1490files: $(modules_to_install) \
1491       $(INSTALLED_ANDROID_INFO_TXT_TARGET)
1492
1493# -------------------------------------------------------------------
1494
1495.PHONY: checkbuild
1496checkbuild: $(modules_to_check) droid_targets check-elf-files
1497
1498ifeq (true,$(ANDROID_BUILD_EVERYTHING_BY_DEFAULT))
1499droid: checkbuild
1500endif
1501
1502.PHONY: ramdisk
1503ramdisk: $(INSTALLED_RAMDISK_TARGET)
1504
1505.PHONY: ramdisk_debug
1506ramdisk_debug: $(INSTALLED_DEBUG_RAMDISK_TARGET)
1507
1508.PHONY: ramdisk_test_harness
1509ramdisk_test_harness: $(INSTALLED_TEST_HARNESS_RAMDISK_TARGET)
1510
1511.PHONY: userdataimage
1512userdataimage: $(INSTALLED_USERDATAIMAGE_TARGET)
1513
1514ifneq (,$(filter userdataimage, $(MAKECMDGOALS)))
1515$(call dist-for-goals, userdataimage, $(BUILT_USERDATAIMAGE_TARGET))
1516endif
1517
1518.PHONY: cacheimage
1519cacheimage: $(INSTALLED_CACHEIMAGE_TARGET)
1520
1521.PHONY: bptimage
1522bptimage: $(INSTALLED_BPTIMAGE_TARGET)
1523
1524.PHONY: vendorimage
1525vendorimage: $(INSTALLED_VENDORIMAGE_TARGET)
1526
1527.PHONY: vendorbootimage
1528vendorbootimage: $(INSTALLED_VENDOR_BOOTIMAGE_TARGET)
1529
1530.PHONY: vendorkernelbootimage
1531vendorkernelbootimage: $(INSTALLED_VENDOR_KERNEL_BOOTIMAGE_TARGET)
1532
1533.PHONY: vendorbootimage_debug
1534vendorbootimage_debug: $(INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET)
1535
1536.PHONY: vendorbootimage_test_harness
1537vendorbootimage_test_harness: $(INSTALLED_VENDOR_TEST_HARNESS_BOOTIMAGE_TARGET)
1538
1539.PHONY: vendorramdisk
1540vendorramdisk: $(INSTALLED_VENDOR_RAMDISK_TARGET)
1541
1542.PHONY: vendorkernelramdisk
1543vendorkernelramdisk: $(INSTALLED_VENDOR_KERNEL_RAMDISK_TARGET)
1544
1545.PHONY: vendorramdisk_debug
1546vendorramdisk_debug: $(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET)
1547
1548.PHONY: vendorramdisk_test_harness
1549vendorramdisk_test_harness: $(INSTALLED_VENDOR_TEST_HARNESS_RAMDISK_TARGET)
1550
1551.PHONY: productimage
1552productimage: $(INSTALLED_PRODUCTIMAGE_TARGET)
1553
1554.PHONY: systemextimage
1555systemextimage: $(INSTALLED_SYSTEM_EXTIMAGE_TARGET)
1556
1557.PHONY: odmimage
1558odmimage: $(INSTALLED_ODMIMAGE_TARGET)
1559
1560.PHONY: vendor_dlkmimage
1561vendor_dlkmimage: $(INSTALLED_VENDOR_DLKMIMAGE_TARGET)
1562
1563.PHONY: odm_dlkmimage
1564odm_dlkmimage: $(INSTALLED_ODM_DLKMIMAGE_TARGET)
1565
1566.PHONY: system_dlkmimage
1567system_dlkmimage: $(INSTALLED_SYSTEM_DLKMIMAGE_TARGET)
1568
1569.PHONY: systemotherimage
1570systemotherimage: $(INSTALLED_SYSTEMOTHERIMAGE_TARGET)
1571
1572.PHONY: superimage_empty
1573superimage_empty: $(INSTALLED_SUPERIMAGE_EMPTY_TARGET)
1574
1575.PHONY: bootimage
1576bootimage: $(INSTALLED_BOOTIMAGE_TARGET)
1577
1578.PHONY: initbootimage
1579initbootimage: $(INSTALLED_INIT_BOOT_IMAGE_TARGET)
1580
1581ifeq (true,$(PRODUCT_EXPORT_BOOT_IMAGE_TO_DIST))
1582$(call dist-for-goals, bootimage, $(INSTALLED_BOOTIMAGE_TARGET))
1583endif
1584
1585.PHONY: bootimage_debug
1586bootimage_debug: $(INSTALLED_DEBUG_BOOTIMAGE_TARGET)
1587
1588.PHONY: bootimage_test_harness
1589bootimage_test_harness: $(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET)
1590
1591.PHONY: vbmetaimage
1592vbmetaimage: $(INSTALLED_VBMETAIMAGE_TARGET)
1593
1594.PHONY: vbmetasystemimage
1595vbmetasystemimage: $(INSTALLED_VBMETA_SYSTEMIMAGE_TARGET)
1596
1597.PHONY: vbmetavendorimage
1598vbmetavendorimage: $(INSTALLED_VBMETA_VENDORIMAGE_TARGET)
1599
1600# The droidcore-unbundled target depends on the subset of targets necessary to
1601# perform a full system build (either unbundled or not).
1602.PHONY: droidcore-unbundled
1603droidcore-unbundled: $(filter $(HOST_OUT_ROOT)/%,$(modules_to_install)) \
1604    $(INSTALLED_FILES_OUTSIDE_IMAGES) \
1605    $(INSTALLED_SYSTEMIMAGE_TARGET) \
1606    $(INSTALLED_RAMDISK_TARGET) \
1607    $(INSTALLED_BOOTIMAGE_TARGET) \
1608    $(INSTALLED_INIT_BOOT_IMAGE_TARGET) \
1609    $(INSTALLED_RADIOIMAGE_TARGET) \
1610    $(INSTALLED_DEBUG_RAMDISK_TARGET) \
1611    $(INSTALLED_DEBUG_BOOTIMAGE_TARGET) \
1612    $(INSTALLED_RECOVERYIMAGE_TARGET) \
1613    $(INSTALLED_VBMETAIMAGE_TARGET) \
1614    $(INSTALLED_VBMETA_SYSTEMIMAGE_TARGET) \
1615    $(INSTALLED_VBMETA_VENDORIMAGE_TARGET) \
1616    $(INSTALLED_USERDATAIMAGE_TARGET) \
1617    $(INSTALLED_CACHEIMAGE_TARGET) \
1618    $(INSTALLED_BPTIMAGE_TARGET) \
1619    $(INSTALLED_VENDORIMAGE_TARGET) \
1620    $(INSTALLED_VENDOR_BOOTIMAGE_TARGET) \
1621    $(INSTALLED_VENDOR_KERNEL_BOOTIMAGE_TARGET) \
1622    $(INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET) \
1623    $(INSTALLED_VENDOR_TEST_HARNESS_RAMDISK_TARGET) \
1624    $(INSTALLED_VENDOR_TEST_HARNESS_BOOTIMAGE_TARGET) \
1625    $(INSTALLED_VENDOR_RAMDISK_TARGET) \
1626    $(INSTALLED_VENDOR_KERNEL_RAMDISK_TARGET) \
1627    $(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET) \
1628    $(INSTALLED_ODMIMAGE_TARGET) \
1629    $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) \
1630    $(INSTALLED_ODM_DLKMIMAGE_TARGET) \
1631    $(INSTALLED_SYSTEM_DLKMIMAGE_TARGET) \
1632    $(INSTALLED_SUPERIMAGE_EMPTY_TARGET) \
1633    $(INSTALLED_PRODUCTIMAGE_TARGET) \
1634    $(INSTALLED_SYSTEMOTHERIMAGE_TARGET) \
1635    $(INSTALLED_TEST_HARNESS_RAMDISK_TARGET) \
1636    $(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET) \
1637    $(INSTALLED_FILES_FILE) \
1638    $(INSTALLED_FILES_JSON) \
1639    $(INSTALLED_FILES_FILE_VENDOR) \
1640    $(INSTALLED_FILES_JSON_VENDOR) \
1641    $(INSTALLED_FILES_FILE_ODM) \
1642    $(INSTALLED_FILES_JSON_ODM) \
1643    $(INSTALLED_FILES_FILE_VENDOR_DLKM) \
1644    $(INSTALLED_FILES_JSON_VENDOR_DLKM) \
1645    $(INSTALLED_FILES_FILE_ODM_DLKM) \
1646    $(INSTALLED_FILES_JSON_ODM_DLKM) \
1647    $(INSTALLED_FILES_FILE_SYSTEM_DLKM) \
1648    $(INSTALLED_FILES_JSON_SYSTEM_DLKM) \
1649    $(INSTALLED_FILES_FILE_PRODUCT) \
1650    $(INSTALLED_FILES_JSON_PRODUCT) \
1651    $(INSTALLED_FILES_FILE_SYSTEM_EXT) \
1652    $(INSTALLED_FILES_JSON_SYSTEM_EXT) \
1653    $(INSTALLED_FILES_FILE_SYSTEMOTHER) \
1654    $(INSTALLED_FILES_JSON_SYSTEMOTHER) \
1655    $(INSTALLED_FILES_FILE_RAMDISK) \
1656    $(INSTALLED_FILES_JSON_RAMDISK) \
1657    $(INSTALLED_FILES_FILE_DEBUG_RAMDISK) \
1658    $(INSTALLED_FILES_JSON_DEBUG_RAMDISK) \
1659    $(INSTALLED_FILES_FILE_VENDOR_RAMDISK) \
1660    $(INSTALLED_FILES_JSON_VENDOR_RAMDISK) \
1661    $(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK) \
1662    $(INSTALLED_FILES_JSON_VENDOR_DEBUG_RAMDISK) \
1663    $(INSTALLED_FILES_FILE_VENDOR_KERNEL_RAMDISK) \
1664    $(INSTALLED_FILES_JSON_VENDOR_KERNEL_RAMDISK) \
1665    $(INSTALLED_FILES_FILE_ROOT) \
1666    $(INSTALLED_FILES_JSON_ROOT) \
1667    $(INSTALLED_FILES_FILE_RECOVERY) \
1668    $(INSTALLED_FILES_JSON_RECOVERY) \
1669    $(INSTALLED_ANDROID_INFO_TXT_TARGET)
1670
1671# The droidcore target depends on the droidcore-unbundled subset and any other
1672# targets for a non-unbundled (full source) full system build.
1673.PHONY: droidcore
1674droidcore: droidcore-unbundled
1675
1676# dist_files only for putting your library into the dist directory with a full build.
1677.PHONY: dist_files
1678
1679ifeq ($(SOONG_COLLECT_JAVA_DEPS), true)
1680  $(call dist-for-goals, dist_files, $(SOONG_OUT_DIR)/module_bp_java_deps.json)
1681  $(call dist-for-goals, dist_files, $(PRODUCT_OUT)/module-info.json)
1682endif
1683
1684.PHONY: apps_only
1685ifeq ($(HOST_OS),darwin)
1686  # Mac only supports building host modules
1687  droid_targets: $(filter $(HOST_OUT_ROOT)/%,$(modules_to_install)) dist_files
1688
1689else ifneq ($(TARGET_BUILD_APPS),)
1690  # If this build is just for apps, only build apps and not the full system by default.
1691
1692  unbundled_build_modules :=
1693  ifneq ($(filter all,$(TARGET_BUILD_APPS)),)
1694    # If they used the magic goal "all" then build all apps in the source tree.
1695    unbundled_build_modules := $(foreach m,$(sort $(ALL_MODULES)),$(if $(filter APPS,$(ALL_MODULES.$(m).CLASS)),$(m)))
1696  else
1697    unbundled_build_modules := $(TARGET_BUILD_APPS)
1698  endif
1699
1700  # Dist the installed files if they exist.
1701  apps_only_installed_files := $(foreach m,$(unbundled_build_modules),$(ALL_MODULES.$(m).INSTALLED))
1702  $(call dist-for-goals,apps_only, $(apps_only_installed_files))
1703
1704  # Dist the bundle files if they exist.
1705  apps_only_bundle_files := $(foreach m,$(unbundled_build_modules),\
1706    $(if $(ALL_MODULES.$(m).BUNDLE),$(ALL_MODULES.$(m).BUNDLE):$(m)-base.zip))
1707  $(call dist-for-goals,apps_only, $(apps_only_bundle_files))
1708
1709  # Dist the lint reports if they exist.
1710  apps_only_lint_report_files := $(foreach m,$(unbundled_build_modules),\
1711    $(foreach report,$(ALL_MODULES.$(m).LINT_REPORTS),\
1712      $(report):$(m)-$(notdir $(report))))
1713  .PHONY: lint-check
1714  lint-check: $(foreach f, $(apps_only_lint_report_files), $(call word-colon,1,$(f)))
1715  $(call dist-for-goals,lint-check, $(apps_only_lint_report_files))
1716
1717  # For uninstallable modules such as static Java library, we have to dist the built file,
1718  # as <module_name>.<suffix>
1719  apps_only_dist_built_files := $(foreach m,$(unbundled_build_modules),$(if $(ALL_MODULES.$(m).INSTALLED),,\
1720      $(if $(ALL_MODULES.$(m).BUILT),$(ALL_MODULES.$(m).BUILT):$(m)$(suffix $(ALL_MODULES.$(m).BUILT)))\
1721      $(if $(ALL_MODULES.$(m).AAR),$(ALL_MODULES.$(m).AAR):$(m).aar)\
1722      ))
1723  $(call dist-for-goals,apps_only, $(apps_only_dist_built_files))
1724
1725  ifeq ($(EMMA_INSTRUMENT),true)
1726    $(JACOCO_REPORT_CLASSES_ALL) : $(apps_only_installed_files)
1727    $(call dist-for-goals,apps_only, $(JACOCO_REPORT_CLASSES_ALL))
1728  endif
1729
1730  $(PROGUARD_DICT_ZIP) : $(apps_only_installed_files)
1731  $(call dist-for-goals,apps_only, $(PROGUARD_DICT_ZIP) $(PROGUARD_DICT_MAPPING))
1732  $(call declare-container-license-deps,$(PROGUARD_DICT_ZIP),$(apps_only_installed_files),$(PRODUCT_OUT)/:/)
1733
1734  $(PROGUARD_USAGE_ZIP) : $(apps_only_installed_files)
1735  $(call dist-for-goals,apps_only, $(PROGUARD_USAGE_ZIP))
1736  $(call declare-container-license-deps,$(PROGUARD_USAGE_ZIP),$(apps_only_installed_files),$(PRODUCT_OUT)/:/)
1737
1738  $(SYMBOLS_ZIP) : $(apps_only_installed_files)
1739  $(call dist-for-goals,apps_only, $(SYMBOLS_ZIP) $(SYMBOLS_MAPPING))
1740  $(call declare-container-license-deps,$(SYMBOLS_ZIP),$(apps_only_installed_files),$(PRODUCT_OUT)/:/)
1741
1742  $(COVERAGE_ZIP) : $(apps_only_installed_files)
1743  $(call dist-for-goals,apps_only, $(COVERAGE_ZIP))
1744  $(call declare-container-license-deps,$(COVERAGE_ZIP),$(apps_only_installed_files),$(PRODUCT_OUT)/:/)
1745
1746apps_only: $(unbundled_build_modules)
1747
1748droid_targets: apps_only
1749
1750# NOTICE files for a apps_only build
1751$(eval $(call html-notice-rule,$(target_notice_file_html_or_xml),"Apps","Notices for files for apps:",$(unbundled_build_modules),$(PRODUCT_OUT)/ $(HOST_OUT)/))
1752
1753$(eval $(call text-notice-rule,$(target_notice_file_txt),"Apps","Notices for files for apps:",$(unbundled_build_modules),$(PRODUCT_OUT)/ $(HOST_OUT)/))
1754
1755$(call declare-0p-target,$(target_notice_file_txt))
1756$(call declare-0p-target,$(target_notice_html_or_xml))
1757
1758
1759else ifeq ($(TARGET_BUILD_UNBUNDLED),$(TARGET_BUILD_UNBUNDLED_IMAGE))
1760
1761  # Truth table for entering this block of code:
1762  # TARGET_BUILD_UNBUNDLED | TARGET_BUILD_UNBUNDLED_IMAGE | Action
1763  # -----------------------|------------------------------|-------------------------
1764  # not set                | not set                      | droidcore path
1765  # not set                | true                         | invalid
1766  # true                   | not set                      | skip
1767  # true                   | true                         | droidcore-unbundled path
1768
1769  # We dist the following targets only for droidcore full build. These items
1770  # can include java-related targets that would cause building framework java
1771  # sources in a droidcore full build.
1772
1773  $(call dist-for-goals, droidcore, \
1774    $(BUILT_OTATOOLS_PACKAGE) \
1775    $(APPCOMPAT_ZIP) \
1776    $(DEXPREOPT_TOOLS_ZIP) \
1777  )
1778
1779  # We dist the following targets for droidcore-unbundled (and droidcore since
1780  # droidcore depends on droidcore-unbundled). The droidcore-unbundled target
1781  # is a subset of droidcore. It can be used used for an unbundled build to
1782  # avoid disting targets that would cause building framework java sources,
1783  # which we want to avoid in an unbundled build.
1784
1785  $(call dist-for-goals, droidcore-unbundled, \
1786    $(INTERNAL_UPDATE_PACKAGE_TARGET) \
1787    $(INTERNAL_OTA_PACKAGE_TARGET) \
1788    $(INTERNAL_OTA_METADATA) \
1789    $(INTERNAL_OTA_PARTIAL_PACKAGE_TARGET) \
1790    $(INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET) \
1791    $(SYMBOLS_ZIP) \
1792    $(SYMBOLS_MAPPING) \
1793    $(PROGUARD_DICT_ZIP) \
1794    $(PROGUARD_DICT_MAPPING) \
1795    $(PROGUARD_USAGE_ZIP) \
1796    $(COVERAGE_ZIP) \
1797    $(INSTALLED_FILES_FILE) \
1798    $(INSTALLED_FILES_JSON) \
1799    $(INSTALLED_FILES_FILE_VENDOR) \
1800    $(INSTALLED_FILES_JSON_VENDOR) \
1801    $(INSTALLED_FILES_FILE_ODM) \
1802    $(INSTALLED_FILES_JSON_ODM) \
1803    $(INSTALLED_FILES_FILE_VENDOR_DLKM) \
1804    $(INSTALLED_FILES_JSON_VENDOR_DLKM) \
1805    $(INSTALLED_FILES_FILE_ODM_DLKM) \
1806    $(INSTALLED_FILES_JSON_ODM_DLKM) \
1807    $(INSTALLED_FILES_FILE_SYSTEM_DLKM) \
1808    $(INSTALLED_FILES_JSON_SYSTEM_DLKM) \
1809    $(INSTALLED_FILES_FILE_PRODUCT) \
1810    $(INSTALLED_FILES_JSON_PRODUCT) \
1811    $(INSTALLED_FILES_FILE_SYSTEM_EXT) \
1812    $(INSTALLED_FILES_JSON_SYSTEM_EXT) \
1813    $(INSTALLED_FILES_FILE_SYSTEMOTHER) \
1814    $(INSTALLED_FILES_JSON_SYSTEMOTHER) \
1815    $(INSTALLED_FILES_FILE_RECOVERY) \
1816    $(INSTALLED_FILES_JSON_RECOVERY) \
1817    $(INSTALLED_BUILD_PROP_TARGET):build.prop \
1818    $(INSTALLED_VENDOR_BUILD_PROP_TARGET):build.prop-vendor \
1819    $(INSTALLED_PRODUCT_BUILD_PROP_TARGET):build.prop-product \
1820    $(INSTALLED_ODM_BUILD_PROP_TARGET):build.prop-odm \
1821    $(INSTALLED_SYSTEM_EXT_BUILD_PROP_TARGET):build.prop-system_ext \
1822    $(INSTALLED_RAMDISK_BUILD_PROP_TARGET):build.prop-ramdisk \
1823    $(BUILT_TARGET_FILES_PACKAGE) \
1824    $(INSTALLED_ANDROID_INFO_TXT_TARGET) \
1825    $(INSTALLED_MISC_INFO_TARGET) \
1826    $(INSTALLED_RAMDISK_TARGET) \
1827    $(DEXPREOPT_CONFIG_ZIP) \
1828  )
1829
1830  # Put a copy of the radio/bootloader files in the dist dir.
1831  $(foreach f,$(INSTALLED_RADIOIMAGE_TARGET), \
1832    $(call dist-for-goals, droidcore-unbundled, $(f)))
1833
1834  ifneq ($(ANDROID_BUILD_EMBEDDED),true)
1835    $(call dist-for-goals, droidcore, \
1836      $(APPS_ZIP) \
1837      $(INTERNAL_EMULATOR_PACKAGE_TARGET) \
1838    )
1839  endif
1840
1841  $(call dist-for-goals, droidcore-unbundled, \
1842    $(INSTALLED_FILES_FILE_ROOT) \
1843    $(INSTALLED_FILES_JSON_ROOT) \
1844  )
1845
1846  ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
1847    $(call dist-for-goals, droidcore-unbundled, \
1848      $(INSTALLED_FILES_FILE_RAMDISK) \
1849      $(INSTALLED_FILES_JSON_RAMDISK) \
1850      $(INSTALLED_FILES_FILE_DEBUG_RAMDISK) \
1851      $(INSTALLED_FILES_JSON_DEBUG_RAMDISK) \
1852      $(INSTALLED_FILES_FILE_VENDOR_RAMDISK) \
1853      $(INSTALLED_FILES_JSON_VENDOR_RAMDISK) \
1854      $(INSTALLED_FILES_FILE_VENDOR_KERNEL_RAMDISK) \
1855      $(INSTALLED_FILES_JSON_VENDOR_KERNEL_RAMDISK) \
1856      $(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK) \
1857      $(INSTALLED_FILES_JSON_VENDOR_DEBUG_RAMDISK) \
1858      $(INSTALLED_DEBUG_RAMDISK_TARGET) \
1859      $(INSTALLED_DEBUG_BOOTIMAGE_TARGET) \
1860      $(INSTALLED_TEST_HARNESS_RAMDISK_TARGET) \
1861      $(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET) \
1862      $(INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET) \
1863      $(INSTALLED_VENDOR_TEST_HARNESS_RAMDISK_TARGET) \
1864      $(INSTALLED_VENDOR_TEST_HARNESS_BOOTIMAGE_TARGET) \
1865      $(INSTALLED_VENDOR_RAMDISK_TARGET) \
1866      $(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET) \
1867      $(INSTALLED_VENDOR_KERNEL_RAMDISK_TARGET) \
1868    )
1869  endif
1870
1871  ifeq ($(PRODUCT_EXPORT_BOOT_IMAGE_TO_DIST),true)
1872    $(call dist-for-goals, droidcore-unbundled, $(INSTALLED_BOOTIMAGE_TARGET))
1873  endif
1874
1875  ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
1876    $(call dist-for-goals, droidcore-unbundled, \
1877      $(recovery_ramdisk) \
1878    )
1879  endif
1880
1881  ifeq ($(EMMA_INSTRUMENT),true)
1882    $(call dist-for-goals, dist_files, $(JACOCO_REPORT_CLASSES_ALL))
1883  endif
1884
1885  # Put XML formatted API files in the dist dir.
1886  $(TARGET_OUT_COMMON_INTERMEDIATES)/api.xml: $(call java-lib-files,android_stubs_current) $(APICHECK)
1887  $(TARGET_OUT_COMMON_INTERMEDIATES)/system-api.xml: $(call java-lib-files,android_system_stubs_current) $(APICHECK)
1888  $(TARGET_OUT_COMMON_INTERMEDIATES)/module-lib-api.xml: $(call java-lib-files,android_module_lib_stubs_current) $(APICHECK)
1889  $(TARGET_OUT_COMMON_INTERMEDIATES)/system-server-api.xml: $(call java-lib-files,android_system_server_stubs_current) $(APICHECK)
1890  $(TARGET_OUT_COMMON_INTERMEDIATES)/test-api.xml: $(call java-lib-files,android_test_stubs_current) $(APICHECK)
1891
1892  api_xmls := $(addprefix $(TARGET_OUT_COMMON_INTERMEDIATES)/,api.xml system-api.xml module-lib-api.xml system-server-api.xml test-api.xml)
1893  $(api_xmls):
1894	$(hide) echo "Converting API file to XML: $@"
1895	$(hide) mkdir -p $(dir $@)
1896	$(hide) $(APICHECK_COMMAND) --input-api-jar $< --api-xml $@
1897
1898  $(foreach xml,$(sort $(api_xmls)),$(call declare-1p-target,$(xml),))
1899
1900  $(call dist-for-goals, dist_files, $(api_xmls))
1901  api_xmls :=
1902
1903  ifdef CLANG_COVERAGE
1904    $(foreach f,$(SOONG_NDK_API_XML), \
1905        $(call dist-for-goals,droidcore,$(f):ndk_apis/$(notdir $(f))))
1906    $(foreach f,$(SOONG_CC_API_XML), \
1907        $(call dist-for-goals,droidcore,$(f):cc_apis/$(notdir $(f))))
1908  endif
1909
1910  # For full system build (whether unbundled or not), we configure
1911  # droid_targets to depend on droidcore-unbundled, which will set up the full
1912  # system dependencies and also dist the subset of targets that correspond to
1913  # an unbundled build (exclude building some framework sources).
1914
1915  droid_targets: droidcore-unbundled
1916
1917  ifeq (,$(TARGET_BUILD_UNBUNDLED_IMAGE))
1918
1919    # If we're building a full system (including the framework sources excluded
1920    # by droidcore-unbundled), we configure droid_targets also to depend on
1921    # droidcore, which includes all dist for droidcore, and will build the
1922    # necessary framework sources.
1923
1924    droid_targets: droidcore dist_files
1925
1926  endif
1927
1928endif # TARGET_BUILD_UNBUNDLED == TARGET_BUILD_UNBUNDLED_IMAGE
1929
1930.PHONY: docs
1931docs: $(ALL_DOCS)
1932
1933.PHONY: sdk sdk_addon
1934ifeq ($(HOST_OS),linux)
1935ALL_SDK_TARGETS := $(INTERNAL_SDK_TARGET)
1936sdk: $(ALL_SDK_TARGETS)
1937$(call dist-for-goals,sdk, \
1938    $(ALL_SDK_TARGETS) \
1939    $(INSTALLED_BUILD_PROP_TARGET) \
1940)
1941endif
1942
1943# umbrella targets to assit engineers in verifying builds
1944.PHONY: java native target host java-host java-target native-host native-target \
1945        java-host-tests java-target-tests native-host-tests native-target-tests \
1946        java-tests native-tests host-tests target-tests tests java-dex \
1947        native-host-cross
1948# some synonyms
1949.PHONY: host-java target-java host-native target-native \
1950        target-java-tests target-native-tests
1951host-java : java-host
1952target-java : java-target
1953host-native : native-host
1954target-native : native-target
1955target-java-tests : java-target-tests
1956target-native-tests : native-target-tests
1957tests : host-tests target-tests
1958
1959# Phony target to run all java compilations that use javac
1960.PHONY: javac-check
1961
1962.PHONY: findbugs
1963findbugs: $(INTERNAL_FINDBUGS_HTML_TARGET) $(INTERNAL_FINDBUGS_XML_TARGET)
1964
1965LSDUMP_PATHS_FILE := $(PRODUCT_OUT)/lsdump_paths.txt
1966
1967.PHONY: findlsdumps
1968# LSDUMP_PATHS is a list of tag:path.
1969findlsdumps: $(LSDUMP_PATHS_FILE) $(foreach p,$(LSDUMP_PATHS),$(call word-colon,2,$(p)))
1970
1971$(LSDUMP_PATHS_FILE): PRIVATE_LSDUMP_PATHS := $(LSDUMP_PATHS)
1972$(LSDUMP_PATHS_FILE):
1973	@echo "Generate $@"
1974	@rm -rf $@ && echo -e "$(subst :,:$(space),$(subst $(space),\n,$(PRIVATE_LSDUMP_PATHS)))" > $@
1975
1976.PHONY: check-elf-files
1977check-elf-files:
1978
1979#xxx scrape this from ALL_MODULE_NAME_TAGS
1980.PHONY: modules
1981modules:
1982	@echo "Available sub-modules:"
1983	@echo "$(call module-names-for-tag-list,$(ALL_MODULE_TAGS))" | \
1984	      tr -s ' ' '\n' | sort -u
1985
1986.PHONY: dump-files
1987dump-files:
1988	@echo "Target files for $(TARGET_PRODUCT)-$(TARGET_BUILD_VARIANT) ($(INTERNAL_PRODUCT)):"
1989	@echo $(sort $(patsubst $(PRODUCT_OUT)/%,%,$(filter $(PRODUCT_OUT)/%,$(modules_to_install)))) | tr -s ' ' '\n'
1990	@echo Successfully dumped product target file list.
1991
1992.PHONY: nothing
1993nothing:
1994	@echo Successfully read the makefiles.
1995
1996.PHONY: tidy_only
1997tidy_only:
1998	@echo Successfully make tidy_only.
1999
2000ndk: $(SOONG_OUT_DIR)/ndk.timestamp
2001.PHONY: ndk
2002
2003# Checks that allowed_deps.txt remains up to date
2004ifneq ($(UNSAFE_DISABLE_APEX_ALLOWED_DEPS_CHECK),true)
2005  droidcore: ${APEX_ALLOWED_DEPS_CHECK}
2006endif
2007
2008# Create a license metadata rule per module. Could happen in base_rules.mk or
2009# notice_files.mk; except, it has to happen after fix-notice-deps to avoid
2010# missing dependency errors.
2011$(call build-license-metadata)
2012
2013$(call dist-write-file,$(KATI_PACKAGE_MK_DIR)/dist.mk)
2014
2015$(info [$(call inc_and_print,subdir_makefiles_inc)/$(subdir_makefiles_total)] writing build rules ...)
2016