From 6ef5779c988af610e5ff18866479e5a8ff296d9d Mon Sep 17 00:00:00 2001 From: Ulya Trafimovich Date: Thu, 8 Apr 2021 11:47:00 +0100 Subject: [PATCH] Don't expect all Java modules to have a manifest. Some libraries that go through manifest_check do not have a manifest or APK, so there is nothing to check LOCAL_USES_LIBRARIES and LOCAL_OPTIONAL_USES_LIBRARIES against. Handle it as if the manifest had zero tags: don't fail the build unless the module has non-empty LOCAL_USES_LIBRARIES or LOCAL_OPTIONAL_USES_LIBRARIES. Bug: 132357300 Test: lunch cf_x86_64_phone-userdebug && m Change-Id: I4b1317cfbd93cb6129caba51b56081307a564442 --- core/app_prebuilt_internal.mk | 3 ++- core/dex_preopt_odex_install.mk | 13 ++++++++++++- core/java_prebuilt_internal.mk | 1 - 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/core/app_prebuilt_internal.mk b/core/app_prebuilt_internal.mk index fe04b84d4..6335728a8 100644 --- a/core/app_prebuilt_internal.mk +++ b/core/app_prebuilt_internal.mk @@ -169,12 +169,13 @@ LOCAL_DEX_PREOPT := false endif my_dex_jar := $(my_prebuilt_src_file) -my_manifest_or_apk := $(my_prebuilt_src_file) dex_preopt_profile_src_file := $(my_prebuilt_src_file) ####################################### # defines built_odex along with rule to install odex +my_manifest_or_apk := $(my_prebuilt_src_file) include $(BUILD_SYSTEM)/dex_preopt_odex_install.mk +my_manifest_or_apk := ####################################### ifneq ($(LOCAL_REPLACE_PREBUILT_APK_INSTALLED),) # There is a replacement for the prebuilt .apk we can install without any processing. diff --git a/core/dex_preopt_odex_install.mk b/core/dex_preopt_odex_install.mk index e0f94bd41..6b05d0d66 100644 --- a/core/dex_preopt_odex_install.mk +++ b/core/dex_preopt_odex_install.mk @@ -208,6 +208,17 @@ add_json_class_loader_context = \ # Verify coherence between the build system and the manifest. ################################################################################ +# Some libraries do not have a manifest, so there is nothing to check against. +# Handle it as if the manifest had zero tags: it is ok unless the +# module has non-empty LOCAL_USES_LIBRARIES or LOCAL_OPTIONAL_USES_LIBRARIES. +ifndef my_manifest_or_apk + ifneq (,$(strip $(LOCAL_USES_LIBRARIES)$(LOCAL_OPTIONAL_USES_LIBRARIES))) + $(error $(LOCAL_MODULE) has non-empty list but no manifest) + else + LOCAL_ENFORCE_USES_LIBRARIES := false + endif +endif + # Verify LOCAL_USES_LIBRARIES/LOCAL_OPTIONAL_USES_LIBRARIES # If LOCAL_ENFORCE_USES_LIBRARIES is not set, default to true if either of LOCAL_USES_LIBRARIES or # LOCAL_OPTIONAL_USES_LIBRARIES are specified. @@ -360,7 +371,7 @@ ifdef LOCAL_DEX_PREOPT $(call add_json_str, ProfileClassListing, $(if $(my_process_profile),$(LOCAL_DEX_PREOPT_PROFILE))) $(call add_json_bool, ProfileIsTextListing, $(my_profile_is_text_listing)) $(call add_json_str, EnforceUsesLibrariesStatusFile, $(my_enforced_uses_libraries)) - $(call add_json_bool, EnforceUsesLibraries, $(LOCAL_ENFORCE_USES_LIBRARIES)) + $(call add_json_bool, EnforceUsesLibraries, $(filter true,$(LOCAL_ENFORCE_USES_LIBRARIES))) $(call add_json_str, ProvidesUsesLibrary, $(firstword $(LOCAL_PROVIDES_USES_LIBRARY) $(LOCAL_MODULE))) $(call add_json_map, ClassLoaderContexts) $(call add_json_class_loader_context, any, $(my_dexpreopt_libs)) diff --git a/core/java_prebuilt_internal.mk b/core/java_prebuilt_internal.mk index 990b7d4c1..be733ff6c 100644 --- a/core/java_prebuilt_internal.mk +++ b/core/java_prebuilt_internal.mk @@ -33,7 +33,6 @@ endif ifeq ($(prebuilt_module_is_dex_javalib),true) my_dex_jar := $(my_prebuilt_src_file) -my_manifest_or_apk := $(my_prebuilt_src_file) # This is a target shared library, i.e. a jar with classes.dex. $(foreach pair,$(PRODUCT_BOOT_JARS), \