mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-01-29 15:43:52 +00:00
Setup native build for Windows Java.
Still need to do Mac & Linux
This commit is contained in:
parent
75d7137025
commit
0a15eae00f
2
.gitignore
vendored
2
.gitignore
vendored
@ -44,3 +44,5 @@ java/bin/
|
||||
java/classes/
|
||||
java/doc/
|
||||
windows/ZeroTierOne/Debug/
|
||||
java/build_win64/
|
||||
java/build_win32/
|
||||
|
74
java/CMakeLists.txt
Normal file
74
java/CMakeLists.txt
Normal file
@ -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})
|
@ -1,15 +1,20 @@
|
||||
<project default="build" name="ZeroTierOneSDK">
|
||||
<property environment="env"/>
|
||||
|
||||
<condition property="isWindows">
|
||||
<os family="windows"/>
|
||||
</condition>
|
||||
|
||||
<target name="clean">
|
||||
<delete dir="bin" failonerror="false"/>
|
||||
<delete dir="classes" failonerror="false"/>
|
||||
<delete dir="cmakebuild" failonerror="false"/>
|
||||
<delete dir="libs" failonerror="false"/>
|
||||
<delete dir="obj" failonerror="false"/>
|
||||
</target>
|
||||
|
||||
<target name="build">
|
||||
<echo message="os.name = ${os.name}"/>
|
||||
<target name="build_java">
|
||||
<echo message="os.name = ${os.name}"/>
|
||||
<echo message="os.arch = ${os.arch}"/>
|
||||
<echo message="ant.java.version = ${ant.java.version}"/>
|
||||
<echo message="java.version = ${java.version}"/>
|
||||
@ -19,6 +24,9 @@
|
||||
destdir="classes"
|
||||
classpath="${env.ANDROID_PLATFORM}/android.jar"
|
||||
includeantruntime="false"/>
|
||||
</target>
|
||||
|
||||
<target name="build_android">
|
||||
<exec dir="jni" executable="${env.NDK_BUILD_LOC}" failonerror="true">
|
||||
<arg value="ZT1=${user.dir}/../"/>
|
||||
</exec>
|
||||
@ -34,6 +42,34 @@
|
||||
<copy file="libs/x86/libZeroTierOneJNI.so"
|
||||
tofile="${user.dir}/classes/lib/x86/libZeroTierOneJNI.so"
|
||||
overwrite="true"/>
|
||||
</target>
|
||||
|
||||
|
||||
<target name="windows" if="isWindows">
|
||||
<mkdir dir="build_win32"/>
|
||||
<exec dir="build_win32/" executable="cmake" failonerror="true">
|
||||
<arg line=".. -G"Visual Studio 11 2012" -DCMAKE_BUILD_TYPE=Release"/>
|
||||
</exec>
|
||||
<exec dir="build_win32/" executable="cmake" failonerror="true">
|
||||
<arg line="--build . --config Release"/>
|
||||
</exec>
|
||||
<copy file="build_win32/Release/ZeroTierOneJNI.dll"
|
||||
tofile="classes/lib/ZeroTierOneJNI_win32.dll"
|
||||
overwrite="true"/>
|
||||
|
||||
<mkdir dir="build_win64"/>
|
||||
<exec dir="build_win64/" executable="cmake" failonerror="true">
|
||||
<arg line=".. -G"Visual Studio 11 2012 Win64" -DCMAKE_BUILD_TYPE=Release"/>
|
||||
</exec>
|
||||
<exec dir="build_win64/" executable="cmake" failonerror="true">
|
||||
<arg line="--build . --config Release"/>
|
||||
</exec>
|
||||
<copy file="build_win64/Release/ZeroTierOneJNI.dll"
|
||||
tofile="classes/lib/ZeroTierOneJNI_win64.dll"
|
||||
overwrite="true"/>
|
||||
</target>
|
||||
|
||||
<target name="build" depends="build_java,build_android,windows">
|
||||
<jar destfile="bin/ZeroTierOneSDK.jar" basedir="classes"/>
|
||||
</target>
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
#ifndef ZT1_jniutils_h_
|
||||
#define ZT1_jniutils_h_
|
||||
#include <stdio.h>
|
||||
#include <jni.h>
|
||||
#include <ZeroTierOne.h>
|
||||
|
||||
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user