Ivan Lozano | d62e712 | 2019-08-27 11:23:35 -0700 | [diff] [blame] | 1 | # Native prebuilt coming from Soong. |
| 2 | # Extra inputs: |
| 3 | # LOCAL_SOONG_UNSTRIPPED_BINARY |
| 4 | |
| 5 | ifneq ($(LOCAL_MODULE_MAKEFILE),$(SOONG_ANDROID_MK)) |
| 6 | $(call pretty-error,soong_rust_prebuilt.mk may only be used from Soong) |
| 7 | endif |
| 8 | |
| 9 | ifdef 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 |
| 17 | else |
| 18 | my_prefix := TARGET_ |
| 19 | endif |
| 20 | |
| 21 | ifeq ($($(my_prefix)ARCH),$(LOCAL_MODULE_$(my_prefix)ARCH)) |
| 22 | # primary arch |
| 23 | LOCAL_2ND_ARCH_VAR_PREFIX := |
| 24 | else 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) |
| 27 | else |
| 28 | $(call pretty-error,Unsupported LOCAL_MODULE_$(my_prefix)ARCH=$(LOCAL_MODULE_$(my_prefix)ARCH)) |
| 29 | endif |
| 30 | |
Ivan Lozano | d62e712 | 2019-08-27 11:23:35 -0700 | [diff] [blame] | 31 | # Don't install rlib/proc_macro libraries. |
| 32 | ifndef LOCAL_UNINSTALLABLE_MODULE |
| 33 | ifneq ($(filter RLIB_LIBRARIES PROC_MACRO_LIBRARIES,$(LOCAL_MODULE_CLASS)),) |
| 34 | LOCAL_UNINSTALLABLE_MODULE := true |
| 35 | endif |
| 36 | endif |
| 37 | |
| 38 | |
| 39 | ####################################### |
| 40 | include $(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. |
| 45 | ifdef 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 |
| 57 | endif |
| 58 | |
| 59 | $(LOCAL_BUILT_MODULE): $(LOCAL_PREBUILT_MODULE_FILE) |
| 60 | $(transform-prebuilt-to-target) |
| 61 | ifneq ($(filter EXECUTABLES,$(LOCAL_MODULE_CLASS)),) |
| 62 | $(hide) chmod +x $@ |
| 63 | endif |
| 64 | |
| 65 | ifndef 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 |
| 76 | endif |
| 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. |
| 82 | ifneq ($(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) |
| 85 | endif |
| 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. |
| 95 | my_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)) |
| 100 | installed_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)) |
| 103 | installed_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) |