From af9757e84940a3d3f4a4b88d2f1ed259d4f43c02 Mon Sep 17 00:00:00 2001 From: Ying Wang Date: Thu, 17 Jul 2014 21:24:42 -0700 Subject: [PATCH] New installation path for apks and their JNIs. Apk's path is changed to /MyApp/MyApp.apk; JNI path is changed to /MyApp/lib//libfoo.so. Symlinks of JNIs are changed accordingly. Bug: 16319961 Change-Id: Ib3b2309c95fa9aea27837fcc29e28d990b04747b --- CleanSpec.mk | 2 ++ core/base_rules.mk | 7 +++++++ core/definitions.mk | 4 ++-- core/install_jni_libs_internal.mk | 10 +++++++--- core/package_internal.mk | 1 + core/post_clean.mk | 1 + core/prebuilt_internal.mk | 5 +++++ 7 files changed, 25 insertions(+), 5 deletions(-) diff --git a/CleanSpec.mk b/CleanSpec.mk index 7175b0e741..4e90c904a9 100644 --- a/CleanSpec.mk +++ b/CleanSpec.mk @@ -281,6 +281,8 @@ $(call add-clean-step, rm -rf $(PRODUCT_OUT)/recovery/root/default.prop) # dalvik.vm.image-dex2oat-Xms, and dalvik.vm.image-dex2oat-Xmx $(call add-clean-step, rm -rf $(PRODUCT_OUT)/root/default.prop) $(call add-clean-step, rm -rf $(PRODUCT_OUT)/recovery/root/default.prop) + +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system) # ************************************************ # NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST # ************************************************ diff --git a/core/base_rules.mk b/core/base_rules.mk index a4f13605b7..2984d9d898 100644 --- a/core/base_rules.mk +++ b/core/base_rules.mk @@ -179,6 +179,13 @@ LOCAL_BUILT_MODULE := $(built_module_path)/$(my_built_module_stem) built_module_path := ifneq (true,$(LOCAL_UNINSTALLABLE_MODULE)) + # Apk and its attachments reside in its own subdir. + ifeq ($(LOCAL_MODULE_CLASS),APPS) + # framework-res.apk doesn't like the additional layer. + ifneq ($(LOCAL_NO_STANDARD_LIBRARIES),true) + my_module_path := $(my_module_path)/$(LOCAL_MODULE) + endif + endif LOCAL_INSTALLED_MODULE := $(my_module_path)/$(my_installed_module_stem) endif diff --git a/core/definitions.mk b/core/definitions.mk index d7c68f3006..66565919d0 100644 --- a/core/definitions.mk +++ b/core/definitions.mk @@ -1689,7 +1689,7 @@ endef define transform-classes.jar-to-dex @echo "target Dex: $(PRIVATE_MODULE)" @mkdir -p $(dir $@) -$(hide) rm -f $(dir $@)/classes*.dex +$(hide) rm -f $(dir $@)classes*.dex $(hide) $(DX) \ $(if $(findstring windows,$(HOST_OS)),,-JXms16M -JXmx2048M) \ --dex --output=$(dir $@) \ @@ -1762,7 +1762,7 @@ endef #TODO: update the manifest to point to the dex file define add-dex-to-package -$(hide) zip -qj $@ $(dir $(PRIVATE_DEX_FILE))/classes*.dex +$(hide) zip -qj $@ $(dir $(PRIVATE_DEX_FILE))classes*.dex endef # Add java resources added by the current module. diff --git a/core/install_jni_libs_internal.mk b/core/install_jni_libs_internal.mk index eb90c500f4..944420b838 100644 --- a/core/install_jni_libs_internal.mk +++ b/core/install_jni_libs_internal.mk @@ -18,7 +18,7 @@ my_jni_shared_libraries := \ $(LOCAL_JNI_SHARED_LIBRARIES))) # App-specific lib path. -my_app_lib_path := $($(my_2nd_arch_prefix)TARGET_OUT$(partition_tag)_SHARED_LIBRARIES)/$(basename $(my_installed_module_stem)) +my_app_lib_path := $(dir $(LOCAL_INSTALLED_MODULE))lib/$(TARGET_$(my_2nd_arch_prefix)ARCH) my_extracted_jni_libs := ifdef my_embed_jni @@ -54,16 +54,20 @@ ifneq ($(my_jni_shared_libraries),) # The jni libaries will be installed to the system.img. my_jni_filenames := $(notdir $(my_jni_shared_libraries)) # Make sure the JNI libraries get installed -$(LOCAL_INSTALLED_MODULE) : | $(addprefix $($(my_2nd_arch_prefix)TARGET_OUT$(partition_tag)_SHARED_LIBRARIES)/, $(my_jni_filenames)) +my_shared_library_path := $($(my_2nd_arch_prefix)TARGET_OUT$(partition_tag)_SHARED_LIBRARIES) +$(LOCAL_INSTALLED_MODULE) : | $(addprefix $(my_shared_library_path)/, $(my_jni_filenames)) # Create symlink in the app specific lib path ifdef LOCAL_POST_INSTALL_CMD # Add a shell command separator LOCAL_POST_INSTALL_CMD += ; endif + +my_symlink_target_dir := $(patsubst $(PRODUCT_OUT)%,%,\ + $(my_shared_library_path)) LOCAL_POST_INSTALL_CMD += \ mkdir -p $(my_app_lib_path) \ - $(foreach lib, $(my_jni_filenames), ;ln -sf ../$(lib) $(my_app_lib_path)/$(lib)) + $(foreach lib, $(my_jni_filenames), ;ln -sf $(my_symlink_target_dir)/$(lib) $(my_app_lib_path)/$(lib)) $(LOCAL_INSTALLED_MODULE): PRIVATE_POST_INSTALL_CMD := $(LOCAL_POST_INSTALL_CMD) # Clear jni_shared_libraries to not embed it into the apk. diff --git a/core/package_internal.mk b/core/package_internal.mk index 57b7b1f254..12d878e1ae 100644 --- a/core/package_internal.mk +++ b/core/package_internal.mk @@ -130,6 +130,7 @@ LOCAL_INTERMEDIATE_TARGETS += $(R_file_stamp) endif LOCAL_BUILT_MODULE_STEM := package.apk +LOCAL_INSTALLED_MODULE_STEM := $(LOCAL_MODULE).apk LOCAL_PROGUARD_ENABLED:=$(strip $(LOCAL_PROGUARD_ENABLED)) ifndef LOCAL_PROGUARD_ENABLED diff --git a/core/post_clean.mk b/core/post_clean.mk index 9f15b6d309..f7e654b50d 100644 --- a/core/post_clean.mk +++ b/core/post_clean.mk @@ -72,6 +72,7 @@ $(foreach p, $(ALL_MODULES), \ $(shell echo 'AIDL_FILES.$(p) := $(ALL_MODULES.$(p).AIDL_FILES)' >> $(current_aidl_config)))\ $(if $(filter-out $(ALL_MODULES.$(p).AIDL_FILES),$(AIDL_FILES.$(p))),\ $(eval intermediates_to_clean += $(ALL_MODULES.$(p).INTERMEDIATE_SOURCE_DIR)))) +intermediates_to_clean := $(strip $(intermediates_to_clean)) ifdef intermediates_to_clean $(info *** Obsolete aidl-generated files detected, clean intermediate files...) $(info *** rm -rf $(intermediates_to_clean)) diff --git a/core/prebuilt_internal.mk b/core/prebuilt_internal.mk index 1ee9f9ab1e..23ca279d7b 100644 --- a/core/prebuilt_internal.mk +++ b/core/prebuilt_internal.mk @@ -54,6 +54,11 @@ ifeq (STATIC_LIBRARIES,$(LOCAL_MODULE_CLASS)) endif endif +ifeq ($(LOCAL_MODULE_CLASS),APPS) +LOCAL_BUILT_MODULE_STEM := package.apk +LOCAL_INSTALLED_MODULE_STEM := $(LOCAL_MODULE).apk +endif + ifeq ($(LOCAL_STRIP_MODULE),true) ifdef LOCAL_IS_HOST_MODULE $(error Cannot strip host module LOCAL_PATH=$(LOCAL_PATH))