1DEX_PREOPT_CONFIG := $(PRODUCT_OUT)/dexpreopt.config 2 3# The default value for LOCAL_DEX_PREOPT 4DEX_PREOPT_DEFAULT ?= true 5 6# The default filter for which files go into the system_other image (if it is 7# being used). To bundle everything one should set this to '%' 8SYSTEM_OTHER_ODEX_FILTER ?= \ 9 app/% \ 10 priv-app/% \ 11 product_services/app/% \ 12 product_services/priv-app/% \ 13 product/app/% \ 14 product/priv-app/% \ 15 16# The default values for pre-opting. To support the runtime module we ensure no dex files 17# get stripped. 18ifeq ($(PRODUCT_DEX_PREOPT_NEVER_ALLOW_STRIPPING),) 19 PRODUCT_DEX_PREOPT_NEVER_ALLOW_STRIPPING := true 20endif 21# Conditional to building on linux, as dex2oat currently does not work on darwin. 22ifeq ($(HOST_OS),linux) 23 ifeq (eng,$(TARGET_BUILD_VARIANT)) 24 # Don't strip for quick development turnarounds. 25 DEX_PREOPT_DEFAULT := nostripping 26 # For an eng build only pre-opt the boot image and system server. This gives reasonable performance 27 # and still allows a simple workflow: building in frameworks/base and syncing. 28 WITH_DEXPREOPT_BOOT_IMG_AND_SYSTEM_SERVER_ONLY ?= true 29 endif 30 # Add mini-debug-info to the boot classpath unless explicitly asked not to. 31 ifneq (false,$(WITH_DEXPREOPT_DEBUG_INFO)) 32 PRODUCT_DEX_PREOPT_BOOT_FLAGS += --generate-mini-debug-info 33 endif 34 35 # Non eng linux builds must have preopt enabled so that system server doesn't run as interpreter 36 # only. b/74209329 37 ifeq (,$(filter eng, $(TARGET_BUILD_VARIANT))) 38 ifneq (true,$(WITH_DEXPREOPT)) 39 ifneq (true,$(WITH_DEXPREOPT_BOOT_IMG_AND_SYSTEM_SERVER_ONLY)) 40 $(call pretty-error, DEXPREOPT must be enabled for user and userdebug builds) 41 endif 42 endif 43 endif 44endif 45 46# Default to debug version to help find bugs. 47# Set USE_DEX2OAT_DEBUG to false for only building non-debug versions. 48ifeq ($(USE_DEX2OAT_DEBUG),false) 49DEX2OAT := $(SOONG_HOST_OUT_EXECUTABLES)/dex2oat$(HOST_EXECUTABLE_SUFFIX) 50else 51DEX2OAT := $(SOONG_HOST_OUT_EXECUTABLES)/dex2oatd$(HOST_EXECUTABLE_SUFFIX) 52endif 53 54DEX2OAT_DEPENDENCY += $(DEX2OAT) 55 56# Use the first preloaded-classes file in PRODUCT_COPY_FILES. 57PRELOADED_CLASSES := $(call word-colon,1,$(firstword \ 58 $(filter %system/etc/preloaded-classes,$(PRODUCT_COPY_FILES)))) 59 60# Use the first dirty-image-objects file in PRODUCT_COPY_FILES. 61DIRTY_IMAGE_OBJECTS := $(call word-colon,1,$(firstword \ 62 $(filter %system/etc/dirty-image-objects,$(PRODUCT_COPY_FILES)))) 63 64define get-product-default-property 65$(strip \ 66 $(eval _prop := $(patsubst $(1)=%,%,$(filter $(1)=%,$(PRODUCT_DEFAULT_PROPERTY_OVERRIDES))))\ 67 $(if $(_prop),$(_prop),$(patsubst $(1)=%,%,$(filter $(1)=%,$(PRODUCT_SYSTEM_DEFAULT_PROPERTIES))))) 68endef 69 70DEX2OAT_IMAGE_XMS := $(call get-product-default-property,dalvik.vm.image-dex2oat-Xms) 71DEX2OAT_IMAGE_XMX := $(call get-product-default-property,dalvik.vm.image-dex2oat-Xmx) 72DEX2OAT_XMS := $(call get-product-default-property,dalvik.vm.dex2oat-Xms) 73DEX2OAT_XMX := $(call get-product-default-property,dalvik.vm.dex2oat-Xmx) 74 75ifeq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),mips mips64)) 76# MIPS specific overrides. 77# For MIPS the ART image is loaded at a lower address. This causes issues 78# with the image overlapping with memory on the host cross-compiling and 79# building the image. We therefore limit the Xmx value. This isn't done 80# via a property as we want the larger Xmx value if we're running on a 81# MIPS device. 82DEX2OAT_XMX := 128m 83endif 84 85ifeq ($(WRITE_SOONG_VARIABLES),true) 86 87 $(call json_start) 88 89 $(call add_json_bool, DefaultNoStripping, $(filter nostripping,$(DEX_PREOPT_DEFAULT))) 90 $(call add_json_bool, DisablePreopt, $(call invert_bool,$(filter true,$(WITH_DEXPREOPT)))) 91 $(call add_json_list, DisablePreoptModules, $(DEXPREOPT_DISABLED_MODULES)) 92 $(call add_json_bool, OnlyPreoptBootImageAndSystemServer, $(filter true,$(WITH_DEXPREOPT_BOOT_IMG_AND_SYSTEM_SERVER_ONLY))) 93 $(call add_json_bool, GenerateApexImage, $(filter true,$(DEXPREOPT_GENERATE_APEX_IMAGE))) 94 $(call add_json_bool, UseApexImage, $(filter true,$(DEXPREOPT_USE_APEX_IMAGE))) 95 $(call add_json_bool, DontUncompressPrivAppsDex, $(filter true,$(DONT_UNCOMPRESS_PRIV_APPS_DEXS))) 96 $(call add_json_list, ModulesLoadedByPrivilegedModules, $(PRODUCT_LOADED_BY_PRIVILEGED_MODULES)) 97 $(call add_json_bool, HasSystemOther, $(BOARD_USES_SYSTEM_OTHER_ODEX)) 98 $(call add_json_list, PatternsOnSystemOther, $(SYSTEM_OTHER_ODEX_FILTER)) 99 $(call add_json_bool, DisableGenerateProfile, $(filter false,$(WITH_DEX_PREOPT_GENERATE_PROFILE))) 100 $(call add_json_str, ProfileDir, $(PRODUCT_DEX_PREOPT_PROFILE_DIR)) 101 $(call add_json_list, BootJars, $(PRODUCT_BOOT_JARS)) 102 $(call add_json_list, RuntimeApexJars, $(RUNTIME_APEX_JARS)) 103 $(call add_json_list, ProductUpdatableBootModules, $(PRODUCT_UPDATABLE_BOOT_MODULES)) 104 $(call add_json_list, ProductUpdatableBootLocations, $(PRODUCT_UPDATABLE_BOOT_LOCATIONS)) 105 $(call add_json_list, SystemServerJars, $(PRODUCT_SYSTEM_SERVER_JARS)) 106 $(call add_json_list, SystemServerApps, $(PRODUCT_SYSTEM_SERVER_APPS)) 107 $(call add_json_list, SpeedApps, $(PRODUCT_DEXPREOPT_SPEED_APPS)) 108 $(call add_json_list, PreoptFlags, $(PRODUCT_DEX_PREOPT_DEFAULT_FLAGS)) 109 $(call add_json_str, DefaultCompilerFilter, $(PRODUCT_DEX_PREOPT_DEFAULT_COMPILER_FILTER)) 110 $(call add_json_str, SystemServerCompilerFilter, $(PRODUCT_SYSTEM_SERVER_COMPILER_FILTER)) 111 $(call add_json_bool, GenerateDmFiles, $(PRODUCT_DEX_PREOPT_GENERATE_DM_FILES)) 112 $(call add_json_bool, NeverAllowStripping, $(PRODUCT_DEX_PREOPT_NEVER_ALLOW_STRIPPING)) 113 $(call add_json_bool, NoDebugInfo, $(filter false,$(WITH_DEXPREOPT_DEBUG_INFO))) 114 $(call add_json_bool, DontResolveStartupStrings, $(filter false,$(PRODUCT_DEX_PREOPT_RESOLVE_STARTUP_STRINGS))) 115 $(call add_json_bool, AlwaysSystemServerDebugInfo, $(filter true,$(PRODUCT_SYSTEM_SERVER_DEBUG_INFO))) 116 $(call add_json_bool, NeverSystemServerDebugInfo, $(filter false,$(PRODUCT_SYSTEM_SERVER_DEBUG_INFO))) 117 $(call add_json_bool, AlwaysOtherDebugInfo, $(filter true,$(PRODUCT_OTHER_JAVA_DEBUG_INFO))) 118 $(call add_json_bool, NeverOtherDebugInfo, $(filter false,$(PRODUCT_OTHER_JAVA_DEBUG_INFO))) 119 $(call add_json_list, MissingUsesLibraries, $(INTERNAL_PLATFORM_MISSING_USES_LIBRARIES)) 120 $(call add_json_bool, IsEng, $(filter eng,$(TARGET_BUILD_VARIANT))) 121 $(call add_json_bool, SanitizeLite, $(SANITIZE_LITE)) 122 $(call add_json_bool, DefaultAppImages, $(WITH_DEX_PREOPT_APP_IMAGE)) 123 $(call add_json_str, Dex2oatXmx, $(DEX2OAT_XMX)) 124 $(call add_json_str, Dex2oatXms, $(DEX2OAT_XMS)) 125 $(call add_json_str, EmptyDirectory, $(OUT_DIR)/empty) 126 127 $(call add_json_map, CpuVariant) 128 $(call add_json_str, $(TARGET_ARCH), $(DEX2OAT_TARGET_CPU_VARIANT)) 129 ifdef TARGET_2ND_ARCH 130 $(call add_json_str, $(TARGET_2ND_ARCH), $($(TARGET_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_CPU_VARIANT)) 131 endif 132 $(call end_json_map) 133 134 $(call add_json_map, InstructionSetFeatures) 135 $(call add_json_str, $(TARGET_ARCH), $(DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES)) 136 ifdef TARGET_2ND_ARCH 137 $(call add_json_str, $(TARGET_2ND_ARCH), $($(TARGET_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES)) 138 endif 139 $(call end_json_map) 140 141 $(call add_json_str, DirtyImageObjects, $(DIRTY_IMAGE_OBJECTS)) 142 $(call add_json_str, PreloadedClasses, $(PRELOADED_CLASSES)) 143 $(call add_json_list, BootImageProfiles, $(PRODUCT_DEX_PREOPT_BOOT_IMAGE_PROFILE_LOCATION)) 144 $(call add_json_bool, UseProfileForBootImage, $(call invert_bool,$(filter false,$(PRODUCT_USE_PROFILE_FOR_BOOT_IMAGE)))) 145 $(call add_json_str, BootFlags, $(PRODUCT_DEX_PREOPT_BOOT_FLAGS)) 146 $(call add_json_str, Dex2oatImageXmx, $(DEX2OAT_IMAGE_XMX)) 147 $(call add_json_str, Dex2oatImageXms, $(DEX2OAT_IMAGE_XMS)) 148 149 $(call add_json_map, Tools) 150 $(call add_json_str, Profman, $(SOONG_HOST_OUT_EXECUTABLES)/profman) 151 $(call add_json_str, Dex2oat, $(DEX2OAT)) 152 $(call add_json_str, Aapt, $(SOONG_HOST_OUT_EXECUTABLES)/aapt) 153 $(call add_json_str, SoongZip, $(SOONG_ZIP)) 154 $(call add_json_str, Zip2zip, $(ZIP2ZIP)) 155 $(call add_json_str, VerifyUsesLibraries, $(BUILD_SYSTEM)/verify_uses_libraries.sh) 156 $(call add_json_str, ConstructContext, $(BUILD_SYSTEM)/construct_context.sh) 157 $(call end_json_map) 158 159 $(call json_end) 160 161 $(shell mkdir -p $(dir $(DEX_PREOPT_CONFIG))) 162 $(file >$(DEX_PREOPT_CONFIG).tmp,$(json_contents)) 163 164 $(shell \ 165 if ! cmp -s $(DEX_PREOPT_CONFIG).tmp $(DEX_PREOPT_CONFIG); then \ 166 mv $(DEX_PREOPT_CONFIG).tmp $(DEX_PREOPT_CONFIG); \ 167 else \ 168 rm $(DEX_PREOPT_CONFIG).tmp; \ 169 fi) 170endif 171 172# Dummy rule to create dexpreopt.config, it will already have been created 173# by the $(file) call above, but a rule needs to exist to keep the dangling 174# rule check happy. 175$(DEX_PREOPT_CONFIG): 176 @#empty 177 178DEXPREOPT_GEN_DEPS := \ 179 $(SOONG_HOST_OUT_EXECUTABLES)/profman \ 180 $(DEX2OAT) \ 181 $(SOONG_HOST_OUT_EXECUTABLES)/aapt \ 182 $(SOONG_ZIP) \ 183 $(ZIP2ZIP) \ 184 $(BUILD_SYSTEM)/verify_uses_libraries.sh \ 185 $(BUILD_SYSTEM)/construct_context.sh \ 186 187DEXPREOPT_STRIP_DEPS := \ 188 $(ZIP2ZIP) \ 189