1# Determines the types of NDK modules the current module is allowed to link to. 2# Input variables: 3# LOCAL_MODULE 4# LOCAL_MODULE_CLASS 5# LOCAL_NDK_STL_VARIANT 6# LOCAL_SDK_VERSION 7# Output variables: 8# my_ndk_stl_family: Family of the NDK STL. 9# my_ndk_stl_link_type: STL link type, static or shared. 10# my_allowed_ndk_types: Types of NDK modules that may be linked. 11# my_warn_ndk_types: Types of NDK modules that shouldn't be linked, but are. 12 13my_allowed_ndk_types := 14my_warn_ndk_types := 15my_ndk_stl_family := 16my_ndk_stl_link_type := 17 18ifdef LOCAL_SDK_VERSION 19 ifeq ($(LOCAL_NDK_STL_VARIANT),) 20 my_ndk_stl_family := system 21 my_ndk_stl_link_type := shared 22 else ifeq ($(LOCAL_NDK_STL_VARIANT),system) 23 my_ndk_stl_family := system 24 my_ndk_stl_link_type := shared 25 else ifeq ($(LOCAL_NDK_STL_VARIANT),c++_shared) 26 my_ndk_stl_family := libc++ 27 my_ndk_stl_link_type := shared 28 else ifeq ($(LOCAL_NDK_STL_VARIANT),c++_static) 29 my_ndk_stl_family := libc++ 30 my_ndk_stl_link_type := static 31 else ifeq ($(LOCAL_NDK_STL_VARIANT),none) 32 my_ndk_stl_family := none 33 my_ndk_stl_link_type := none 34 else 35 $(call pretty-error,invalid LOCAL_NDK_STL_VARIANT: $(LOCAL_NDK_STL_VARIANT)) 36 endif 37 38 ifeq ($(LOCAL_MODULE_CLASS),STATIC_LIBRARIES) 39 # The "none" link type indicates that nothing is actually linked. Since 40 # this is a static library, it's still up to the final use of the 41 # library whether a static or shared STL should be used. 42 my_ndk_stl_link_type := none 43 endif 44 45 # The system STL is only the C++ ABI layer, so it's compatible with any STL. 46 my_allowed_ndk_types += native:ndk:system:shared 47 my_allowed_ndk_types += native:ndk:system:none 48 49 # Libaries that don't use the STL can be linked to anything. 50 my_allowed_ndk_types += native:ndk:none:none 51 52 # And it's always okay to link a static library that uses your own STL type. 53 # Since nothing was actually linked for the static library, it is up to the 54 # first linked library in the dependency chain which gets used. 55 my_allowed_ndk_types += native:ndk:$(my_ndk_stl_family):none 56 57 ifeq ($(LOCAL_MODULE_CLASS),APPS) 58 # For an app package, it's actually okay to depend on any set of STLs. 59 # If any of the individual libraries depend on each other they've 60 # already been checked for consistency, and if they don't they'll be 61 # kept isolated by RTLD_LOCAL anyway. 62 my_allowed_ndk_types += \ 63 native:ndk:libc++:shared native:ndk:libc++:static 64 65 # The "none" link type that used by static libraries is intentionally 66 # omitted here. We should only be dealing with shared libraries in 67 # LOCAL_JNI_SHARED_LIBRARIES. 68 else ifeq ($(my_ndk_stl_link_type),shared) 69 # Modules linked to a shared STL can only use another shared STL. 70 my_allowed_ndk_types += native:ndk:$(my_ndk_stl_family):shared 71 endif 72 # Else we are a non-static library that uses a static STL, and are 73 # incompatible with all other shared libraries that use an STL. 74else 75 my_allowed_ndk_types := \ 76 native:ndk:none:none \ 77 native:ndk:system:none \ 78 native:ndk:system:shared \ 79 80 ifeq ($(LOCAL_MODULE_CLASS),APPS) 81 # CTS is bad and it should feel bad: http://b/13249737 82 my_warn_ndk_types += native:ndk:libc++:static 83 endif 84endif 85