1# Native prebuilt coming from Soong. 2# Extra inputs: 3# LOCAL_SOONG_UNSTRIPPED_BINARY 4 5ifneq ($(LOCAL_MODULE_MAKEFILE),$(SOONG_ANDROID_MK)) 6 $(call pretty-error,soong_rust_prebuilt.mk may only be used from Soong) 7endif 8 9ifdef LOCAL_IS_HOST_MODULE 10 ifneq ($(HOST_OS),$(LOCAL_MODULE_HOST_OS)) 11 my_prefix := HOST_CROSS_ 12 LOCAL_HOST_PREFIX := $(my_prefix) 13 else 14 my_prefix := HOST_ 15 LOCAL_HOST_PREFIX := 16 endif 17else 18 my_prefix := TARGET_ 19endif 20 21ifeq ($($(my_prefix)ARCH),$(LOCAL_MODULE_$(my_prefix)ARCH)) 22 # primary arch 23 LOCAL_2ND_ARCH_VAR_PREFIX := 24else ifeq ($($(my_prefix)2ND_ARCH),$(LOCAL_MODULE_$(my_prefix)ARCH)) 25 # secondary arch 26 LOCAL_2ND_ARCH_VAR_PREFIX := $($(my_prefix)2ND_ARCH_VAR_PREFIX) 27else 28 $(call pretty-error,Unsupported LOCAL_MODULE_$(my_prefix)ARCH=$(LOCAL_MODULE_$(my_prefix)ARCH)) 29endif 30 31# Don't install rlib/proc_macro libraries. 32ifndef LOCAL_UNINSTALLABLE_MODULE 33 ifneq ($(filter RLIB_LIBRARIES PROC_MACRO_LIBRARIES,$(LOCAL_MODULE_CLASS)),) 34 LOCAL_UNINSTALLABLE_MODULE := true 35 endif 36endif 37 38 39####################################### 40include $(BUILD_SYSTEM)/base_rules.mk 41####################################### 42 43# The real dependency will be added after all Android.mks are loaded and the install paths 44# of the shared libraries are determined. 45ifdef LOCAL_INSTALLED_MODULE 46 ifdef LOCAL_SHARED_LIBRARIES 47 my_shared_libraries := $(LOCAL_SHARED_LIBRARIES) 48 $(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)DEPENDENCIES_ON_SHARED_LIBRARIES += \ 49 $(my_register_name):$(LOCAL_INSTALLED_MODULE):$(subst $(space),$(comma),$(my_shared_libraries)) 50 endif 51 ifdef LOCAL_DYLIB_LIBRARIES 52 my_dylibs := $(LOCAL_DYLIB_LIBRARIES) 53 # Treat these as shared library dependencies for installation purposes. 54 $(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)DEPENDENCIES_ON_SHARED_LIBRARIES += \ 55 $(my_register_name):$(LOCAL_INSTALLED_MODULE):$(subst $(space),$(comma),$(my_dylibs)) 56 endif 57endif 58 59$(LOCAL_BUILT_MODULE): $(LOCAL_PREBUILT_MODULE_FILE) 60 $(transform-prebuilt-to-target) 61ifneq ($(filter EXECUTABLES NATIVE_TESTS,$(LOCAL_MODULE_CLASS)),) 62 $(hide) chmod +x $@ 63endif 64 65ifndef LOCAL_IS_HOST_MODULE 66 ifdef LOCAL_SOONG_UNSTRIPPED_BINARY 67 my_symbol_path := $(if $(LOCAL_SOONG_SYMBOL_PATH),$(LOCAL_SOONG_SYMBOL_PATH),$(my_module_path)) 68 # Store a copy with symbols for symbolic debugging 69 my_unstripped_path := $(TARGET_OUT_UNSTRIPPED)/$(patsubst $(PRODUCT_OUT)/%,%,$(my_symbol_path)) 70 # drop /root as /root is mounted as / 71 my_unstripped_path := $(patsubst $(TARGET_OUT_UNSTRIPPED)/root/%,$(TARGET_OUT_UNSTRIPPED)/%, $(my_unstripped_path)) 72 symbolic_output := $(my_unstripped_path)/$(my_installed_module_stem) 73 $(eval $(call copy-one-file,$(LOCAL_SOONG_UNSTRIPPED_BINARY),$(symbolic_output))) 74 $(call add-dependency,$(LOCAL_BUILT_MODULE),$(symbolic_output)) 75 endif 76endif 77 78# A product may be configured to strip everything in some build variants. 79# We do the stripping as a post-install command so that LOCAL_BUILT_MODULE 80# is still with the symbols and we don't need to clean it (and relink) when 81# you switch build variant. 82ifneq ($(filter $(STRIP_EVERYTHING_BUILD_VARIANTS),$(TARGET_BUILD_VARIANT)),) 83$(LOCAL_INSTALLED_MODULE): PRIVATE_POST_INSTALL_CMD := \ 84 $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_STRIP) --strip-all $(LOCAL_INSTALLED_MODULE) 85endif 86 87$(LOCAL_BUILT_MODULE): $(LOCAL_ADDITIONAL_DEPENDENCIES) 88 89# We don't care about installed rlib/static libraries, since the libraries have 90# already been linked into the module at that point. We do, however, care 91# about the NOTICE files for any rlib/static libraries that we use. 92# (see notice_files.mk) 93# 94# Filter out some NDK libraries that are not being exported. 95my_static_libraries := \ 96 $(filter-out ndk_libc++_static ndk_libc++abi ndk_libandroid_support ndk_libunwind \ 97 ndk_libc++_static.native_bridge ndk_libc++abi.native_bridge \ 98 ndk_libandroid_support.native_bridge ndk_libunwind.native_bridge, \ 99 $(LOCAL_STATIC_LIBRARIES)) 100installed_static_library_notice_file_targets := \ 101 $(foreach lib,$(my_static_libraries), \ 102 NOTICE-$(if $(LOCAL_IS_HOST_MODULE),HOST$(if $(my_host_cross),_CROSS,),TARGET)-STATIC_LIBRARIES-$(lib)) 103installed_static_library_notice_file_targets += \ 104 $(foreach lib,$(LOCAL_RLIB_LIBRARIES), \ 105 NOTICE-$(if $(LOCAL_IS_HOST_MODULE),HOST$(if $(my_host_cross),_CROSS,),TARGET)-RLIB_LIBRARIES-$(lib)) 106 107$(notice_target): | $(installed_static_library_notice_file_targets) 108$(LOCAL_INSTALLED_MODULE): | $(notice_target) 109