blob: 67394595f6ffafcea3f87528f999e692c7e96f2b [file] [log] [blame]
Colin Cross51ba1df2019-05-09 21:50:21 -07001DEX_PREOPT_CONFIG := $(SOONG_OUT_DIR)/dexpreopt.config
Colin Cross6db5b0e2018-11-16 21:26:33 -08002
Martin Stjernholmf712ba92020-06-04 20:47:55 +01003ENABLE_PREOPT := true
Ulya Trafimovich7f8b7a12021-01-15 18:45:15 +00004ENABLE_PREOPT_BOOT_IMAGES := true
Martin Stjernholmf712ba92020-06-04 20:47:55 +01005ifneq (true,$(filter true,$(WITH_DEXPREOPT)))
Ulya Trafimovich7f8b7a12021-01-15 18:45:15 +00006 # Disable dexpreopt for libraries/apps and for boot images.
Martin Stjernholmf712ba92020-06-04 20:47:55 +01007 ENABLE_PREOPT :=
Ulya Trafimovich7f8b7a12021-01-15 18:45:15 +00008 ENABLE_PREOPT_BOOT_IMAGES :=
Martin Stjernholmf712ba92020-06-04 20:47:55 +01009else ifneq (true,$(filter true,$(PRODUCT_USES_DEFAULT_ART_CONFIG)))
Ulya Trafimovich7f8b7a12021-01-15 18:45:15 +000010 # 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.
Martin Stjernholmf712ba92020-06-04 20:47:55 +010013 ENABLE_PREOPT :=
Ulya Trafimovich7f8b7a12021-01-15 18:45:15 +000014 ENABLE_PREOPT_BOOT_IMAGES :=
Jiakai Zhangc74a4012023-05-10 13:49:05 +010015else
16 ifeq (true,$(DISABLE_PREOPT))
17 # Disable dexpreopt for libraries/apps, but may compile boot images.
18 ENABLE_PREOPT :=
19 endif
20 ifeq (true,$(DISABLE_PREOPT_BOOT_IMAGES))
21 # Disable dexpreopt for boot images, but may compile libraries/apps.
22 ENABLE_PREOPT_BOOT_IMAGES :=
23 endif
Martin Stjernholmf712ba92020-06-04 20:47:55 +010024endif
25
Colin Cross6db5b0e2018-11-16 21:26:33 -080026# The default value for LOCAL_DEX_PREOPT
Ulya Trafimoviche245e002021-01-11 16:42:21 +000027DEX_PREOPT_DEFAULT ?= $(ENABLE_PREOPT)
Colin Cross6db5b0e2018-11-16 21:26:33 -080028
Ulya Trafimovich1a3b1452021-03-22 17:24:18 +000029# Whether to fail immediately if verify_uses_libraries check fails, or to keep
30# going and restrict dexpreopt to not compile any code for the failed module.
31#
32# The intended use case for this flag is to have a smoother migration path for
33# the Java modules that need to add <uses-library> information in their build
34# files. The flag allows to quickly silence build errors. This flag should be
35# used with caution and only as a temporary measure, as it masks real errors
36# and affects performance.
37ifndef RELAX_USES_LIBRARY_CHECK
38 RELAX_USES_LIBRARY_CHECK := $(if \
39 $(filter true,$(PRODUCT_BROKEN_VERIFY_USES_LIBRARIES)),true,false)
40else
41 # Let the environment variable override PRODUCT_BROKEN_VERIFY_USES_LIBRARIES.
42endif
43.KATI_READONLY := RELAX_USES_LIBRARY_CHECK
44
Colin Cross6db5b0e2018-11-16 21:26:33 -080045# The default filter for which files go into the system_other image (if it is
Anton Hansson3c5a18f2019-10-02 18:13:19 +010046# being used). Note that each pattern p here matches both '/<p>' and /system/<p>'.
47# To bundle everything one should set this to '%'.
Colin Cross6db5b0e2018-11-16 21:26:33 -080048SYSTEM_OTHER_ODEX_FILTER ?= \
49 app/% \
50 priv-app/% \
Justin Yun6151e3f2019-06-25 15:58:13 +090051 system_ext/app/% \
52 system_ext/priv-app/% \
Colin Cross6db5b0e2018-11-16 21:26:33 -080053 product/app/% \
54 product/priv-app/% \
55
Nicolas Geoffray5bfe9262021-03-29 11:48:33 +010056# Global switch to control if updatable boot jars are included in dexpreopt.
57DEX_PREOPT_WITH_UPDATABLE_BCP := true
Ulya Trafimovichb9f43062021-03-23 16:46:18 +000058
Colin Cross6db5b0e2018-11-16 21:26:33 -080059# Conditional to building on linux, as dex2oat currently does not work on darwin.
60ifeq ($(HOST_OS),linux)
Colin Cross6db5b0e2018-11-16 21:26:33 -080061 ifeq (eng,$(TARGET_BUILD_VARIANT))
Colin Cross6db5b0e2018-11-16 21:26:33 -080062 # For an eng build only pre-opt the boot image and system server. This gives reasonable performance
63 # and still allows a simple workflow: building in frameworks/base and syncing.
64 WITH_DEXPREOPT_BOOT_IMG_AND_SYSTEM_SERVER_ONLY ?= true
65 endif
66 # Add mini-debug-info to the boot classpath unless explicitly asked not to.
67 ifneq (false,$(WITH_DEXPREOPT_DEBUG_INFO))
68 PRODUCT_DEX_PREOPT_BOOT_FLAGS += --generate-mini-debug-info
69 endif
70
71 # Non eng linux builds must have preopt enabled so that system server doesn't run as interpreter
72 # only. b/74209329
73 ifeq (,$(filter eng, $(TARGET_BUILD_VARIANT)))
Ulya Trofimovichcc5c6a72023-03-28 13:15:35 +000074 ifneq (true,$(WITH_DEXPREOPT))
75 ifneq (true,$(WITH_DEXPREOPT_BOOT_IMG_AND_SYSTEM_SERVER_ONLY))
76 $(call pretty-error, DEXPREOPT must be enabled for user and userdebug builds)
Colin Cross6db5b0e2018-11-16 21:26:33 -080077 endif
78 endif
79 endif
80endif
81
Jiyong Parkeb49b342020-05-29 17:50:03 +090082# Get value of a property. It is first searched from PRODUCT_VENDOR_PROPERTIES
83# and then falls back to PRODUCT_SYSTEM_PROPERTIES
84# $1: name of the property
Colin Cross6db5b0e2018-11-16 21:26:33 -080085define get-product-default-property
86$(strip \
Jiyong Parkeb49b342020-05-29 17:50:03 +090087 $(eval _prop := $(patsubst $(1)=%,%,$(filter $(1)=%,$(PRODUCT_VENDOR_PROPERTIES))))\
88 $(if $(_prop),$(_prop),$(patsubst $(1)=%,%,$(filter $(1)=%,$(PRODUCT_SYSTEM_PROPERTIES)))))
Colin Cross6db5b0e2018-11-16 21:26:33 -080089endef
90
91DEX2OAT_IMAGE_XMS := $(call get-product-default-property,dalvik.vm.image-dex2oat-Xms)
92DEX2OAT_IMAGE_XMX := $(call get-product-default-property,dalvik.vm.image-dex2oat-Xmx)
93DEX2OAT_XMS := $(call get-product-default-property,dalvik.vm.dex2oat-Xms)
94DEX2OAT_XMX := $(call get-product-default-property,dalvik.vm.dex2oat-Xmx)
95
Colin Cross6db5b0e2018-11-16 21:26:33 -080096ifeq ($(WRITE_SOONG_VARIABLES),true)
97
98 $(call json_start)
99
Martin Stjernholmf712ba92020-06-04 20:47:55 +0100100 $(call add_json_bool, DisablePreopt, $(call invert_bool,$(ENABLE_PREOPT)))
Ulya Trafimovich7f8b7a12021-01-15 18:45:15 +0000101 $(call add_json_bool, DisablePreoptBootImages, $(call invert_bool,$(ENABLE_PREOPT_BOOT_IMAGES)))
Ulya Trafimovich40e55c22020-03-27 12:12:59 +0000102 $(call add_json_list, DisablePreoptModules, $(DEXPREOPT_DISABLED_MODULES))
103 $(call add_json_bool, OnlyPreoptBootImageAndSystemServer, $(filter true,$(WITH_DEXPREOPT_BOOT_IMG_AND_SYSTEM_SERVER_ONLY)))
Ulya Trafimovichb9f43062021-03-23 16:46:18 +0000104 $(call add_json_bool, PreoptWithUpdatableBcp, $(filter true,$(DEX_PREOPT_WITH_UPDATABLE_BCP)))
Ulya Trafimovich40e55c22020-03-27 12:12:59 +0000105 $(call add_json_bool, DontUncompressPrivAppsDex, $(filter true,$(DONT_UNCOMPRESS_PRIV_APPS_DEXS)))
106 $(call add_json_list, ModulesLoadedByPrivilegedModules, $(PRODUCT_LOADED_BY_PRIVILEGED_MODULES))
107 $(call add_json_bool, HasSystemOther, $(BOARD_USES_SYSTEM_OTHER_ODEX))
108 $(call add_json_list, PatternsOnSystemOther, $(SYSTEM_OTHER_ODEX_FILTER))
109 $(call add_json_bool, DisableGenerateProfile, $(filter false,$(WITH_DEX_PREOPT_GENERATE_PROFILE)))
110 $(call add_json_str, ProfileDir, $(PRODUCT_DEX_PREOPT_PROFILE_DIR))
111 $(call add_json_list, BootJars, $(PRODUCT_BOOT_JARS))
satayev8bc189e2021-07-21 14:14:44 +0100112 $(call add_json_list, ApexBootJars, $(PRODUCT_APEX_BOOT_JARS))
Paul Duffind418e962021-04-14 20:30:07 +0100113 $(call add_json_list, ArtApexJars, $(filter $(PRODUCT_BOOT_JARS),$(ART_APEX_JARS)))
Jiakai Zhang7bdb2b32023-07-12 16:55:10 +0100114 $(call add_json_list, TestOnlyArtBootImageJars, $(PRODUCT_TEST_ONLY_ART_BOOT_IMAGE_JARS))
Ulya Trafimovich40e55c22020-03-27 12:12:59 +0000115 $(call add_json_list, SystemServerJars, $(PRODUCT_SYSTEM_SERVER_JARS))
116 $(call add_json_list, SystemServerApps, $(PRODUCT_SYSTEM_SERVER_APPS))
satayeved081792021-07-28 14:03:57 +0100117 $(call add_json_list, ApexSystemServerJars, $(PRODUCT_APEX_SYSTEM_SERVER_JARS))
Jiakai Zhang44ffb212021-10-28 14:37:20 +0000118 $(call add_json_list, StandaloneSystemServerJars, $(PRODUCT_STANDALONE_SYSTEM_SERVER_JARS))
119 $(call add_json_list, ApexStandaloneSystemServerJars, $(PRODUCT_APEX_STANDALONE_SYSTEM_SERVER_JARS))
Ulya Trafimovich40e55c22020-03-27 12:12:59 +0000120 $(call add_json_bool, BrokenSuboptimalOrderOfSystemServerJars, $(PRODUCT_BROKEN_SUBOPTIMAL_ORDER_OF_SYSTEM_SERVER_JARS))
121 $(call add_json_list, SpeedApps, $(PRODUCT_DEXPREOPT_SPEED_APPS))
122 $(call add_json_list, PreoptFlags, $(PRODUCT_DEX_PREOPT_DEFAULT_FLAGS))
123 $(call add_json_str, DefaultCompilerFilter, $(PRODUCT_DEX_PREOPT_DEFAULT_COMPILER_FILTER))
124 $(call add_json_str, SystemServerCompilerFilter, $(PRODUCT_SYSTEM_SERVER_COMPILER_FILTER))
125 $(call add_json_bool, GenerateDmFiles, $(PRODUCT_DEX_PREOPT_GENERATE_DM_FILES))
126 $(call add_json_bool, NeverAllowStripping, $(PRODUCT_DEX_PREOPT_NEVER_ALLOW_STRIPPING))
127 $(call add_json_bool, NoDebugInfo, $(filter false,$(WITH_DEXPREOPT_DEBUG_INFO)))
128 $(call add_json_bool, DontResolveStartupStrings, $(filter false,$(PRODUCT_DEX_PREOPT_RESOLVE_STARTUP_STRINGS)))
129 $(call add_json_bool, AlwaysSystemServerDebugInfo, $(filter true,$(PRODUCT_SYSTEM_SERVER_DEBUG_INFO)))
130 $(call add_json_bool, NeverSystemServerDebugInfo, $(filter false,$(PRODUCT_SYSTEM_SERVER_DEBUG_INFO)))
131 $(call add_json_bool, AlwaysOtherDebugInfo, $(filter true,$(PRODUCT_OTHER_JAVA_DEBUG_INFO)))
132 $(call add_json_bool, NeverOtherDebugInfo, $(filter false,$(PRODUCT_OTHER_JAVA_DEBUG_INFO)))
133 $(call add_json_bool, IsEng, $(filter eng,$(TARGET_BUILD_VARIANT)))
134 $(call add_json_bool, SanitizeLite, $(SANITIZE_LITE))
135 $(call add_json_bool, DefaultAppImages, $(WITH_DEX_PREOPT_APP_IMAGE))
Ulya Trafimovich5a09c202021-02-17 16:05:21 +0000136 $(call add_json_bool, RelaxUsesLibraryCheck, $(filter true,$(RELAX_USES_LIBRARY_CHECK)))
Ulya Trafimovich40e55c22020-03-27 12:12:59 +0000137 $(call add_json_str, Dex2oatXmx, $(DEX2OAT_XMX))
138 $(call add_json_str, Dex2oatXms, $(DEX2OAT_XMS))
139 $(call add_json_str, EmptyDirectory, $(OUT_DIR)/empty)
Jiakai Zhang4a30e132022-11-23 11:20:29 +0000140 $(call add_json_bool, EnableUffdGc, $(filter true,$(ENABLE_UFFD_GC)))
Colin Cross6db5b0e2018-11-16 21:26:33 -0800141
Anton Hansson41f9cc22020-11-27 11:00:38 +0000142ifdef TARGET_ARCH
Colin Cross6db5b0e2018-11-16 21:26:33 -0800143 $(call add_json_map, CpuVariant)
144 $(call add_json_str, $(TARGET_ARCH), $(DEX2OAT_TARGET_CPU_VARIANT))
145 ifdef TARGET_2ND_ARCH
146 $(call add_json_str, $(TARGET_2ND_ARCH), $($(TARGET_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_CPU_VARIANT))
147 endif
148 $(call end_json_map)
149
150 $(call add_json_map, InstructionSetFeatures)
151 $(call add_json_str, $(TARGET_ARCH), $(DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES))
152 ifdef TARGET_2ND_ARCH
153 $(call add_json_str, $(TARGET_2ND_ARCH), $($(TARGET_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES))
154 endif
155 $(call end_json_map)
Anton Hansson41f9cc22020-11-27 11:00:38 +0000156endif
Colin Cross6db5b0e2018-11-16 21:26:33 -0800157
Colin Cross36b5d1c2019-02-15 12:59:09 -0800158 $(call add_json_list, BootImageProfiles, $(PRODUCT_DEX_PREOPT_BOOT_IMAGE_PROFILE_LOCATION))
Colin Cross47e384c2019-02-11 14:25:13 -0800159 $(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 Cross6db5b0e2018-11-16 21:26:33 -0800163 $(call json_end)
164
165 $(shell mkdir -p $(dir $(DEX_PREOPT_CONFIG)))
166 $(file >$(DEX_PREOPT_CONFIG).tmp,$(json_contents))
167
168 $(shell \
169 if ! cmp -s $(DEX_PREOPT_CONFIG).tmp $(DEX_PREOPT_CONFIG); then \
170 mv $(DEX_PREOPT_CONFIG).tmp $(DEX_PREOPT_CONFIG); \
171 else \
172 rm $(DEX_PREOPT_CONFIG).tmp; \
173 fi)
174endif