diff --git a/core/binary.mk b/core/binary.mk index 6f9fff2a2..4087963d0 100644 --- a/core/binary.mk +++ b/core/binary.mk @@ -1167,6 +1167,34 @@ asm_objects += $(asm_objects_asm) endif +#################################################### +## For NDK-built libraries, move LOCAL_SHARED_LIBRARY +## references to my_ldlibs, so that we use the NDK +## prebuilt library and headers for linking. +#################################################### +ifndef LOCAL_IS_HOST_MODULE +my_allowed_ldlibs := +ifdef LOCAL_SDK_VERSION + my_ndk_shared_libraries := $(filter $(addprefix lib,$(NDK_PREBUILT_SHARED_LIBRARIES)),$(my_shared_libraries)) + my_shared_libraries := $(filter-out $(my_ndk_shared_libraries),$(my_shared_libraries)) + my_ldlibs += $(patsubst lib%,-l%,$(my_ndk_shared_libraries)) + my_ndk_shared_libraries := + my_allowed_ldlibs := $(addprefix -l,$(NDK_PREBUILT_SHARED_LIBRARIES)) +endif + +# Sort ldlibs and ldflags between -l and other linker flags +# We'll do this again later, since there are still changes happening, but that's fine. +my_ldlib_flags := $(my_ldflags) $(my_ldlibs) +my_ldlibs := $(filter -l%,$(my_ldlib_flags)) +my_ldflags := $(filter-out -l%,$(my_ldlib_flags)) +my_ldlib_flags := + +# Move other ldlibs back to shared libraries +my_shared_libraries += $(patsubst -l%,lib%,$(filter-out $(my_allowed_ldlibs),$(my_ldlibs))) +my_ldlibs := $(filter $(my_allowed_ldlibs),$(my_ldlibs)) +endif + + ########################################################## ## Set up installed module dependency ## We cannot compute the full path of the LOCAL_SHARED_LIBRARIES for @@ -1465,6 +1493,24 @@ ifneq (,$(filter 1 true,$(my_tidy_enabled))) endif endif +# Move -l* entries from ldflags to ldlibs, and everything else to ldflags +my_ldlib_flags := $(my_ldflags) $(my_ldlibs) +my_ldlibs := $(filter -l%,$(my_ldlib_flags)) +my_ldflags := $(filter-out -l%,$(my_ldlib_flags)) + +# One last verification check for ldlibs +ifndef LOCAL_IS_HOST_MODULE +my_allowed_ldlibs := +ifdef LOCAL_SDK_VERSION + my_allowed_ldlibs := $(addprefix -l,$(NDK_PREBUILT_SHARED_LIBRARIES)) +endif + +my_bad_ldlibs := $(filter-out $(my_allowed_ldlibs),$(my_ldlibs)) +ifneq ($(my_bad_ldlibs),) + $(error $(LOCAL_MODULE_MAKEFILE): $(LOCAL_MODULE): Bad LOCAL_LDLIBS entries: $(my_bad_ldlibs)) +endif +endif + $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_YACCFLAGS := $(LOCAL_YACCFLAGS) $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ASFLAGS := $(my_asflags) $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CONLYFLAGS := $(my_conlyflags) diff --git a/core/config.mk b/core/config.mk index 29a606a41..a11eb693d 100644 --- a/core/config.mk +++ b/core/config.mk @@ -794,6 +794,8 @@ endif RSCOMPAT_32BIT_ONLY_API_LEVELS := 8 9 10 11 12 13 14 15 16 17 18 19 20 RSCOMPAT_NO_USAGEIO_API_LEVELS := 8 9 10 11 12 13 +NDK_PREBUILT_SHARED_LIBRARIES := android c dl EGL GLESv1_CM GLESv2 GLESv3 jnigraphics log mediandk m OpenMAXAL OpenSLES stdc++ vulkan z + ifeq ($(JAVA_NOT_REQUIRED),true) # Remove java and tools from our path so that we make sure nobody uses them. unexport ANDROID_JAVA_HOME