OSDN Git Service

[DO NOT MERGE] Update Security String to 2017-04-01 on lmp-dev am: ffab69998a -s...
[android-x86/build.git] / core / dynamic_binary.mk
index 6d3d2b5..08fb176 100644 (file)
@@ -13,31 +13,17 @@ $(error This file should not be used to build host binaries.  Included by (or ne
 endif
 
 # The name of the target file, without any path prepended.
-# TODO: This duplicates logic from base_rules.mk because we need to
-#       know its results before base_rules.mk is included.
-#       Consolidate the duplicates.
-ifndef LOCAL_MODULE_STEM
-  LOCAL_MODULE_STEM := $(LOCAL_MODULE)
-endif
-
-ifndef LOCAL_BUILT_MODULE_STEM
-  LOCAL_BUILT_MODULE_STEM := $(LOCAL_MODULE_STEM)$(LOCAL_MODULE_SUFFIX)
-endif
+# This duplicates logic from base_rules.mk because we need to
+# know its results before base_rules.mk is included.
+include $(BUILD_SYSTEM)/configure_module_stem.mk
 
-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
-# it's correct once the real value is defined.
-guessed_intermediates := $(call local-intermediates-dir,,$(LOCAL_2ND_ARCH_VAR_PREFIX))
+intermediates := $(call local-intermediates-dir,,$(LOCAL_2ND_ARCH_VAR_PREFIX))
 
 # Define the target that is the unmodified output of the linker.
 # The basename of this target must be the same as the final output
 # binary name, because it's used to set the "soname" in the binary.
 # The includer of this file will define a rule to build this target.
-linked_module := $(guessed_intermediates)/LINKED/$(LOCAL_BUILT_MODULE_STEM)
+linked_module := $(intermediates)/LINKED/$(my_built_module_stem)
 
 ALL_ORIGINAL_DYNAMIC_BINARIES += $(linked_module)
 
@@ -52,13 +38,6 @@ LOCAL_INTERMEDIATE_TARGETS := $(linked_module)
 include $(BUILD_SYSTEM)/binary.mk
 ###################################
 
-$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_2ND_ARCH_VAR_PREFIX := $(LOCAL_2ND_ARCH_VAR_PREFIX)
-
-# Make sure that our guess at the value of intermediates was correct.
-ifneq ($(intermediates),$(guessed_intermediates))
-$(error Internal error: guessed path '$(guessed_intermediates)' doesn't match '$(intermediates))
-endif
-
 ###########################################################
 ## Compress
 ###########################################################
@@ -70,7 +49,7 @@ endif
 
 ifeq ($(LOCAL_COMPRESS_MODULE_SYMBOLS),true)
 $(error Symbol compression not yet supported.)
-compress_output := $(intermediates)/COMPRESSED-$(LOCAL_BUILT_MODULE_STEM)
+compress_output := $(intermediates)/COMPRESSED-$(my_built_module_stem)
 
 #TODO: write the real $(STRIPPER) rule.
 #TODO: define a rule to build TARGET_SYMBOL_FILTER_FILE, and
@@ -92,7 +71,7 @@ else
 my_unstripped_path := $(LOCAL_UNSTRIPPED_PATH)
 endif
 symbolic_input := $(compress_output)
-symbolic_output := $(my_unstripped_path)/$(LOCAL_INSTALLED_MODULE_STEM)
+symbolic_output := $(my_unstripped_path)/$(my_installed_module_stem)
 $(symbolic_output) : $(symbolic_input) | $(ACP)
        @echo "target Symbolic: $(PRIVATE_MODULE) ($@)"
        $(copy-file-to-target)
@@ -104,17 +83,35 @@ $(symbolic_output) : $(symbolic_input) | $(ACP)
 strip_input := $(symbolic_output)
 strip_output := $(LOCAL_BUILT_MODULE)
 
-ifeq ($(strip $(LOCAL_STRIP_MODULE)),)
-  LOCAL_STRIP_MODULE := $(strip $(TARGET_STRIP_MODULE))
+my_strip_module := $(LOCAL_STRIP_MODULE)
+ifeq ($(my_strip_module),)
+  my_strip_module := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_STRIP_MODULE)
 endif
 
-ifeq ($(LOCAL_STRIP_MODULE),true)
+ifeq ($(my_strip_module),true)
 # Strip the binary
 $(strip_output): PRIVATE_STRIP := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_STRIP)
 $(strip_output): PRIVATE_OBJCOPY := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OBJCOPY)
 $(strip_output): $(strip_input) | $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_STRIP)
        $(transform-to-stripped)
 else
+ifeq ($(my_strip_module),keep_symbols)
+# Strip only the debug frames, but leave the symbol table.
+$(strip_output): PRIVATE_STRIP := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_STRIP)
+$(strip_output): PRIVATE_OBJCOPY := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OBJCOPY)
+$(strip_output): PRIVATE_READELF := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_READELF)
+$(strip_output): $(strip_input) | $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_STRIP)
+       $(transform-to-stripped-keep-symbols)
+
+# A product may be configured to strip everything in some build variants.
+# We do the stripping as a post-install command so that LOCAL_BUILT_MODULE
+# is still with the symbols and we don't need to clean it (and relink) when
+# you switch build variant.
+ifneq ($(filter $(STRIP_EVERYTHING_BUILD_VARIANTS),$(TARGET_BUILD_VARIANT)),)
+$(LOCAL_INSTALLED_MODULE): PRIVATE_POST_INSTALL_CMD := \
+  $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_STRIP) --strip-all $(LOCAL_INSTALLED_MODULE)
+endif
+else
 # Don't strip the binary, just copy it.  We can't skip this step
 # because a copy of the binary must appear at LOCAL_BUILT_MODULE.
 #
@@ -129,7 +126,8 @@ $(strip_output): $(strip_input)
        @echo "target Unstripped: $(PRIVATE_MODULE) ($@)"
        $(copy-file-to-target-with-cp)
 endif
-endif # LOCAL_STRIP_MODULE
+endif
+endif # my_strip_module
 
 
 $(cleantarget): PRIVATE_CLEAN_FILES += \