From 0a15eae00f7360930dad1fcfb25f02c15c930710 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Thu, 30 Apr 2015 21:50:28 -0700 Subject: Setup native build for Windows Java. Still need to do Mac & Linux --- java/CMakeLists.txt | 74 +++++++++++++++++++++++++++++++++++++++++++++++++ java/build.xml | 40 ++++++++++++++++++++++++-- java/jni/ZT1_jniutils.h | 7 +++-- 3 files changed, 116 insertions(+), 5 deletions(-) create mode 100644 java/CMakeLists.txt (limited to 'java') diff --git a/java/CMakeLists.txt b/java/CMakeLists.txt new file mode 100644 index 00000000..c97e86d6 --- /dev/null +++ b/java/CMakeLists.txt @@ -0,0 +1,74 @@ +cmake_minimum_required(VERSION 3.2) + +project(ZeroTierOneJNI) + +find_package(Java COMPONENTS Development) +message("JAVA_HOME: $ENV{JAVA_HOME}") + +set(Java_INCLUDE_DIRS $ENV{JAVA_HOME}/include) + +message("Java Include Dirs: ${Java_INCLUDE_DIRS}") + +if(WIN32) + add_definitions(-DNOMINMAX) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc /W3 /MP") +endif() + +set(src_files + ../ext/lz4/lz4.c + ../ext/json-parser/json.c + ../ext/http-parser/http_parser.c + ../node/C25519.cpp + ../node/CertificateOfMembership.cpp + ../node/Defaults.cpp + ../node/Dictionary.cpp + ../node/Identity.cpp + ../node/IncomingPacket.cpp + ../node/InetAddress.cpp + ../node/Multicaster.cpp + ../node/Network.cpp + ../node/NetworkConfig.cpp + ../node/Node.cpp + ../node/OutboundMulticast.cpp + ../node/Packet.cpp + ../node/Peer.cpp + ../node/Poly1305.cpp + ../node/Salsa20.cpp + ../node/SelfAwareness.cpp + ../node/SHA512.cpp + ../node/Switch.cpp + ../node/Topology.cpp + ../node/Utils.cpp + ../osdep/Http.cpp + ../osdep/OSUtils.cpp + jni/com_zerotierone_sdk_Node.cpp + jni/ZT1_jniutils.cpp + ) + +set(include_dirs + ${CMAKE_CURRENT_SOURCE_DIR}/../include/ + ${Java_INCLUDE_DIRS}) + +if(WIN32) + set(include_dirs + ${include_dirs} + ${Java_INCLUDE_DIRS}/win32) +endif() + +include_directories( + ${include_dirs} + ) + +add_library(${PROJECT_NAME} SHARED ${src_files}) + +set(link_libs ) + +if(WIN32) + set(link_libs + wsock32 + ws2_32 + + ) +endif() + +target_link_libraries(${PROJECT_NAME} ${link_libs}) \ No newline at end of file diff --git a/java/build.xml b/java/build.xml index 2057a509..0ee27185 100644 --- a/java/build.xml +++ b/java/build.xml @@ -1,15 +1,20 @@ + + + + + - - + + @@ -19,6 +24,9 @@ destdir="classes" classpath="${env.ANDROID_PLATFORM}/android.jar" includeantruntime="false"/> + + + @@ -34,6 +42,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/java/jni/ZT1_jniutils.h b/java/jni/ZT1_jniutils.h index 6c43704c..d8baf85d 100644 --- a/java/jni/ZT1_jniutils.h +++ b/java/jni/ZT1_jniutils.h @@ -1,5 +1,6 @@ #ifndef ZT1_jniutils_h_ #define ZT1_jniutils_h_ +#include #include #include @@ -15,9 +16,9 @@ extern "C" { #define LOGD(...) ((void)__android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)) #define LOGE(...) ((void)__android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)) #else -#define LOGI(...) -#define LOGD(...) -#define LOGE(...) +#define LOGI(...) fprintf(stdout, __VA_ARGS__) +#define LOGD(...) fprintf(stdout, __VA_ARGS__) +#define LOGE(...) fprintf(stdout, __VA_ARGS__) #endif jobject createResultObject(JNIEnv *env, ZT1_ResultCode code); -- cgit v1.2.3