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 | |
| 31 | skip_module := |
| 32 | ifeq ($(TARGET_TRANSLATE_2ND_ARCH),true) |
| 33 | ifndef LOCAL_IS_HOST_MODULE |
| 34 | ifdef LOCAL_2ND_ARCH_VAR_PREFIX |
| 35 | # Only support rlib and dylib libraries for translated arch |
| 36 | ifeq ($(filter RLIB_LIBRARIES DYLIB_LIBRARIES PROC_MACRO_LIBRARIES,$(LOCAL_MODULE_CLASS)),) |
| 37 | skip_module := true |
| 38 | endif |
| 39 | endif |
| 40 | endif |
| 41 | endif |
| 42 | |
| 43 | |
| 44 | ifndef skip_module |
| 45 | |
| 46 | # Don't install rlib/proc_macro libraries. |
| 47 | ifndef LOCAL_UNINSTALLABLE_MODULE |
| 48 | ifneq ($(filter RLIB_LIBRARIES PROC_MACRO_LIBRARIES,$(LOCAL_MODULE_CLASS)),) |
| 49 | LOCAL_UNINSTALLABLE_MODULE := true |
| 50 | endif |
| 51 | endif |
| 52 | |
| 53 | |
| 54 | ####################################### |
| 55 | include $(BUILD_SYSTEM)/base_rules.mk |
| 56 | ####################################### |
| 57 | |
| 58 | # The real dependency will be added after all Android.mks are loaded and the install paths |
| 59 | # of the shared libraries are determined. |
| 60 | ifdef LOCAL_INSTALLED_MODULE |
| 61 | ifdef LOCAL_SHARED_LIBRARIES |
| 62 | my_shared_libraries := $(LOCAL_SHARED_LIBRARIES) |
| 63 | $(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)DEPENDENCIES_ON_SHARED_LIBRARIES += \ |
| 64 | $(my_register_name):$(LOCAL_INSTALLED_MODULE):$(subst $(space),$(comma),$(my_shared_libraries)) |
| 65 | endif |
| 66 | ifdef LOCAL_DYLIB_LIBRARIES |
| 67 | my_dylibs := $(LOCAL_DYLIB_LIBRARIES) |
| 68 | # Treat these as shared library dependencies for installation purposes. |
| 69 | $(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)DEPENDENCIES_ON_SHARED_LIBRARIES += \ |
| 70 | $(my_register_name):$(LOCAL_INSTALLED_MODULE):$(subst $(space),$(comma),$(my_dylibs)) |
| 71 | endif |
| 72 | endif |
| 73 | |
| 74 | $(LOCAL_BUILT_MODULE): $(LOCAL_PREBUILT_MODULE_FILE) |
| 75 | $(transform-prebuilt-to-target) |
| 76 | ifneq ($(filter EXECUTABLES,$(LOCAL_MODULE_CLASS)),) |
| 77 | $(hide) chmod +x $@ |
| 78 | endif |
| 79 | |
| 80 | ifndef LOCAL_IS_HOST_MODULE |
| 81 | ifdef LOCAL_SOONG_UNSTRIPPED_BINARY |
| 82 | my_symbol_path := $(if $(LOCAL_SOONG_SYMBOL_PATH),$(LOCAL_SOONG_SYMBOL_PATH),$(my_module_path)) |
| 83 | # Store a copy with symbols for symbolic debugging |
| 84 | my_unstripped_path := $(TARGET_OUT_UNSTRIPPED)/$(patsubst $(PRODUCT_OUT)/%,%,$(my_symbol_path)) |
| 85 | # drop /root as /root is mounted as / |
| 86 | my_unstripped_path := $(patsubst $(TARGET_OUT_UNSTRIPPED)/root/%,$(TARGET_OUT_UNSTRIPPED)/%, $(my_unstripped_path)) |
| 87 | symbolic_output := $(my_unstripped_path)/$(my_installed_module_stem) |
| 88 | $(eval $(call copy-one-file,$(LOCAL_SOONG_UNSTRIPPED_BINARY),$(symbolic_output))) |
| 89 | $(call add-dependency,$(LOCAL_BUILT_MODULE),$(symbolic_output)) |
| 90 | endif |
| 91 | endif |
| 92 | |
| 93 | # A product may be configured to strip everything in some build variants. |
| 94 | # We do the stripping as a post-install command so that LOCAL_BUILT_MODULE |
| 95 | # is still with the symbols and we don't need to clean it (and relink) when |
| 96 | # you switch build variant. |
| 97 | ifneq ($(filter $(STRIP_EVERYTHING_BUILD_VARIANTS),$(TARGET_BUILD_VARIANT)),) |
| 98 | $(LOCAL_INSTALLED_MODULE): PRIVATE_POST_INSTALL_CMD := \ |
| 99 | $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_STRIP) --strip-all $(LOCAL_INSTALLED_MODULE) |
| 100 | endif |
| 101 | |
| 102 | $(LOCAL_BUILT_MODULE): $(LOCAL_ADDITIONAL_DEPENDENCIES) |
| 103 | |
| 104 | # We don't care about installed rlib/static libraries, since the libraries have |
| 105 | # already been linked into the module at that point. We do, however, care |
| 106 | # about the NOTICE files for any rlib/static libraries that we use. |
| 107 | # (see notice_files.mk) |
| 108 | # |
| 109 | # Filter out some NDK libraries that are not being exported. |
| 110 | my_static_libraries := \ |
| 111 | $(filter-out ndk_libc++_static ndk_libc++abi ndk_libandroid_support ndk_libunwind \ |
| 112 | ndk_libc++_static.native_bridge ndk_libc++abi.native_bridge \ |
| 113 | ndk_libandroid_support.native_bridge ndk_libunwind.native_bridge, \ |
| 114 | $(LOCAL_STATIC_LIBRARIES)) |
| 115 | installed_static_library_notice_file_targets := \ |
| 116 | $(foreach lib,$(my_static_libraries), \ |
| 117 | NOTICE-$(if $(LOCAL_IS_HOST_MODULE),HOST$(if $(my_host_cross),_CROSS,),TARGET)-STATIC_LIBRARIES-$(lib)) |
| 118 | installed_static_library_notice_file_targets += \ |
| 119 | $(foreach lib,$(LOCAL_RLIB_LIBRARIES), \ |
| 120 | NOTICE-$(if $(LOCAL_IS_HOST_MODULE),HOST$(if $(my_host_cross),_CROSS,),TARGET)-RLIB_LIBRARIES-$(lib)) |
| 121 | |
| 122 | $(notice_target): | $(installed_static_library_notice_file_targets) |
| 123 | $(LOCAL_INSTALLED_MODULE): | $(notice_target) |
| 124 | endif # !skip_module |
| 125 | |
| 126 | skip_module := |
| 127 | |