diff --git a/.gitignore b/.gitignore index 64e13d98d..66a9e748c 100755 --- a/.gitignore +++ b/.gitignore @@ -44,3 +44,5 @@ java/bin/ java/classes/ java/doc/ windows/ZeroTierOne/Debug/ +java/build_win64/ +java/build_win32/ diff --git a/java/CMakeLists.txt b/java/CMakeLists.txt new file mode 100644 index 000000000..c97e86d61 --- /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 2057a509a..0ee271854 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 6c43704c8..d8baf85de 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);