diff --git a/core/android_manifest.mk b/core/android_manifest.mk index 21b95c27a..c641b75c8 100644 --- a/core/android_manifest.mk +++ b/core/android_manifest.mk @@ -11,13 +11,27 @@ else full_android_manifest := $(LOCAL_PATH)/$(LOCAL_MANIFEST_FILE) endif +my_full_libs_manifest_files := $(LOCAL_FULL_LIBS_MANIFEST_FILES) +my_full_libs_manifest_deps := $(LOCAL_FULL_LIBS_MANIFEST_FILES) + +# Set up dependency on aar libraries +ifdef LOCAL_STATIC_JAVA_AAR_LIBRARIES +my_full_libs_manifest_deps += $(foreach lib, $(LOCAL_STATIC_JAVA_AAR_LIBRARIES),\ + $(call intermediates-dir-for,JAVA_LIBRARIES,$(lib),,COMMON)/aar/classes.jar) +my_full_libs_manifest_files += $(foreach lib, $(LOCAL_STATIC_JAVA_AAR_LIBRARIES),\ + $(call intermediates-dir-for,JAVA_LIBRARIES,$(lib),,COMMON)/aar/AndroidManifest.xml) + +LOCAL_RESOURCE_DIR += $(foreach lib, $(LOCAL_STATIC_JAVA_AAR_LIBRARIES),\ + $(call intermediates-dir-for,JAVA_LIBRARIES,$(lib),,COMMON)/aar/res) +endif + # Set up rules to merge library manifest files -ifdef LOCAL_FULL_LIBS_MANIFEST_FILES +ifdef my_full_libs_manifest_files main_android_manifest := $(full_android_manifest) full_android_manifest := $(intermediates.COMMON)/AndroidManifest.xml -$(full_android_manifest): PRIVATE_LIBS_MANIFESTS := $(LOCAL_FULL_LIBS_MANIFEST_FILES) -$(full_android_manifest) : $(main_android_manifest) $(LOCAL_FULL_LIBS_MANIFEST_FILES) - @echo "Merge android manifest files: $@ <-- $^" +$(full_android_manifest): PRIVATE_LIBS_MANIFESTS := $(my_full_libs_manifest_files) +$(full_android_manifest) : $(main_android_manifest) $(my_full_libs_manifest_deps) + @echo "Merge android manifest files: $@ <-- $< $(PRIVATE_LIBS_MANIFESTS)" @mkdir -p $(dir $@) $(hide) $(ANDROID_MANIFEST_MERGER) --main $< --libs $(PRIVATE_LIBS_MANIFESTS) \ --out $@ diff --git a/core/clear_vars.mk b/core/clear_vars.mk index 361988067..bf81ebf12 100644 --- a/core/clear_vars.mk +++ b/core/clear_vars.mk @@ -30,6 +30,7 @@ LOCAL_MODULE_TAGS:= LOCAL_SRC_FILES:= LOCAL_PREBUILT_OBJ_FILES:= LOCAL_STATIC_JAVA_LIBRARIES:= +LOCAL_STATIC_JAVA_AAR_LIBRARIES:= LOCAL_STATIC_LIBRARIES:= # Group static libraries with "-Wl,--start-group" and "-Wl,--end-group" when linking. LOCAL_GROUP_STATIC_LIBRARIES:= diff --git a/core/java.mk b/core/java.mk index debdf53db..a96925467 100644 --- a/core/java.mk +++ b/core/java.mk @@ -52,6 +52,9 @@ else endif endif +# LOCAL_STATIC_JAVA_AAR_LIBRARIES are special LOCAL_STATIC_JAVA_LIBRARIES +LOCAL_STATIC_JAVA_LIBRARIES := $(strip $(LOCAL_STATIC_JAVA_LIBRARIES) $(LOCAL_STATIC_JAVA_AAR_LIBRARIES)) + LOCAL_JAVA_LIBRARIES := $(sort $(LOCAL_JAVA_LIBRARIES)) LOCAL_BUILT_MODULE_STEM := $(strip $(LOCAL_BUILT_MODULE_STEM)) diff --git a/core/package_internal.mk b/core/package_internal.mk index 933b32f05..50e2e7593 100644 --- a/core/package_internal.mk +++ b/core/package_internal.mk @@ -192,6 +192,8 @@ endif # LOCAL_EMMA_INSTRUMENT rs_compatibility_jni_libs := +include $(BUILD_SYSTEM)/android_manifest.mk + ################################# include $(BUILD_SYSTEM)/java.mk ################################# @@ -201,8 +203,6 @@ ifeq ($(LOCAL_SDK_RES_VERSION),) LOCAL_SDK_RES_VERSION:=$(LOCAL_SDK_VERSION) endif -include $(BUILD_SYSTEM)/android_manifest.mk - $(LOCAL_INTERMEDIATE_TARGETS): \ PRIVATE_ANDROID_MANIFEST := $(full_android_manifest) ifneq (,$(filter-out current system_current, $(LOCAL_SDK_VERSION))) diff --git a/core/prebuilt_internal.mk b/core/prebuilt_internal.mk index e7a66f037..bc6088fa2 100644 --- a/core/prebuilt_internal.mk +++ b/core/prebuilt_internal.mk @@ -260,10 +260,26 @@ ifeq ($(LOCAL_IS_HOST_MODULE)$(LOCAL_MODULE_CLASS),JAVA_LIBRARIES) # while the deps should be in the common dir, so we make a copy in the common dir. # For nonstatic library, $(common_javalib_jar) is the dependency file, # while $(common_classes_jar) is used to link. -common_classes_jar := $(call intermediates-dir-for,JAVA_LIBRARIES,$(LOCAL_MODULE),,COMMON)/classes.jar -common_javalib_jar := $(dir $(common_classes_jar))javalib.jar +common_classes_jar := $(intermediates.COMMON)/classes.jar +common_javalib_jar := $(intermediates.COMMON)/javalib.jar -$(common_classes_jar) : $(my_prebuilt_src_file) | $(ACP) +$(common_classes_jar) $(common_javalib_jar): PRIVATE_MODULE := $(LOCAL_MODULE) + +ifneq ($(filter %.aar, $(my_prebuilt_src_file)),) +# This is .aar file, archive of classes.jar and Android resources. +my_src_jar := $(intermediates.COMMON)/aar/classes.jar + +$(my_src_jar) : $(my_prebuilt_src_file) + $(hide) rm -rf $(dir $@) && mkdir -p $(dir $@) + $(hide) unzip -qo -d $(dir $@) $< + # Make sure the extracted classes.jar has a new timestamp. + $(hide) touch $@ + +else +# This is jar file. +my_src_jar := $(my_prebuilt_src_file) +endif +$(common_classes_jar) : $(my_src_jar) | $(ACP) $(transform-prebuilt-to-target) $(common_javalib_jar) : $(common_classes_jar) | $(ACP)