123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229 |
……tags_to_install :=ifneq (,$(user_variant))….. ifeq ($(user_variant),userdebug) tags_to_install += debug else … endifendififeq ($(TARGET_BUILD_VARIANT),eng)tags_to_install := debug eng…endififeq ($(TARGET_BUILD_VARIANT),tests)tags_to_install := debug eng testsendififdef is_sdk_buildtags_to_install := debug engelse # !sdkendif……# ------------------------------------------------------------# Define a function that, given a list of module tags, returns# non-empty if that module should be installed in /system. # For most goals, anything not tagged with the "tests" tag should# be installed in /system.define should-install-to-system$(if $(filter tests,$(1)),,true)endefifdef is_sdk_build# For the sdk goal, anything with the "samples" tag should be# installed in /data even if that module also has "eng"/"debug"/"user".define should-install-to-system$(if $(filter samples tests,$(1)),,true)endefendif…#接下來根據配置計算要尋找的subdirs目錄ifneq ($(dont_bother),true)…ifeq ($(SDK_ONLY),true)include $(TOPDIR)sdk/build/sdk_only_whitelist.mkinclude $(TOPDIR)development/build/sdk_only_whitelist.mk# Exclude tools/acp when cross-compiling windows under linuxifeq ($(findstring Linux,$(UNAME)),)subdirs += build/tools/acpendif else# !SDK_ONLYifeq ($(BUILD_TINY_ANDROID), true)subdirs := bionic system/core system/extras/ext4_utils system/extras/su build/libs build/target build/tools/acp external/gcc-demangle external/mksh external/openssl external/yaffs2 external/zlibelse# !BUILD_TINY_ANDROIDsubdirs := $(TOP) FULL_BUILD := trueendif# !BUILD_TINY_ANDROIDendif# Before we go and include all of the module makefiles, stash away# the PRODUCT_* values so that later we can verify they are not modified.stash_product_vars:=trueifeq ($(stash_product_vars),true) $(call stash-product-vars, __STASHED)endif….ifneq ($(ONE_SHOT_MAKEFILE),)include $(ONE_SHOT_MAKEFILE)CUSTOM_MODULES := $(sort $(call get-tagged-modules,$(ALL_MODULE_TAGS)))FULL_BUILD :=…else # ONE_SHOT_MAKEFILE## Include all of the makefiles in the system# # Can‘t use first-makefiles-under here because# --mindepth=2 makes the prunes not work.subdir_makefiles := $(shell build/tools/findleaves.py --prune=out --prune=.repo --prune=.git $(subdirs) Android.mk) include $(subdir_makefiles) endif # ONE_SHOT_MAKEFILE……ifeq ($(stash_product_vars),true) $(call assert-product-vars, __STASHED)endif…# -------------------------------------------------------------------# Fix up CUSTOM_MODULES to refer to installed files rather than# just bare module names. Leave unknown modules alone in case# they‘re actually full paths to a particular file.known_custom_modules := $(filter $(ALL_MODULES),$(CUSTOM_MODULES))unknown_custom_modules := $(filter-out $(ALL_MODULES),$(CUSTOM_MODULES))CUSTOM_MODULES := $(call module-installed-files,$(known_custom_modules)) $(unknown_custom_modules# -------------------------------------------------------------------# Figure out our module sets.## Of the modules defined by the component makefiles,# determine what we actually want to build. ifdef FULL_BUILD # The base list of modules to build for this product is specified # by the appropriate product definition file, which was included # by product_config.make. product_MODULES := $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES) # Filter out the overridden packages before doing expansion product_MODULES := $(filter-out $(foreach p, $(product_MODULES), $(PACKAGES.$(p).OVERRIDES)), $(product_MODULES)) $(call expand-required-modules,product_MODULES,$(product_MODULES)) product_FILES := $(call module-installed-files, $(product_MODULES)) ifeq (0,1) $(info product_FILES for $(TARGET_DEVICE) ($(INTERNAL_PRODUCT)):) $(foreach p,$(product_FILES),$(info : $(p))) $(error done) endifelse # We‘re not doing a full build, and are probably only including # a subset of the module makefiles. Don‘t try to build any modules # requested by the product, because we probably won‘t have rules # to build them. product_FILES :=endif# When modules are tagged with debug eng or tests, they are installed# for those variants regardless of what the product spec says.debug_MODULES := $(sort $(call get-tagged-modules,debug) $(call module-installed-files, $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES_DEBUG)) )eng_MODULES := $(sort $(call get-tagged-modules,eng) $(call module-installed-files, $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES_ENG)) )tests_MODULES := $(sort $(call get-tagged-modules,tests) $(call module-installed-files, $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES_TESTS)) )# TODO: Remove the 3 places in the tree that use ALL_DEFAULT_INSTALLED_MODULES# and get rid of it from this list.# TODO: The shell is chosen by magic. Do we still need this?modules_to_install := $(sort $(ALL_DEFAULT_INSTALLED_MODULES) $(product_FILES) $(foreach tag,$(tags_to_install),$($(tag)_MODULES)) $(call get-tagged-modules, shell_$(TARGET_SHELL)) $(CUSTOM_MODULES) )# Some packages may override others using LOCAL_OVERRIDES_PACKAGES.# Filter out (do not install) any overridden packages.overridden_packages := $(call get-package-overrides,$(modules_to_install))ifdef overridden_packages# old_modules_to_install := $(modules_to_install) modules_to_install := $(filter-out $(foreach p,$(overridden_packages),$(p) %/$(p).apk), $(modules_to_install))endif#$(error filtered out# $(filter-out $(modules_to_install),$(old_modules_to_install))) # Don‘t include any GNU targets in the SDK. It‘s ok (and necessary)# to build the host tools, but nothing that‘s going to be installed# on the target (including static libraries).ifdef is_sdk_build target_gnu_MODULES := $(filter $(TARGET_OUT_INTERMEDIATES)/% $(TARGET_OUT)/% $(TARGET_OUT_DATA)/%, $(sort $(call get-tagged-modules,gnu))) $(info Removing from sdk:)$(foreach d,$(target_gnu_MODULES),$(info : $(d))) modules_to_install := $(filter-out $(target_gnu_MODULES),$(modules_to_install)) # Ensure every module listed in PRODUCT_PACKAGES* gets something installed # TODO: Should we do this for all builds and not just the sdk? $(foreach m, $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES), $(if $(strip $(ALL_MODULES.$(m).INSTALLED)),, $(warning $(ALL_MODULES.$(m).MAKEFILE): Module ‘$(m)‘ in PRODUCT_PACKAGES has nothing to install!))) $(foreach m, $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES_DEBUG), $(if $(strip $(ALL_MODULES.$(m).INSTALLED)),, $(warning $(ALL_MODULES.$(m).MAKEFILE): Module ‘$(m)‘ in PRODUCT_PACKAGES_DEBUG has nothing to install!))) $(foreach m, $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES_ENG), $(if $(strip $(ALL_MODULES.$(m).INSTALLED)),, $(warning $(ALL_MODULES.$(m).MAKEFILE): Module ‘$(m)‘ in PRODUCT_PACKAGES_ENG has nothing to install!))) $(foreach m, $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES_TESTS), $(if $(strip $(ALL_MODULES.$(m).INSTALLED)),, $(warning $(ALL_MODULES.$(m).MAKEFILE): Module ‘$(m)‘ in PRODUCT_PACKAGES_TESTS has nothing to install!)))endif # Install all of the host modulesmodules_to_install += $(sort $(modules_to_install) $(ALL_HOST_INSTALLED_FILES)) # build/core/Makefile contains extra stuff that we don‘t want to pollute this# top-level makefile with. It expects that ALL_DEFAULT_INSTALLED_MODULES# contains everything that‘s built during the current make, but it also further# extends ALL_DEFAULT_INSTALLED_MODULES.ALL_DEFAULT_INSTALLED_MODULES := $(modules_to_install)include $(BUILD_SYSTEM)/Makefilemodules_to_install := $(sort $(ALL_DEFAULT_INSTALLED_MODULES))ALL_DEFAULT_INSTALLED_MODULES := endif # dont_bother# These are additional goals that we build, in order to make sure that there# is as little code as possible in the tree that doesn‘t build.modules_to_check := $(foreach m,$(ALL_MODULES),$(ALL_MODULES.$(m).CHECKED)) # If you would like to build all goals, and not skip any intermediate# steps, you can pass the "all" modifier goal on the commandline.ifneq ($(filter all,$(MAKECMDGOALS)),)modules_to_check += $(foreach m,$(ALL_MODULES),$(ALL_MODULES.$(m).BUILT))endif # for easier debuggingmodules_to_check := $(sort $(modules_to_check))#$(error modules_to_check $(modules_to_check)) |