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