diff options
author | Ying Wang <wangying@google.com> | 2014-10-29 15:48:32 -0700 |
---|---|---|
committer | Ying Wang <wangying@google.com> | 2014-11-02 16:51:49 +0000 |
commit | e9dd9f2bfceed3b5f630b0edbe3feb7f34548d8b (patch) | |
tree | b31f1dff7cec0a62864b6d56bf993d0aabebd190 /core | |
parent | e4cbc2af5f476d9eb875253584260bed807acddf (diff) | |
download | build-e9dd9f2bfceed3b5f630b0edbe3feb7f34548d8b.zip build-e9dd9f2bfceed3b5f630b0edbe3feb7f34548d8b.tar.gz build-e9dd9f2bfceed3b5f630b0edbe3feb7f34548d8b.tar.bz2 |
Add support for prebuilt AARs.
- You can give a .aar as source file to a prebuilt static Java library
module. The build system will set up dependencies and rules to extract
classes.jar and other resource files.
- To build against a prebuilt AAR module, use:
LOCAL_STATIC_JAVA_AAR_LIBRARIES := <module names of aar prebuilt AARs>
The build system will set up rules to merge the library's
AndroidManifest.xml with the main AndroidManifest.xml, add the AAR's
resource dirs and link/merge the AAR's classes.jar.
Bug: 18168693
Change-Id: Ic2c1d20572a93bd98dbc72f8a39e26b459e442c2
Diffstat (limited to 'core')
-rw-r--r-- | core/android_manifest.mk | 22 | ||||
-rw-r--r-- | core/clear_vars.mk | 1 | ||||
-rw-r--r-- | core/java.mk | 3 | ||||
-rw-r--r-- | core/package_internal.mk | 4 | ||||
-rw-r--r-- | core/prebuilt_internal.mk | 22 |
5 files changed, 43 insertions, 9 deletions
diff --git a/core/android_manifest.mk b/core/android_manifest.mk index 21b95c2..c641b75 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 92b3fc4..d9ac48f 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 debdf53..a969254 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 bb458d4..e2c3cf4 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 284884c..5fcd3be 100644 --- a/core/prebuilt_internal.mk +++ b/core/prebuilt_internal.mk @@ -247,10 +247,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) |