Improvements to packaging scripts

This commit is contained in:
Joseph Henry
2018-09-06 15:30:34 -07:00
parent 84fcfd3baf
commit f9e83bcb59
3 changed files with 14 additions and 54 deletions

View File

@@ -1,25 +0,0 @@
OSTYPE=$(shell uname -s | tr '[A-Z]' '[a-z]')
BUILD=build/$(OSTYPE)
ifeq ($(OSTYPE),darwin)
SHARED_LIB=libzt.dylib
endif
ifeq ($(OSTYPE),linux)
SHARED_LIB=libzt.so
endif
example_java_app:
javac *.java
example_java_app_1.6:
javac -source 1.6 -bootclasspath /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.41.x86_64/jre/lib/rt.jar -target 1.6 *.java
copy_dynamic_lib:
cp ../../bin/lib/$(SHARED_LIB) .
jar:
jar cf libzt.jar libzt.dylib zerotier/ZeroTier.class
clean:
-rm -rf *.jar *.dylib *.so
-find . -type f \( -name '*.class' \) -delete

View File

@@ -1,27 +1,8 @@
## ZeroTier with Java via JNI
***
### Example App
### ExampleApp
- From libzt main directory, build shared library: `make shared_jni_lib`
- Copy the resultant dynamic library (`*.so` or `*.dylib`) from `build/` to this current directory
- Change to this directory and `make example_java_app`
- Run: `java -cp "." ExampleApp`
### JAR file (with embedded C++ dynamic library)
```
make example_java_app
make copy_dynamic_lib
make jar
```
Notes:
Upon execution, it will load the libzt dynamic library via the `loadLibrary` method and begin generating an identity.
***
More resources on JNI usage:
http://journals.ecs.soton.ac.uk/java/tutorial/native1.1/implementing/index.html
Copy `zt.jar` file into this directory
Extract shared library from JAR file: `jar xf zt.jar libzt.dylib`
Build ExampleApp: `javac -cp ".:zt.jar" ExampleApp.java`