Add jni to OsmAnd-java

This commit is contained in:
Victor Shcherb 2013-08-07 21:34:30 +02:00
parent 1439a4406c
commit 24fb8a11cf
5 changed files with 97 additions and 0 deletions

View file

@ -1,2 +1,4 @@
bin
c-src
OsmAnd-core.jar
src/net/osmand/core/jni/*

28
OsmAnd-java/Android.mk Normal file
View file

@ -0,0 +1,28 @@
include $(CLEAR_VARS)
LOCAL_PATH := $(call my-dir)
ifneq ($(OSMAND_BUILDING_NEON_LIBRARY),true)
LOCAL_MODULE := OsmAndJNI
else
LOCAL_MODULE := OsmAndJNI_neon
LOCAL_ARM_NEON := true
endif
ifeq ($(LOCAL_ARM_NEON),true)
OSMAND_BINARY_SUFFIX := _neon
else
OSMAND_BINARY_SUFFIX :=
endif
LOCAL_STATIC_LIBRARIES := OsmAndCore$(OSMAND_BINARY_SUFFIX)
ifneq ($(OSMAND_USE_PREBUILT),true)
LOCAL_SRC_FILES := src/swig.c
include $(BUILD_SHARED_LIBRARY)
else
LOCAL_SRC_FILES := \
$(OSMAND_ANDROID_PREBUILT_ROOT)/$(TARGET_ARCH_ABI)/lib$(LOCAL_MODULE).so
include $(PREBUILT_SHARED_LIBRARY)
endif

View file

@ -0,0 +1,53 @@
project(OsmAndJNI)
set(target_specific_private_includes "")
if(CMAKE_TARGET_OS STREQUAL "windows")
set(target_specific_private_includes ${target_specific_private_includes}
"$ENV{JAVA_HOME}/include/win32"
)
elseif(CMAKE_TARGET_OS STREQUAL "darwin")
set(target_specific_private_includes ${target_specific_private_includes}
"$ENV{JAVA_HOME}/include/darwin"
)
elseif(CMAKE_TARGET_OS STREQUAL "linux")
set(target_specific_private_includes ${target_specific_private_includes}
"$ENV{JAVA_HOME}/include/linux"
)
endif()
if(CMAKE_SHARED_LIBS_ALLOWED_ON_TARGET)
add_library(OsmAndJNI SHARED
"c-src/swig.cpp"
)
target_compile_definitions(OsmAndJNI
PRIVATE
-DOSMAND_CORE_EXPORTS
)
target_include_directories(OsmAndJNI
PRIVATE
"$ENV{JAVA_HOME}/include"
${target_specific_private_includes}
)
if(CMAKE_STATIC_LIBS_ALLOWED_ON_TARGET)
add_dependencies(OsmAndJNI
OsmAndCore_static
OsmAndCoreUtils_static
)
target_link_libraries(OsmAndJNI
LINK_PUBLIC
OsmAndCore_static
OsmAndCoreUtils_static
)
else()
add_dependencies(OsmAndJNI
OsmAndCore_shared
OsmAndCoreUtils_shared
)
target_link_libraries(OsmAndJNI
LINK_PUBLIC
OsmAndCore_shared
OsmAndCoreUtils_shared
)
endif()
endif()

11
OsmAnd-java/generate-swig.sh Executable file
View file

@ -0,0 +1,11 @@
#!/bin/bash
SRCLOC="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
rm -rf "$SRCLOC/src/net/osmand/core/jni"
mkdir -p "$SRCLOC/src/net/osmand/core/jni"
rm -rf "$SRCLOC/c-src"
mkdir -p "$SRCLOC/c-src"
swig -java -package net.osmand.core.jni -outdir "$SRCLOC/src/net/osmand/core/jni" -o "$SRCLOC/c-src/swig.cpp" -I"$SRCLOC/../../core/include" -c++ -v "$SRCLOC/../../core/core.swig"

3
OsmAnd-java/jni.cmake Normal file
View file

@ -0,0 +1,3 @@
# OsmAnd JNI
add_subdirectory("${OSMAND_ROOT}/jni" "jni")
add_dependencies(OsmAndJNI OsmAndCore)