1DEX_PREOPT_CONFIG := $(SOONG_OUT_DIR)/dexpreopt.config 2 3ENABLE_PREOPT := true 4ifneq (true,$(filter true,$(WITH_DEXPREOPT))) 5 ENABLE_PREOPT := 6else ifneq (true,$(filter true,$(PRODUCT_USES_DEFAULT_ART_CONFIG))) 7 ENABLE_PREOPT := 8else ifneq (,$(TARGET_BUILD_APPS)) 9 ENABLE_PREOPT := 10endif 11 12# The default value for LOCAL_DEX_PREOPT 13DEX_PREOPT_DEFAULT ?= true 14 15# The default filter for which files go into the system_other image (if it is 16# being used). Note that each pattern p here matches both '/<p>' and /system/<p>'. 17# To bundle everything one should set this to '%'. 18SYSTEM_OTHER_ODEX_FILTER ?= \ 19 app/% \ 20 priv-app/% \ 21 system_ext/app/% \ 22 system_ext/priv-app/% \ 23 product/app/% \ 24 product/priv-app/% \ 25 26# Conditional to building on linux, as dex2oat currently does not work on darwin. 27ifeq ($(HOST_OS),linux) 28 ifeq (eng,$(TARGET_BUILD_VARIANT)) 29 # For an eng build only pre-opt the boot image and system server. This gives reasonable performance 30 # and still allows a simple workflow: building in frameworks/base and syncing. 31 WITH_DEXPREOPT_BOOT_IMG_AND_SYSTEM_SERVER_ONLY ?= true 32 endif 33 # Add mini-debug-info to the boot classpath unless explicitly asked not to. 34 ifneq (false,$(WITH_DEXPREOPT_DEBUG_INFO)) 35 PRODUCT_DEX_PREOPT_BOOT_FLAGS += --generate-mini-debug-info 36 endif 37 38 # Non eng linux builds must have preopt enabled so that system server doesn't run as interpreter 39 # only. b/74209329 40 ifeq (,$(filter eng, $(TARGET_BUILD_VARIANT))) 41 ifneq (true,$(WITH_DEXPREOPT)) 42 ifneq (true,$(WITH_DEXPREOPT_BOOT_IMG_AND_SYSTEM_SERVER_ONLY)) 43 $(call pretty-error, DEXPREOPT must be enabled for user and userdebug builds) 44 endif 45 endif 46 endif 47endif 48 49# Use the first preloaded-classes file in PRODUCT_COPY_FILES. 50PRELOADED_CLASSES := $(call word-colon,1,$(firstword \ 51 $(filter %system/etc/preloaded-classes,$(PRODUCT_COPY_FILES)))) 52 53# Use the first dirty-image-objects file in PRODUCT_COPY_FILES. 54DIRTY_IMAGE_OBJECTS := $(call word-colon,1,$(firstword \ 55 $(filter %system/etc/dirty-image-objects,$(PRODUCT_COPY_FILES)))) 56 57# Get value of a property. It is first searched from PRODUCT_VENDOR_PROPERTIES 58# and then falls back to PRODUCT_SYSTEM_PROPERTIES 59# $1: name of the property 60define get-product-default-property 61$(strip \ 62 $(eval _prop := $(patsubst $(1)=%,%,$(filter $(1)=%,$(PRODUCT_VENDOR_PROPERTIES))))\ 63 $(if $(_prop),$(_prop),$(patsubst $(1)=%,%,$(filter $(1)=%,$(PRODUCT_SYSTEM_PROPERTIES))))) 64endef 65 66DEX2OAT_IMAGE_XMS := $(call get-product-default-property,dalvik.vm.image-dex2oat-Xms) 67DEX2OAT_IMAGE_XMX := $(call get-product-default-property,dalvik.vm.image-dex2oat-Xmx) 68DEX2OAT_XMS := $(call get-product-default-property,dalvik.vm.dex2oat-Xms) 69DEX2OAT_XMX := $(call get-product-default-property,dalvik.vm.dex2oat-Xmx) 70 71ifeq ($(WRITE_SOONG_VARIABLES),true) 72 73 $(call json_start) 74 75 $(call add_json_bool, DisablePreopt, $(call invert_bool,$(ENABLE_PREOPT))) 76 $(call add_json_list, DisablePreoptModules, $(DEXPREOPT_DISABLED_MODULES)) 77 $(call add_json_bool, OnlyPreoptBootImageAndSystemServer, $(filter true,$(WITH_DEXPREOPT_BOOT_IMG_AND_SYSTEM_SERVER_ONLY))) 78 $(call add_json_bool, UseArtImage, $(filter true,$(DEXPREOPT_USE_ART_IMAGE))) 79 $(call add_json_bool, DontUncompressPrivAppsDex, $(filter true,$(DONT_UNCOMPRESS_PRIV_APPS_DEXS))) 80 $(call add_json_list, ModulesLoadedByPrivilegedModules, $(PRODUCT_LOADED_BY_PRIVILEGED_MODULES)) 81 $(call add_json_bool, HasSystemOther, $(BOARD_USES_SYSTEM_OTHER_ODEX)) 82 $(call add_json_list, PatternsOnSystemOther, $(SYSTEM_OTHER_ODEX_FILTER)) 83 $(call add_json_bool, DisableGenerateProfile, $(filter false,$(WITH_DEX_PREOPT_GENERATE_PROFILE))) 84 $(call add_json_str, ProfileDir, $(PRODUCT_DEX_PREOPT_PROFILE_DIR)) 85 $(call add_json_list, BootJars, $(PRODUCT_BOOT_JARS)) 86 $(call add_json_list, UpdatableBootJars, $(PRODUCT_UPDATABLE_BOOT_JARS)) 87 $(call add_json_list, ArtApexJars, $(ART_APEX_JARS)) 88 $(call add_json_list, SystemServerJars, $(PRODUCT_SYSTEM_SERVER_JARS)) 89 $(call add_json_list, SystemServerApps, $(PRODUCT_SYSTEM_SERVER_APPS)) 90 $(call add_json_list, UpdatableSystemServerJars, $(PRODUCT_UPDATABLE_SYSTEM_SERVER_JARS)) 91 $(call add_json_bool, BrokenSuboptimalOrderOfSystemServerJars, $(PRODUCT_BROKEN_SUBOPTIMAL_ORDER_OF_SYSTEM_SERVER_JARS)) 92 $(call add_json_list, SpeedApps, $(PRODUCT_DEXPREOPT_SPEED_APPS)) 93 $(call add_json_list, PreoptFlags, $(PRODUCT_DEX_PREOPT_DEFAULT_FLAGS)) 94 $(call add_json_str, DefaultCompilerFilter, $(PRODUCT_DEX_PREOPT_DEFAULT_COMPILER_FILTER)) 95 $(call add_json_str, SystemServerCompilerFilter, $(PRODUCT_SYSTEM_SERVER_COMPILER_FILTER)) 96 $(call add_json_bool, GenerateDmFiles, $(PRODUCT_DEX_PREOPT_GENERATE_DM_FILES)) 97 $(call add_json_bool, NeverAllowStripping, $(PRODUCT_DEX_PREOPT_NEVER_ALLOW_STRIPPING)) 98 $(call add_json_bool, NoDebugInfo, $(filter false,$(WITH_DEXPREOPT_DEBUG_INFO))) 99 $(call add_json_bool, DontResolveStartupStrings, $(filter false,$(PRODUCT_DEX_PREOPT_RESOLVE_STARTUP_STRINGS))) 100 $(call add_json_bool, AlwaysSystemServerDebugInfo, $(filter true,$(PRODUCT_SYSTEM_SERVER_DEBUG_INFO))) 101 $(call add_json_bool, NeverSystemServerDebugInfo, $(filter false,$(PRODUCT_SYSTEM_SERVER_DEBUG_INFO))) 102 $(call add_json_bool, AlwaysOtherDebugInfo, $(filter true,$(PRODUCT_OTHER_JAVA_DEBUG_INFO))) 103 $(call add_json_bool, NeverOtherDebugInfo, $(filter false,$(PRODUCT_OTHER_JAVA_DEBUG_INFO))) 104 $(call add_json_bool, IsEng, $(filter eng,$(TARGET_BUILD_VARIANT))) 105 $(call add_json_bool, SanitizeLite, $(SANITIZE_LITE)) 106 $(call add_json_bool, DefaultAppImages, $(WITH_DEX_PREOPT_APP_IMAGE)) 107 $(call add_json_str, Dex2oatXmx, $(DEX2OAT_XMX)) 108 $(call add_json_str, Dex2oatXms, $(DEX2OAT_XMS)) 109 $(call add_json_str, EmptyDirectory, $(OUT_DIR)/empty) 110 111 $(call add_json_map, CpuVariant) 112 $(call add_json_str, $(TARGET_ARCH), $(DEX2OAT_TARGET_CPU_VARIANT)) 113 ifdef TARGET_2ND_ARCH 114 $(call add_json_str, $(TARGET_2ND_ARCH), $($(TARGET_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_CPU_VARIANT)) 115 endif 116 $(call end_json_map) 117 118 $(call add_json_map, InstructionSetFeatures) 119 $(call add_json_str, $(TARGET_ARCH), $(DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES)) 120 ifdef TARGET_2ND_ARCH 121 $(call add_json_str, $(TARGET_2ND_ARCH), $($(TARGET_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES)) 122 endif 123 $(call end_json_map) 124 125 $(call add_json_str, DirtyImageObjects, $(DIRTY_IMAGE_OBJECTS)) 126 $(call add_json_list, BootImageProfiles, $(PRODUCT_DEX_PREOPT_BOOT_IMAGE_PROFILE_LOCATION)) 127 $(call add_json_str, BootFlags, $(PRODUCT_DEX_PREOPT_BOOT_FLAGS)) 128 $(call add_json_str, Dex2oatImageXmx, $(DEX2OAT_IMAGE_XMX)) 129 $(call add_json_str, Dex2oatImageXms, $(DEX2OAT_IMAGE_XMS)) 130 131 $(call json_end) 132 133 $(shell mkdir -p $(dir $(DEX_PREOPT_CONFIG))) 134 $(file >$(DEX_PREOPT_CONFIG).tmp,$(json_contents)) 135 136 $(shell \ 137 if ! cmp -s $(DEX_PREOPT_CONFIG).tmp $(DEX_PREOPT_CONFIG); then \ 138 mv $(DEX_PREOPT_CONFIG).tmp $(DEX_PREOPT_CONFIG); \ 139 else \ 140 rm $(DEX_PREOPT_CONFIG).tmp; \ 141 fi) 142endif 143