From feb75860ff00fa9094c0e5c18da29b00d0796bcb Mon Sep 17 00:00:00 2001 From: Ying Wang Date: Tue, 24 Sep 2013 15:56:11 -0700 Subject: [PATCH] Allow module to specify LOCAL_INSTALLED_MODULE_STEM With this change, you can install a shared library with module name foo as bar.so to the system.img with: LOCAL_INSTALLED_MODULE_STEM := bar.so Note that we in general still disallow a static/shared library to specify LOCAL_MODULE_STEM or LOCAL_BUILT_MODULE_STEM, because the build system uses LOCAL_MODULE to compute build time dependencies, such as export_includes, the -l linker flag etc. Also, if you use LOCAL_INSTALLED_MODULE_STEM to change the installed file name and if any other module links against this library, you may run into runtime error: the library name baked in to the binary is not the same as file name in the system image. Change-Id: I55b571c8139c3bda07a4a0e50cea0f20d8d6c168 --- core/base_rules.mk | 13 +++++++------ core/clear_vars.mk | 1 + core/dynamic_binary.mk | 15 ++++++++++----- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/core/base_rules.mk b/core/base_rules.mk index 33bc6fd641..c892d949d4 100644 --- a/core/base_rules.mk +++ b/core/base_rules.mk @@ -141,15 +141,16 @@ intermediates.COMMON := $(call local-intermediates-dir,COMMON) ########################################################### # Pick a name for the intermediate and final targets ########################################################### -LOCAL_MODULE_STEM := $(strip $(LOCAL_MODULE_STEM)) -ifeq ($(LOCAL_MODULE_STEM),) +ifndef LOCAL_MODULE_STEM LOCAL_MODULE_STEM := $(LOCAL_MODULE) endif -LOCAL_INSTALLED_MODULE_STEM := $(LOCAL_MODULE_STEM)$(LOCAL_MODULE_SUFFIX) -LOCAL_BUILT_MODULE_STEM := $(strip $(LOCAL_BUILT_MODULE_STEM)) -ifeq ($(LOCAL_BUILT_MODULE_STEM),) - LOCAL_BUILT_MODULE_STEM := $(LOCAL_INSTALLED_MODULE_STEM) +ifndef LOCAL_BUILT_MODULE_STEM + LOCAL_BUILT_MODULE_STEM := $(LOCAL_MODULE_STEM)$(LOCAL_MODULE_SUFFIX) +endif + +ifndef LOCAL_INSTALLED_MODULE_STEM + LOCAL_INSTALLED_MODULE_STEM := $(LOCAL_MODULE_STEM)$(LOCAL_MODULE_SUFFIX) endif # OVERRIDE_BUILT_MODULE_PATH is only allowed to be used by the diff --git a/core/clear_vars.mk b/core/clear_vars.mk index 12344f3b11..9165255158 100644 --- a/core/clear_vars.mk +++ b/core/clear_vars.mk @@ -11,6 +11,7 @@ LOCAL_BUILT_MODULE:= LOCAL_BUILT_MODULE_STEM:= OVERRIDE_BUILT_MODULE_PATH:= LOCAL_INSTALLED_MODULE:= +LOCAL_INSTALLED_MODULE_STEM:= LOCAL_UNINSTALLABLE_MODULE:= LOCAL_INTERMEDIATE_TARGETS:= LOCAL_UNSTRIPPED_PATH:= diff --git a/core/dynamic_binary.mk b/core/dynamic_binary.mk index 6ede57f8d9..77784776e6 100644 --- a/core/dynamic_binary.mk +++ b/core/dynamic_binary.mk @@ -26,12 +26,17 @@ endif # TODO: This duplicates logic from base_rules.mk because we need to # know its results before base_rules.mk is included. # Consolidate the duplicates. -LOCAL_MODULE_STEM := $(strip $(LOCAL_MODULE_STEM)) -ifeq ($(LOCAL_MODULE_STEM),) +ifndef LOCAL_MODULE_STEM LOCAL_MODULE_STEM := $(LOCAL_MODULE) endif -LOCAL_INSTALLED_MODULE_STEM := $(LOCAL_MODULE_STEM)$(LOCAL_MODULE_SUFFIX) -LOCAL_BUILT_MODULE_STEM := $(LOCAL_INSTALLED_MODULE_STEM) + +ifndef LOCAL_BUILT_MODULE_STEM + LOCAL_BUILT_MODULE_STEM := $(LOCAL_MODULE_STEM)$(LOCAL_MODULE_SUFFIX) +endif + +ifndef LOCAL_INSTALLED_MODULE_STEM + LOCAL_INSTALLED_MODULE_STEM := $(LOCAL_MODULE_STEM)$(LOCAL_MODULE_SUFFIX) +endif # base_rules.make defines $(intermediates), but we need its value # before we include base_rules. Make a guess, and verify that @@ -90,7 +95,7 @@ endif ## Store a copy with symbols for symbolic debugging ########################################################### symbolic_input := $(compress_output) -symbolic_output := $(LOCAL_UNSTRIPPED_PATH)/$(LOCAL_BUILT_MODULE_STEM) +symbolic_output := $(LOCAL_UNSTRIPPED_PATH)/$(LOCAL_INSTALLED_MODULE_STEM) $(symbolic_output) : $(symbolic_input) | $(ACP) @echo "target Symbolic: $(PRIVATE_MODULE) ($@)" $(copy-file-to-target)