1DEX_PREOPT_CONFIG := $(SOONG_OUT_DIR)/dexpreopt.config 2 3ENABLE_PREOPT := true 4ENABLE_PREOPT_BOOT_IMAGES := true 5ifneq (true,$(filter true,$(WITH_DEXPREOPT))) 6 # Disable dexpreopt for libraries/apps and for boot images. 7 ENABLE_PREOPT := 8 ENABLE_PREOPT_BOOT_IMAGES := 9else ifneq (true,$(filter true,$(PRODUCT_USES_DEFAULT_ART_CONFIG))) 10 # Disable dexpreopt for libraries/apps and for boot images: not having default 11 # ART config means that some important system properties are not set, which 12 # would result in passing bad arguments to dex2oat and failing the build. 13 ENABLE_PREOPT := 14 ENABLE_PREOPT_BOOT_IMAGES := 15else ifeq (true,$(DISABLE_PREOPT)) 16 # Disable dexpreopt for libraries/apps, but do compile boot images. 17 ENABLE_PREOPT := 18endif 19 20# The default value for LOCAL_DEX_PREOPT 21DEX_PREOPT_DEFAULT ?= $(ENABLE_PREOPT) 22 23# Whether to fail immediately if verify_uses_libraries check fails, or to keep 24# going and restrict dexpreopt to not compile any code for the failed module. 25# 26# The intended use case for this flag is to have a smoother migration path for 27# the Java modules that need to add <uses-library> information in their build 28# files. The flag allows to quickly silence build errors. This flag should be 29# used with caution and only as a temporary measure, as it masks real errors 30# and affects performance. 31ifndef RELAX_USES_LIBRARY_CHECK 32 RELAX_USES_LIBRARY_CHECK := $(if \ 33 $(filter true,$(PRODUCT_BROKEN_VERIFY_USES_LIBRARIES)),true,false) 34else 35 # Let the environment variable override PRODUCT_BROKEN_VERIFY_USES_LIBRARIES. 36endif 37.KATI_READONLY := RELAX_USES_LIBRARY_CHECK 38 39# The default filter for which files go into the system_other image (if it is 40# being used). Note that each pattern p here matches both '/<p>' and /system/<p>'. 41# To bundle everything one should set this to '%'. 42SYSTEM_OTHER_ODEX_FILTER ?= \ 43 app/% \ 44 priv-app/% \ 45 system_ext/app/% \ 46 system_ext/priv-app/% \ 47 product/app/% \ 48 product/priv-app/% \ 49 50# Global switch to control if updatable boot jars are included in dexpreopt. 51DEX_PREOPT_WITH_UPDATABLE_BCP := true 52 53# Conditional to building on linux, as dex2oat currently does not work on darwin. 54ifeq ($(HOST_OS),linux) 55 ifeq (eng,$(TARGET_BUILD_VARIANT)) 56 # For an eng build only pre-opt the boot image and system server. This gives reasonable performance 57 # and still allows a simple workflow: building in frameworks/base and syncing. 58 WITH_DEXPREOPT_BOOT_IMG_AND_SYSTEM_SERVER_ONLY ?= true 59 endif 60 # Add mini-debug-info to the boot classpath unless explicitly asked not to. 61 ifneq (false,$(WITH_DEXPREOPT_DEBUG_INFO)) 62 PRODUCT_DEX_PREOPT_BOOT_FLAGS += --generate-mini-debug-info 63 endif 64 65 # Non eng linux builds must have preopt enabled so that system server doesn't run as interpreter 66 # only. b/74209329 67 ifeq (,$(filter eng, $(TARGET_BUILD_VARIANT))) 68 ifneq (true,$(WITH_DEXPREOPT)) 69 ifneq (true,$(WITH_DEXPREOPT_BOOT_IMG_AND_SYSTEM_SERVER_ONLY)) 70 $(call pretty-error, DEXPREOPT must be enabled for user and userdebug builds) 71 endif 72 endif 73 endif 74endif 75 76# Get value of a property. It is first searched from PRODUCT_VENDOR_PROPERTIES 77# and then falls back to PRODUCT_SYSTEM_PROPERTIES 78# $1: name of the property 79define get-product-default-property 80$(strip \ 81 $(eval _prop := $(patsubst $(1)=%,%,$(filter $(1)=%,$(PRODUCT_VENDOR_PROPERTIES))))\ 82 $(if $(_prop),$(_prop),$(patsubst $(1)=%,%,$(filter $(1)=%,$(PRODUCT_SYSTEM_PROPERTIES))))) 83endef 84 85DEX2OAT_IMAGE_XMS := $(call get-product-default-property,dalvik.vm.image-dex2oat-Xms) 86DEX2OAT_IMAGE_XMX := $(call get-product-default-property,dalvik.vm.image-dex2oat-Xmx) 87DEX2OAT_XMS := $(call get-product-default-property,dalvik.vm.dex2oat-Xms) 88DEX2OAT_XMX := $(call get-product-default-property,dalvik.vm.dex2oat-Xmx) 89 90ifeq ($(WRITE_SOONG_VARIABLES),true) 91 92 $(call json_start) 93 94 $(call add_json_bool, DisablePreopt, $(call invert_bool,$(ENABLE_PREOPT))) 95 $(call add_json_bool, DisablePreoptBootImages, $(call invert_bool,$(ENABLE_PREOPT_BOOT_IMAGES))) 96 $(call add_json_list, DisablePreoptModules, $(DEXPREOPT_DISABLED_MODULES)) 97 $(call add_json_bool, OnlyPreoptBootImageAndSystemServer, $(filter true,$(WITH_DEXPREOPT_BOOT_IMG_AND_SYSTEM_SERVER_ONLY))) 98 $(call add_json_bool, PreoptWithUpdatableBcp, $(filter true,$(DEX_PREOPT_WITH_UPDATABLE_BCP))) 99 $(call add_json_bool, UseArtImage, $(filter true,$(DEXPREOPT_USE_ART_IMAGE))) 100 $(call add_json_bool, DontUncompressPrivAppsDex, $(filter true,$(DONT_UNCOMPRESS_PRIV_APPS_DEXS))) 101 $(call add_json_list, ModulesLoadedByPrivilegedModules, $(PRODUCT_LOADED_BY_PRIVILEGED_MODULES)) 102 $(call add_json_bool, HasSystemOther, $(BOARD_USES_SYSTEM_OTHER_ODEX)) 103 $(call add_json_list, PatternsOnSystemOther, $(SYSTEM_OTHER_ODEX_FILTER)) 104 $(call add_json_bool, DisableGenerateProfile, $(filter false,$(WITH_DEX_PREOPT_GENERATE_PROFILE))) 105 $(call add_json_str, ProfileDir, $(PRODUCT_DEX_PREOPT_PROFILE_DIR)) 106 $(call add_json_list, BootJars, $(PRODUCT_BOOT_JARS)) 107 $(call add_json_list, UpdatableBootJars, $(PRODUCT_UPDATABLE_BOOT_JARS)) 108 $(call add_json_list, ArtApexJars, $(filter $(PRODUCT_BOOT_JARS),$(ART_APEX_JARS))) 109 $(call add_json_list, SystemServerJars, $(PRODUCT_SYSTEM_SERVER_JARS)) 110 $(call add_json_list, SystemServerApps, $(PRODUCT_SYSTEM_SERVER_APPS)) 111 $(call add_json_list, UpdatableSystemServerJars, $(PRODUCT_UPDATABLE_SYSTEM_SERVER_JARS)) 112 $(call add_json_bool, BrokenSuboptimalOrderOfSystemServerJars, $(PRODUCT_BROKEN_SUBOPTIMAL_ORDER_OF_SYSTEM_SERVER_JARS)) 113 $(call add_json_list, SpeedApps, $(PRODUCT_DEXPREOPT_SPEED_APPS)) 114 $(call add_json_list, PreoptFlags, $(PRODUCT_DEX_PREOPT_DEFAULT_FLAGS)) 115 $(call add_json_str, DefaultCompilerFilter, $(PRODUCT_DEX_PREOPT_DEFAULT_COMPILER_FILTER)) 116 $(call add_json_str, SystemServerCompilerFilter, $(PRODUCT_SYSTEM_SERVER_COMPILER_FILTER)) 117 $(call add_json_bool, GenerateDmFiles, $(PRODUCT_DEX_PREOPT_GENERATE_DM_FILES)) 118 $(call add_json_bool, NeverAllowStripping, $(PRODUCT_DEX_PREOPT_NEVER_ALLOW_STRIPPING)) 119 $(call add_json_bool, NoDebugInfo, $(filter false,$(WITH_DEXPREOPT_DEBUG_INFO))) 120 $(call add_json_bool, DontResolveStartupStrings, $(filter false,$(PRODUCT_DEX_PREOPT_RESOLVE_STARTUP_STRINGS))) 121 $(call add_json_bool, AlwaysSystemServerDebugInfo, $(filter true,$(PRODUCT_SYSTEM_SERVER_DEBUG_INFO))) 122 $(call add_json_bool, NeverSystemServerDebugInfo, $(filter false,$(PRODUCT_SYSTEM_SERVER_DEBUG_INFO))) 123 $(call add_json_bool, AlwaysOtherDebugInfo, $(filter true,$(PRODUCT_OTHER_JAVA_DEBUG_INFO))) 124 $(call add_json_bool, NeverOtherDebugInfo, $(filter false,$(PRODUCT_OTHER_JAVA_DEBUG_INFO))) 125 $(call add_json_bool, IsEng, $(filter eng,$(TARGET_BUILD_VARIANT))) 126 $(call add_json_bool, SanitizeLite, $(SANITIZE_LITE)) 127 $(call add_json_bool, DefaultAppImages, $(WITH_DEX_PREOPT_APP_IMAGE)) 128 $(call add_json_bool, RelaxUsesLibraryCheck, $(filter true,$(RELAX_USES_LIBRARY_CHECK))) 129 $(call add_json_str, Dex2oatXmx, $(DEX2OAT_XMX)) 130 $(call add_json_str, Dex2oatXms, $(DEX2OAT_XMS)) 131 $(call add_json_str, EmptyDirectory, $(OUT_DIR)/empty) 132 133ifdef TARGET_ARCH 134 $(call add_json_map, CpuVariant) 135 $(call add_json_str, $(TARGET_ARCH), $(DEX2OAT_TARGET_CPU_VARIANT)) 136 ifdef TARGET_2ND_ARCH 137 $(call add_json_str, $(TARGET_2ND_ARCH), $($(TARGET_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_CPU_VARIANT)) 138 endif 139 $(call end_json_map) 140 141 $(call add_json_map, InstructionSetFeatures) 142 $(call add_json_str, $(TARGET_ARCH), $(DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES)) 143 ifdef TARGET_2ND_ARCH 144 $(call add_json_str, $(TARGET_2ND_ARCH), $($(TARGET_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES)) 145 endif 146 $(call end_json_map) 147endif 148 149 $(call add_json_list, BootImageProfiles, $(PRODUCT_DEX_PREOPT_BOOT_IMAGE_PROFILE_LOCATION)) 150 $(call add_json_str, BootFlags, $(PRODUCT_DEX_PREOPT_BOOT_FLAGS)) 151 $(call add_json_str, Dex2oatImageXmx, $(DEX2OAT_IMAGE_XMX)) 152 $(call add_json_str, Dex2oatImageXms, $(DEX2OAT_IMAGE_XMS)) 153 154 $(call json_end) 155 156 $(shell mkdir -p $(dir $(DEX_PREOPT_CONFIG))) 157 $(file >$(DEX_PREOPT_CONFIG).tmp,$(json_contents)) 158 159 $(shell \ 160 if ! cmp -s $(DEX_PREOPT_CONFIG).tmp $(DEX_PREOPT_CONFIG); then \ 161 mv $(DEX_PREOPT_CONFIG).tmp $(DEX_PREOPT_CONFIG); \ 162 else \ 163 rm $(DEX_PREOPT_CONFIG).tmp; \ 164 fi) 165endif 166