Colin Cross | 6db5b0e | 2018-11-16 21:26:33 -0800 | [diff] [blame] | 1 | DEX_PREOPT_CONFIG := $(PRODUCT_OUT)/dexpreopt.config |
| 2 | |
Nicolas Geoffray | 6ce12f5 | 2019-01-15 11:46:32 +0000 | [diff] [blame] | 3 | UPDATABLE_BOOT_MODULES := conscrypt |
| 4 | UPDATABLE_BOOT_JARS := /apex/com.android.conscrypt/javalib/conscrypt.jar |
| 5 | NON_UPDATABLE_BOOT_MODULES := $(filter-out $(UPDATABLE_BOOT_MODULES), $(PRODUCT_BOOT_JARS)) |
| 6 | NON_UPDATABLE_BOOT_JARS := $(foreach m,$(NON_UPDATABLE_BOOT_MODULES),/system/framework/$(m).jar) |
| 7 | ALL_BOOT_JARS := $(NON_UPDATABLE_BOOT_JARS) $(UPDATABLE_BOOT_JARS) |
| 8 | ALL_BOOT_MODULES := $(NON_UPDATABLE_BOOT_MODULES) $(UPDATABLE_BOOT_MODULES) |
Colin Cross | 6db5b0e | 2018-11-16 21:26:33 -0800 | [diff] [blame] | 9 | |
Nicolas Geoffray | 6ce12f5 | 2019-01-15 11:46:32 +0000 | [diff] [blame] | 10 | PRODUCT_BOOTCLASSPATH := $(subst $(space),:,$(ALL_BOOT_JARS)) |
Colin Cross | 6db5b0e | 2018-11-16 21:26:33 -0800 | [diff] [blame] | 11 | |
Nicolas Geoffray | 6ce12f5 | 2019-01-15 11:46:32 +0000 | [diff] [blame] | 12 | DEXPREOPT_BOOT_JARS_MODULES := $(NON_UPDATABLE_BOOT_MODULES) |
| 13 | DEXPREOPT_BOOTCLASSPATH_DEX_LOCATIONS := $(NON_UPDATABLE_BOOT_JARS) |
| 14 | DEXPREOPT_BOOTCLASSPATH_DEX_FILES := $(foreach jar,$(DEXPREOPT_BOOTCLASSPATH_DEX_LOCATIONS),$(PRODUCT_OUT)$(jar)) |
| 15 | |
| 16 | # Create paths for boot image. |
Colin Cross | 6db5b0e | 2018-11-16 21:26:33 -0800 | [diff] [blame] | 17 | DEXPREOPT_BUILD_DIR := $(OUT_DIR) |
| 18 | DEXPREOPT_PRODUCT_DIR_FULL_PATH := $(PRODUCT_OUT)/dex_bootjars |
| 19 | DEXPREOPT_PRODUCT_DIR := $(patsubst $(DEXPREOPT_BUILD_DIR)/%,%,$(DEXPREOPT_PRODUCT_DIR_FULL_PATH)) |
| 20 | DEXPREOPT_BOOT_JAR_DIR := system/framework |
| 21 | DEXPREOPT_BOOT_JAR_DIR_FULL_PATH := $(DEXPREOPT_PRODUCT_DIR_FULL_PATH)/$(DEXPREOPT_BOOT_JAR_DIR) |
Colin Cross | 6db5b0e | 2018-11-16 21:26:33 -0800 | [diff] [blame] | 22 | DEFAULT_DEX_PREOPT_BUILT_IMAGE_LOCATION := $(DEXPREOPT_BOOT_JAR_DIR_FULL_PATH)/boot.art |
| 23 | DEFAULT_DEX_PREOPT_BUILT_IMAGE_FILENAME := $(DEXPREOPT_BOOT_JAR_DIR_FULL_PATH)/$(DEX2OAT_TARGET_ARCH)/boot.art |
| 24 | |
| 25 | ifdef TARGET_2ND_ARCH |
| 26 | $(TARGET_2ND_ARCH_VAR_PREFIX)DEFAULT_DEX_PREOPT_BUILT_IMAGE_LOCATION := $(DEXPREOPT_BOOT_JAR_DIR_FULL_PATH)/boot.art |
| 27 | $(TARGET_2ND_ARCH_VAR_PREFIX)DEFAULT_DEX_PREOPT_BUILT_IMAGE_FILENAME := $(DEXPREOPT_BOOT_JAR_DIR_FULL_PATH)/$($(TARGET_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_ARCH)/boot.art |
| 28 | endif |
| 29 | |
Nicolas Geoffray | 6ce12f5 | 2019-01-15 11:46:32 +0000 | [diff] [blame] | 30 | PRODUCT_SYSTEM_SERVER_CLASSPATH := $(subst $(space),:,$(foreach m,$(PRODUCT_SYSTEM_SERVER_JARS),/system/framework/$(m).jar)) |
| 31 | |
Colin Cross | 6db5b0e | 2018-11-16 21:26:33 -0800 | [diff] [blame] | 32 | # The default value for LOCAL_DEX_PREOPT |
| 33 | DEX_PREOPT_DEFAULT ?= true |
| 34 | |
| 35 | # The default filter for which files go into the system_other image (if it is |
| 36 | # being used). To bundle everything one should set this to '%' |
| 37 | SYSTEM_OTHER_ODEX_FILTER ?= \ |
| 38 | app/% \ |
| 39 | priv-app/% \ |
| 40 | product_services/app/% \ |
| 41 | product_services/priv-app/% \ |
| 42 | product/app/% \ |
| 43 | product/priv-app/% \ |
| 44 | |
| 45 | # The default values for pre-opting: always preopt PIC. |
| 46 | # Conditional to building on linux, as dex2oat currently does not work on darwin. |
| 47 | ifeq ($(HOST_OS),linux) |
| 48 | WITH_DEXPREOPT ?= true |
| 49 | ifeq (eng,$(TARGET_BUILD_VARIANT)) |
| 50 | # Don't strip for quick development turnarounds. |
| 51 | DEX_PREOPT_DEFAULT := nostripping |
| 52 | # For an eng build only pre-opt the boot image and system server. This gives reasonable performance |
| 53 | # and still allows a simple workflow: building in frameworks/base and syncing. |
| 54 | WITH_DEXPREOPT_BOOT_IMG_AND_SYSTEM_SERVER_ONLY ?= true |
| 55 | endif |
| 56 | # Add mini-debug-info to the boot classpath unless explicitly asked not to. |
| 57 | ifneq (false,$(WITH_DEXPREOPT_DEBUG_INFO)) |
| 58 | PRODUCT_DEX_PREOPT_BOOT_FLAGS += --generate-mini-debug-info |
| 59 | endif |
| 60 | |
| 61 | # Non eng linux builds must have preopt enabled so that system server doesn't run as interpreter |
| 62 | # only. b/74209329 |
| 63 | ifeq (,$(filter eng, $(TARGET_BUILD_VARIANT))) |
| 64 | ifneq (true,$(WITH_DEXPREOPT)) |
| 65 | ifneq (true,$(WITH_DEXPREOPT_BOOT_IMG_AND_SYSTEM_SERVER_ONLY)) |
| 66 | $(call pretty-error, DEXPREOPT must be enabled for user and userdebug builds) |
| 67 | endif |
| 68 | endif |
| 69 | endif |
| 70 | endif |
| 71 | |
| 72 | # Default to debug version to help find bugs. |
| 73 | # Set USE_DEX2OAT_DEBUG to false for only building non-debug versions. |
| 74 | ifeq ($(USE_DEX2OAT_DEBUG),false) |
| 75 | DEX2OAT := $(HOST_OUT_EXECUTABLES)/dex2oat$(HOST_EXECUTABLE_SUFFIX) |
| 76 | else |
| 77 | DEX2OAT := $(HOST_OUT_EXECUTABLES)/dex2oatd$(HOST_EXECUTABLE_SUFFIX) |
| 78 | endif |
| 79 | |
| 80 | DEX2OAT_DEPENDENCY += $(DEX2OAT) |
| 81 | |
| 82 | # Use the first preloaded-classes file in PRODUCT_COPY_FILES. |
| 83 | PRELOADED_CLASSES := $(call word-colon,1,$(firstword \ |
| 84 | $(filter %system/etc/preloaded-classes,$(PRODUCT_COPY_FILES)))) |
| 85 | |
| 86 | # Use the first dirty-image-objects file in PRODUCT_COPY_FILES. |
| 87 | DIRTY_IMAGE_OBJECTS := $(call word-colon,1,$(firstword \ |
| 88 | $(filter %system/etc/dirty-image-objects,$(PRODUCT_COPY_FILES)))) |
| 89 | |
| 90 | define get-product-default-property |
| 91 | $(strip \ |
| 92 | $(eval _prop := $(patsubst $(1)=%,%,$(filter $(1)=%,$(PRODUCT_DEFAULT_PROPERTY_OVERRIDES))))\ |
| 93 | $(if $(_prop),$(_prop),$(patsubst $(1)=%,%,$(filter $(1)=%,$(PRODUCT_SYSTEM_DEFAULT_PROPERTIES))))) |
| 94 | endef |
| 95 | |
| 96 | DEX2OAT_IMAGE_XMS := $(call get-product-default-property,dalvik.vm.image-dex2oat-Xms) |
| 97 | DEX2OAT_IMAGE_XMX := $(call get-product-default-property,dalvik.vm.image-dex2oat-Xmx) |
| 98 | DEX2OAT_XMS := $(call get-product-default-property,dalvik.vm.dex2oat-Xms) |
| 99 | DEX2OAT_XMX := $(call get-product-default-property,dalvik.vm.dex2oat-Xmx) |
| 100 | |
| 101 | ifeq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),mips mips64)) |
| 102 | # MIPS specific overrides. |
| 103 | # For MIPS the ART image is loaded at a lower address. This causes issues |
| 104 | # with the image overlapping with memory on the host cross-compiling and |
| 105 | # building the image. We therefore limit the Xmx value. This isn't done |
| 106 | # via a property as we want the larger Xmx value if we're running on a |
| 107 | # MIPS device. |
| 108 | DEX2OAT_XMX := 128m |
| 109 | endif |
| 110 | |
| 111 | ifeq ($(WRITE_SOONG_VARIABLES),true) |
| 112 | |
| 113 | $(call json_start) |
| 114 | |
| 115 | $(call add_json_bool, DefaultNoStripping, $(filter nostripping,$(DEX_PREOPT_DEFAULT))) |
| 116 | $(call add_json_list, DisablePreoptModules, $(DEXPREOPT_DISABLED_MODULES)) |
| 117 | $(call add_json_bool, OnlyPreoptBootImageAndSystemServer, $(filter true,$(WITH_DEXPREOPT_BOOT_IMG_AND_SYSTEM_SERVER_ONLY))) |
| 118 | $(call add_json_bool, DontUncompressPrivAppsDex, $(filter true,$(DONT_UNCOMPRESS_PRIV_APPS_DEXS))) |
| 119 | $(call add_json_list, ModulesLoadedByPrivilegedModules, $(PRODUCT_LOADED_BY_PRIVILEGED_MODULES)) |
| 120 | $(call add_json_bool, HasSystemOther, $(BOARD_USES_SYSTEM_OTHER_ODEX)) |
| 121 | $(call add_json_list, PatternsOnSystemOther, $(SYSTEM_OTHER_ODEX_FILTER)) |
| 122 | $(call add_json_bool, DisableGenerateProfile, $(filter false,$(WITH_DEX_PREOPT_GENERATE_PROFILE))) |
Vladimir Marko | 3266d6e | 2018-10-24 14:31:43 +0100 | [diff] [blame] | 123 | $(call add_json_list, PreoptBootClassPathDexFiles, $(DEXPREOPT_BOOTCLASSPATH_DEX_FILES)) |
| 124 | $(call add_json_list, PreoptBootClassPathDexLocations, $(DEXPREOPT_BOOTCLASSPATH_DEX_LOCATIONS)) |
| 125 | $(call add_json_list, BootJars, $(PRODUCT_BOOT_JARS)) |
Vladimir Marko | e3a2db8 | 2018-12-21 15:53:17 +0000 | [diff] [blame] | 126 | $(call add_json_list, PreoptBootJars, $(DEXPREOPT_BOOT_JARS_MODULES)) |
Colin Cross | 6db5b0e | 2018-11-16 21:26:33 -0800 | [diff] [blame] | 127 | $(call add_json_list, SystemServerJars, $(PRODUCT_SYSTEM_SERVER_JARS)) |
| 128 | $(call add_json_list, SystemServerApps, $(PRODUCT_SYSTEM_SERVER_APPS)) |
| 129 | $(call add_json_list, SpeedApps, $(PRODUCT_DEXPREOPT_SPEED_APPS)) |
| 130 | $(call add_json_list, PreoptFlags, $(PRODUCT_DEX_PREOPT_DEFAULT_FLAGS)) |
| 131 | $(call add_json_str, DefaultCompilerFilter, $(PRODUCT_DEX_PREOPT_DEFAULT_COMPILER_FILTER)) |
| 132 | $(call add_json_str, SystemServerCompilerFilter, $(PRODUCT_SYSTEM_SERVER_COMPILER_FILTER)) |
| 133 | $(call add_json_bool, GenerateDmFiles, $(PRODUCT_DEX_PREOPT_GENERATE_DM_FILES)) |
| 134 | $(call add_json_bool, NoDebugInfo, $(filter false,$(WITH_DEXPREOPT_DEBUG_INFO))) |
| 135 | $(call add_json_bool, AlwaysSystemServerDebugInfo, $(filter true,$(PRODUCT_SYSTEM_SERVER_DEBUG_INFO))) |
| 136 | $(call add_json_bool, NeverSystemServerDebugInfo, $(filter false,$(PRODUCT_SYSTEM_SERVER_DEBUG_INFO))) |
| 137 | $(call add_json_bool, AlwaysOtherDebugInfo, $(filter true,$(PRODUCT_OTHER_JAVA_DEBUG_INFO))) |
| 138 | $(call add_json_bool, NeverOtherDebugInfo, $(filter false,$(PRODUCT_OTHER_JAVA_DEBUG_INFO))) |
| 139 | $(call add_json_list, MissingUsesLibraries, $(INTERNAL_PLATFORM_MISSING_USES_LIBRARIES)) |
| 140 | $(call add_json_bool, IsEng, $(filter eng,$(TARGET_BUILD_VARIANT))) |
| 141 | $(call add_json_bool, SanitizeLite, $(SANITIZE_LITE)) |
| 142 | $(call add_json_bool, DefaultAppImages, $(WITH_DEX_PREOPT_APP_IMAGE)) |
| 143 | $(call add_json_str, Dex2oatXmx, $(DEX2OAT_XMX)) |
| 144 | $(call add_json_str, Dex2oatXms, $(DEX2OAT_XMS)) |
| 145 | $(call add_json_str, EmptyDirectory, $(OUT_DIR)/empty) |
| 146 | |
| 147 | $(call add_json_map, DefaultDexPreoptImageLocation) |
| 148 | $(call add_json_str, $(TARGET_ARCH), $(DEFAULT_DEX_PREOPT_BUILT_IMAGE_LOCATION)) |
| 149 | ifdef TARGET_2ND_ARCH |
| 150 | $(call add_json_str, $(TARGET_2ND_ARCH), $($(TARGET_2ND_ARCH_VAR_PREFIX)DEFAULT_DEX_PREOPT_BUILT_IMAGE_LOCATION)) |
| 151 | endif |
| 152 | $(call end_json_map) |
| 153 | |
| 154 | $(call add_json_map, CpuVariant) |
| 155 | $(call add_json_str, $(TARGET_ARCH), $(DEX2OAT_TARGET_CPU_VARIANT)) |
| 156 | ifdef TARGET_2ND_ARCH |
| 157 | $(call add_json_str, $(TARGET_2ND_ARCH), $($(TARGET_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_CPU_VARIANT)) |
| 158 | endif |
| 159 | $(call end_json_map) |
| 160 | |
| 161 | $(call add_json_map, InstructionSetFeatures) |
| 162 | $(call add_json_str, $(TARGET_ARCH), $(DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES)) |
| 163 | ifdef TARGET_2ND_ARCH |
| 164 | $(call add_json_str, $(TARGET_2ND_ARCH), $($(TARGET_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES)) |
| 165 | endif |
| 166 | $(call end_json_map) |
| 167 | |
| 168 | $(call add_json_map, Tools) |
| 169 | $(call add_json_str, Profman, $(PROFMAN)) |
| 170 | $(call add_json_str, Dex2oat, $(DEX2OAT)) |
| 171 | $(call add_json_str, Aapt, $(AAPT)) |
| 172 | $(call add_json_str, SoongZip, $(SOONG_ZIP)) |
| 173 | $(call add_json_str, Zip2zip, $(ZIP2ZIP)) |
| 174 | $(call add_json_str, VerifyUsesLibraries, $(BUILD_SYSTEM)/verify_uses_libraries.sh) |
| 175 | $(call add_json_str, ConstructContext, $(BUILD_SYSTEM)/construct_context.sh) |
| 176 | $(call end_json_map) |
| 177 | |
| 178 | $(call json_end) |
| 179 | |
| 180 | $(shell mkdir -p $(dir $(DEX_PREOPT_CONFIG))) |
| 181 | $(file >$(DEX_PREOPT_CONFIG).tmp,$(json_contents)) |
| 182 | |
| 183 | $(shell \ |
| 184 | if ! cmp -s $(DEX_PREOPT_CONFIG).tmp $(DEX_PREOPT_CONFIG); then \ |
| 185 | mv $(DEX_PREOPT_CONFIG).tmp $(DEX_PREOPT_CONFIG); \ |
| 186 | else \ |
| 187 | rm $(DEX_PREOPT_CONFIG).tmp; \ |
| 188 | fi) |
| 189 | endif |
| 190 | |
| 191 | # Dummy rule to create dexpreopt.config, it will already have been created |
| 192 | # by the $(file) call above, but a rule needs to exist to keep the dangling |
| 193 | # rule check happy. |
| 194 | $(DEX_PREOPT_CONFIG): |
| 195 | @#empty |
| 196 | |
| 197 | DEXPREOPT_GEN_DEPS := \ |
| 198 | $(PROFMAN) \ |
| 199 | $(DEX2OAT) \ |
| 200 | $(AAPT) \ |
| 201 | $(SOONG_ZIP) \ |
| 202 | $(ZIP2ZIP) \ |
| 203 | $(BUILD_SYSTEM)/verify_uses_libraries.sh \ |
| 204 | $(BUILD_SYSTEM)/construct_context.sh \ |
| 205 | |
| 206 | DEXPREOPT_GEN_DEPS += $(DEFAULT_DEX_PREOPT_BUILT_IMAGE_FILENAME) |
| 207 | ifdef TARGET_2ND_ARCH |
| 208 | ifneq ($(TARGET_TRANSLATE_2ND_ARCH),true) |
| 209 | DEXPREOPT_GEN_DEPS += $($(TARGET_2ND_ARCH_VAR_PREFIX)DEFAULT_DEX_PREOPT_BUILT_IMAGE_FILENAME) |
| 210 | endif |
| 211 | endif |
Colin Cross | ded0aec | 2019-01-17 16:22:04 -0800 | [diff] [blame^] | 212 | |
| 213 | DEXPREOPT_STRIP_DEPS := \ |
| 214 | $(ZIP2ZIP) \ |