2019-05-10 06:50:21 +02:00
|
|
|
DEX_PREOPT_CONFIG := $(SOONG_OUT_DIR)/dexpreopt.config
|
2018-11-17 06:26:33 +01:00
|
|
|
|
2020-06-04 21:47:55 +02:00
|
|
|
ENABLE_PREOPT := true
|
2021-01-15 19:45:15 +01:00
|
|
|
ENABLE_PREOPT_BOOT_IMAGES := true
|
2020-06-04 21:47:55 +02:00
|
|
|
ifneq (true,$(filter true,$(WITH_DEXPREOPT)))
|
2021-01-15 19:45:15 +01:00
|
|
|
# Disable dexpreopt for libraries/apps and for boot images.
|
2020-06-04 21:47:55 +02:00
|
|
|
ENABLE_PREOPT :=
|
2021-01-15 19:45:15 +01:00
|
|
|
ENABLE_PREOPT_BOOT_IMAGES :=
|
2020-06-04 21:47:55 +02:00
|
|
|
else ifneq (true,$(filter true,$(PRODUCT_USES_DEFAULT_ART_CONFIG)))
|
2021-01-15 19:45:15 +01:00
|
|
|
# Disable dexpreopt for libraries/apps and for boot images: not having default
|
|
|
|
# ART config means that some important system properties are not set, which
|
|
|
|
# would result in passing bad arguments to dex2oat and failing the build.
|
2020-06-04 21:47:55 +02:00
|
|
|
ENABLE_PREOPT :=
|
2021-01-15 19:45:15 +01:00
|
|
|
ENABLE_PREOPT_BOOT_IMAGES :=
|
2023-05-10 14:49:05 +02:00
|
|
|
else
|
|
|
|
ifeq (true,$(DISABLE_PREOPT))
|
|
|
|
# Disable dexpreopt for libraries/apps, but may compile boot images.
|
|
|
|
ENABLE_PREOPT :=
|
|
|
|
endif
|
|
|
|
ifeq (true,$(DISABLE_PREOPT_BOOT_IMAGES))
|
|
|
|
# Disable dexpreopt for boot images, but may compile libraries/apps.
|
|
|
|
ENABLE_PREOPT_BOOT_IMAGES :=
|
|
|
|
endif
|
2020-06-04 21:47:55 +02:00
|
|
|
endif
|
|
|
|
|
2018-11-17 06:26:33 +01:00
|
|
|
# The default value for LOCAL_DEX_PREOPT
|
2021-01-11 17:42:21 +01:00
|
|
|
DEX_PREOPT_DEFAULT ?= $(ENABLE_PREOPT)
|
2018-11-17 06:26:33 +01:00
|
|
|
|
2021-03-22 18:24:18 +01:00
|
|
|
# Whether to fail immediately if verify_uses_libraries check fails, or to keep
|
|
|
|
# going and restrict dexpreopt to not compile any code for the failed module.
|
|
|
|
#
|
|
|
|
# The intended use case for this flag is to have a smoother migration path for
|
|
|
|
# the Java modules that need to add <uses-library> information in their build
|
|
|
|
# files. The flag allows to quickly silence build errors. This flag should be
|
|
|
|
# used with caution and only as a temporary measure, as it masks real errors
|
|
|
|
# and affects performance.
|
|
|
|
ifndef RELAX_USES_LIBRARY_CHECK
|
|
|
|
RELAX_USES_LIBRARY_CHECK := $(if \
|
|
|
|
$(filter true,$(PRODUCT_BROKEN_VERIFY_USES_LIBRARIES)),true,false)
|
|
|
|
else
|
|
|
|
# Let the environment variable override PRODUCT_BROKEN_VERIFY_USES_LIBRARIES.
|
|
|
|
endif
|
|
|
|
.KATI_READONLY := RELAX_USES_LIBRARY_CHECK
|
|
|
|
|
2018-11-17 06:26:33 +01:00
|
|
|
# The default filter for which files go into the system_other image (if it is
|
2019-10-02 19:13:19 +02:00
|
|
|
# being used). Note that each pattern p here matches both '/<p>' and /system/<p>'.
|
|
|
|
# To bundle everything one should set this to '%'.
|
2018-11-17 06:26:33 +01:00
|
|
|
SYSTEM_OTHER_ODEX_FILTER ?= \
|
|
|
|
app/% \
|
|
|
|
priv-app/% \
|
2019-06-25 08:58:13 +02:00
|
|
|
system_ext/app/% \
|
|
|
|
system_ext/priv-app/% \
|
2018-11-17 06:26:33 +01:00
|
|
|
product/app/% \
|
|
|
|
product/priv-app/% \
|
|
|
|
|
2021-03-29 12:48:33 +02:00
|
|
|
# Global switch to control if updatable boot jars are included in dexpreopt.
|
|
|
|
DEX_PREOPT_WITH_UPDATABLE_BCP := true
|
2021-03-23 17:46:18 +01:00
|
|
|
|
2018-11-17 06:26:33 +01:00
|
|
|
# Conditional to building on linux, as dex2oat currently does not work on darwin.
|
|
|
|
ifeq ($(HOST_OS),linux)
|
|
|
|
ifeq (eng,$(TARGET_BUILD_VARIANT))
|
|
|
|
# For an eng build only pre-opt the boot image and system server. This gives reasonable performance
|
|
|
|
# and still allows a simple workflow: building in frameworks/base and syncing.
|
|
|
|
WITH_DEXPREOPT_BOOT_IMG_AND_SYSTEM_SERVER_ONLY ?= true
|
|
|
|
endif
|
|
|
|
# Add mini-debug-info to the boot classpath unless explicitly asked not to.
|
|
|
|
ifneq (false,$(WITH_DEXPREOPT_DEBUG_INFO))
|
|
|
|
PRODUCT_DEX_PREOPT_BOOT_FLAGS += --generate-mini-debug-info
|
|
|
|
endif
|
|
|
|
|
|
|
|
# Non eng linux builds must have preopt enabled so that system server doesn't run as interpreter
|
|
|
|
# only. b/74209329
|
|
|
|
ifeq (,$(filter eng, $(TARGET_BUILD_VARIANT)))
|
2023-03-28 15:15:35 +02:00
|
|
|
ifneq (true,$(WITH_DEXPREOPT))
|
|
|
|
ifneq (true,$(WITH_DEXPREOPT_BOOT_IMG_AND_SYSTEM_SERVER_ONLY))
|
|
|
|
$(call pretty-error, DEXPREOPT must be enabled for user and userdebug builds)
|
2018-11-17 06:26:33 +01:00
|
|
|
endif
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2020-05-29 10:50:03 +02:00
|
|
|
# Get value of a property. It is first searched from PRODUCT_VENDOR_PROPERTIES
|
|
|
|
# and then falls back to PRODUCT_SYSTEM_PROPERTIES
|
|
|
|
# $1: name of the property
|
2018-11-17 06:26:33 +01:00
|
|
|
define get-product-default-property
|
|
|
|
$(strip \
|
2020-05-29 10:50:03 +02:00
|
|
|
$(eval _prop := $(patsubst $(1)=%,%,$(filter $(1)=%,$(PRODUCT_VENDOR_PROPERTIES))))\
|
|
|
|
$(if $(_prop),$(_prop),$(patsubst $(1)=%,%,$(filter $(1)=%,$(PRODUCT_SYSTEM_PROPERTIES)))))
|
2018-11-17 06:26:33 +01:00
|
|
|
endef
|
|
|
|
|
|
|
|
DEX2OAT_IMAGE_XMS := $(call get-product-default-property,dalvik.vm.image-dex2oat-Xms)
|
|
|
|
DEX2OAT_IMAGE_XMX := $(call get-product-default-property,dalvik.vm.image-dex2oat-Xmx)
|
|
|
|
DEX2OAT_XMS := $(call get-product-default-property,dalvik.vm.dex2oat-Xms)
|
|
|
|
DEX2OAT_XMX := $(call get-product-default-property,dalvik.vm.dex2oat-Xmx)
|
|
|
|
|
|
|
|
ifeq ($(WRITE_SOONG_VARIABLES),true)
|
|
|
|
|
|
|
|
$(call json_start)
|
|
|
|
|
2020-06-04 21:47:55 +02:00
|
|
|
$(call add_json_bool, DisablePreopt, $(call invert_bool,$(ENABLE_PREOPT)))
|
2021-01-15 19:45:15 +01:00
|
|
|
$(call add_json_bool, DisablePreoptBootImages, $(call invert_bool,$(ENABLE_PREOPT_BOOT_IMAGES)))
|
2020-03-27 13:12:59 +01:00
|
|
|
$(call add_json_list, DisablePreoptModules, $(DEXPREOPT_DISABLED_MODULES))
|
|
|
|
$(call add_json_bool, OnlyPreoptBootImageAndSystemServer, $(filter true,$(WITH_DEXPREOPT_BOOT_IMG_AND_SYSTEM_SERVER_ONLY)))
|
2021-03-23 17:46:18 +01:00
|
|
|
$(call add_json_bool, PreoptWithUpdatableBcp, $(filter true,$(DEX_PREOPT_WITH_UPDATABLE_BCP)))
|
2020-03-27 13:12:59 +01:00
|
|
|
$(call add_json_bool, DontUncompressPrivAppsDex, $(filter true,$(DONT_UNCOMPRESS_PRIV_APPS_DEXS)))
|
|
|
|
$(call add_json_list, ModulesLoadedByPrivilegedModules, $(PRODUCT_LOADED_BY_PRIVILEGED_MODULES))
|
|
|
|
$(call add_json_bool, HasSystemOther, $(BOARD_USES_SYSTEM_OTHER_ODEX))
|
|
|
|
$(call add_json_list, PatternsOnSystemOther, $(SYSTEM_OTHER_ODEX_FILTER))
|
|
|
|
$(call add_json_bool, DisableGenerateProfile, $(filter false,$(WITH_DEX_PREOPT_GENERATE_PROFILE)))
|
|
|
|
$(call add_json_str, ProfileDir, $(PRODUCT_DEX_PREOPT_PROFILE_DIR))
|
|
|
|
$(call add_json_list, BootJars, $(PRODUCT_BOOT_JARS))
|
2021-07-21 15:14:44 +02:00
|
|
|
$(call add_json_list, ApexBootJars, $(PRODUCT_APEX_BOOT_JARS))
|
2021-04-14 21:30:07 +02:00
|
|
|
$(call add_json_list, ArtApexJars, $(filter $(PRODUCT_BOOT_JARS),$(ART_APEX_JARS)))
|
2023-07-12 17:55:10 +02:00
|
|
|
$(call add_json_list, TestOnlyArtBootImageJars, $(PRODUCT_TEST_ONLY_ART_BOOT_IMAGE_JARS))
|
2020-03-27 13:12:59 +01:00
|
|
|
$(call add_json_list, SystemServerJars, $(PRODUCT_SYSTEM_SERVER_JARS))
|
|
|
|
$(call add_json_list, SystemServerApps, $(PRODUCT_SYSTEM_SERVER_APPS))
|
2021-07-28 15:03:57 +02:00
|
|
|
$(call add_json_list, ApexSystemServerJars, $(PRODUCT_APEX_SYSTEM_SERVER_JARS))
|
2021-10-28 16:37:20 +02:00
|
|
|
$(call add_json_list, StandaloneSystemServerJars, $(PRODUCT_STANDALONE_SYSTEM_SERVER_JARS))
|
|
|
|
$(call add_json_list, ApexStandaloneSystemServerJars, $(PRODUCT_APEX_STANDALONE_SYSTEM_SERVER_JARS))
|
2020-03-27 13:12:59 +01:00
|
|
|
$(call add_json_bool, BrokenSuboptimalOrderOfSystemServerJars, $(PRODUCT_BROKEN_SUBOPTIMAL_ORDER_OF_SYSTEM_SERVER_JARS))
|
|
|
|
$(call add_json_list, SpeedApps, $(PRODUCT_DEXPREOPT_SPEED_APPS))
|
|
|
|
$(call add_json_list, PreoptFlags, $(PRODUCT_DEX_PREOPT_DEFAULT_FLAGS))
|
|
|
|
$(call add_json_str, DefaultCompilerFilter, $(PRODUCT_DEX_PREOPT_DEFAULT_COMPILER_FILTER))
|
|
|
|
$(call add_json_str, SystemServerCompilerFilter, $(PRODUCT_SYSTEM_SERVER_COMPILER_FILTER))
|
|
|
|
$(call add_json_bool, GenerateDmFiles, $(PRODUCT_DEX_PREOPT_GENERATE_DM_FILES))
|
|
|
|
$(call add_json_bool, NeverAllowStripping, $(PRODUCT_DEX_PREOPT_NEVER_ALLOW_STRIPPING))
|
|
|
|
$(call add_json_bool, NoDebugInfo, $(filter false,$(WITH_DEXPREOPT_DEBUG_INFO)))
|
|
|
|
$(call add_json_bool, DontResolveStartupStrings, $(filter false,$(PRODUCT_DEX_PREOPT_RESOLVE_STARTUP_STRINGS)))
|
|
|
|
$(call add_json_bool, AlwaysSystemServerDebugInfo, $(filter true,$(PRODUCT_SYSTEM_SERVER_DEBUG_INFO)))
|
|
|
|
$(call add_json_bool, NeverSystemServerDebugInfo, $(filter false,$(PRODUCT_SYSTEM_SERVER_DEBUG_INFO)))
|
|
|
|
$(call add_json_bool, AlwaysOtherDebugInfo, $(filter true,$(PRODUCT_OTHER_JAVA_DEBUG_INFO)))
|
|
|
|
$(call add_json_bool, NeverOtherDebugInfo, $(filter false,$(PRODUCT_OTHER_JAVA_DEBUG_INFO)))
|
|
|
|
$(call add_json_bool, IsEng, $(filter eng,$(TARGET_BUILD_VARIANT)))
|
|
|
|
$(call add_json_bool, SanitizeLite, $(SANITIZE_LITE))
|
|
|
|
$(call add_json_bool, DefaultAppImages, $(WITH_DEX_PREOPT_APP_IMAGE))
|
Add non-fatal mode for verify_uses_libraries check.
The new mode is enabled with environment variable
RELAX_USES_LIBRARY_CHECK. If the variable is set to true, then a
verify_uses_libraries check failure does not fail the build, instead it
sets a special compiler filter "extract" for dexpreopt, which means that
the DEX file will be extracted, but it won't be compiled to native code.
Class loader context will be set to empty in this case (not &, as it is
going to be deprecated soon).
If the variable RELAX_USES_LIBRARY_CHECK is unset or set to something
other than "true", then the old behaviour of the verify_uses_libraries
check is preserved.
The intended use case for this flag is to have a smoother migration path
for the Java modules that need to add <uses-library> information in
the build files. The flag allows to quickly silence build errors. This
flag should be used with caution and only as a temporary measure, as it
masks real errors and affects performance.
verify_uses_libraries check is reworked so that it writes the error
message to a status file (which is used instead of the former timestamp
file). Currently the stored error message is not used, but it may be
used later to produce a warning. Dexpreopt command checks if the status
file exists and is nonempty; if that is the case, then compiler filter
is set to "extract".
Bug: 132357300
Test: Manually add some mismatch between the libraries in the Android.bp
and Android.mk files for dexpreopted apps, build with
RELAX_USES_LIBRARY_CHECK=true and obsserve that the build doesn't
fail and they are compiled with compiler-filter "extract".
Unset RELAX_USES_LIBRARY_CHECK and observe that the build fails.
Change-Id: Ie1a6298c4dba2f368ca9ac8b9fee2de0a26e68e8
2021-02-17 17:05:21 +01:00
|
|
|
$(call add_json_bool, RelaxUsesLibraryCheck, $(filter true,$(RELAX_USES_LIBRARY_CHECK)))
|
2020-03-27 13:12:59 +01:00
|
|
|
$(call add_json_str, Dex2oatXmx, $(DEX2OAT_XMX))
|
|
|
|
$(call add_json_str, Dex2oatXms, $(DEX2OAT_XMS))
|
|
|
|
$(call add_json_str, EmptyDirectory, $(OUT_DIR)/empty)
|
2022-11-23 12:20:29 +01:00
|
|
|
$(call add_json_bool, EnableUffdGc, $(filter true,$(ENABLE_UFFD_GC)))
|
2018-11-17 06:26:33 +01:00
|
|
|
|
2020-11-27 12:00:38 +01:00
|
|
|
ifdef TARGET_ARCH
|
2018-11-17 06:26:33 +01:00
|
|
|
$(call add_json_map, CpuVariant)
|
|
|
|
$(call add_json_str, $(TARGET_ARCH), $(DEX2OAT_TARGET_CPU_VARIANT))
|
|
|
|
ifdef TARGET_2ND_ARCH
|
|
|
|
$(call add_json_str, $(TARGET_2ND_ARCH), $($(TARGET_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_CPU_VARIANT))
|
|
|
|
endif
|
|
|
|
$(call end_json_map)
|
|
|
|
|
|
|
|
$(call add_json_map, InstructionSetFeatures)
|
|
|
|
$(call add_json_str, $(TARGET_ARCH), $(DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES))
|
|
|
|
ifdef TARGET_2ND_ARCH
|
|
|
|
$(call add_json_str, $(TARGET_2ND_ARCH), $($(TARGET_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES))
|
|
|
|
endif
|
|
|
|
$(call end_json_map)
|
2020-11-27 12:00:38 +01:00
|
|
|
endif
|
2018-11-17 06:26:33 +01:00
|
|
|
|
2019-02-15 21:59:09 +01:00
|
|
|
$(call add_json_list, BootImageProfiles, $(PRODUCT_DEX_PREOPT_BOOT_IMAGE_PROFILE_LOCATION))
|
2019-02-11 23:25:13 +01:00
|
|
|
$(call add_json_str, BootFlags, $(PRODUCT_DEX_PREOPT_BOOT_FLAGS))
|
|
|
|
$(call add_json_str, Dex2oatImageXmx, $(DEX2OAT_IMAGE_XMX))
|
|
|
|
$(call add_json_str, Dex2oatImageXms, $(DEX2OAT_IMAGE_XMS))
|
|
|
|
|
2018-11-17 06:26:33 +01:00
|
|
|
$(call json_end)
|
|
|
|
|
|
|
|
$(shell mkdir -p $(dir $(DEX_PREOPT_CONFIG)))
|
|
|
|
$(file >$(DEX_PREOPT_CONFIG).tmp,$(json_contents))
|
|
|
|
|
|
|
|
$(shell \
|
|
|
|
if ! cmp -s $(DEX_PREOPT_CONFIG).tmp $(DEX_PREOPT_CONFIG); then \
|
|
|
|
mv $(DEX_PREOPT_CONFIG).tmp $(DEX_PREOPT_CONFIG); \
|
|
|
|
else \
|
|
|
|
rm $(DEX_PREOPT_CONFIG).tmp; \
|
|
|
|
fi)
|
|
|
|
endif
|