Skip to content
Branch: master
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
android Update paths in android bindings tests Aug 20, 2018
gradle/wrapper
msvc Problem: out of date with project.xml Jan 20, 2017
src
.gitignore Regenerated with current zproject (concerning tmp-deps) Aug 20, 2018
CMakeLists.txt Problem: zyre is out of sync (zproject has evolved!) May 31, 2016
Findzyre.cmake Problem: zyre is out of sync (zproject has evolved!) May 31, 2016
README.md Problem: out of date with project.xml Jan 20, 2017
build.gradle Problem: JNI bindings are out of sync Jul 17, 2019
ci_build.sh Regenerated with current zproject (concerning tmp-deps) Aug 20, 2018
gradlew Problem: gradle 5.0 has security vulnerabilities May 24, 2019
gradlew.bat Problem: gradle 5.0 has security vulnerabilities May 24, 2019
settings.gradle

README.md

zyre-jni

Download

JNI Binding for zyre

Building the JNI Layer for Linux

Ensure you have gradle and cmake installed, then run:

gradle build jar
gradle test

If you don't like to install gradle beforehand just use the gradle wrapper.

./gradlew build jar
./gradlew test

This calls javah to build the headers in src/native/include, and then compiles the C and Java pieces to create a jar file a sharable library (.so).

Installing the JNI Layer for Linux

If you like to use this JNI Layer in another project you'll need to distribute it to a location where the other project can locate it. The easiest way to do this is by leveraging maven and install to the local maven repository located at $HOME/.m2. Therefore simply run:

./gradlew publishToMavenLocal

Building the JNI Layer for Android

See bindings/jni/android/build.sh.

You need the Android Native Development Kit (NDK) installed.

Set these environment variables, e.g:

ANDROID_NDK_ROOT=$HOME/android-ndk-r11c
TOOLCHAIN_VERSION=4.9
TOOLCHAIN_HOST=arm-linux-androideabi
TOOLCHAIN_NAME=$TOOLCHAIN_HOST-$TOOLCHAIN_VERSION
TOOLCHAIN_ARCH=arm
TOOLCHAIN_PATH=$ANDROID_NDK_ROOT/toolchains/$TOOLCHAIN_NAME/prebuilt/linux-x86_64/bin

Then in the android directory, run:

./build.sh

This does the following:

  • It compiles the zyre C sources for Android, into a native library libzyre.so in builds/android/
  • It compiles the JNI Java classes into a jar file zyre-jni-2.0.1.jar in bindings/jni/build/libs
  • It compiles the JNI C sources for Android, into a native library libzyrejni.so.
  • It takes czmq-jni-*.jar, which must already be built in ../czmq/bindings/jni/build/libs/
  • It combines all these into zyre-android.jar, which you can use in your Android projects.

Building the JNI Layer for Windows

You need MS Visual Studio 2010 or later.

You need the Java SDK. Set the JAVA_HOME environment to the installation location, e.g. C:Program FilesJavajdk1.8.0_66.

  1. Check out all dependent projects from github, at the same level as this project. E.g.: libzmq, czmq.
  2. In each project, open a console in builds/msvc/vs2010 and run the build.bat batch file.
  3. In this project, open a console in bindings/jni/msvc/vs2010 and run the build.bat batch file.

The resulting libraries (zyrejni.dll, zyrejni.lib) are created in bindings/jni/msvc/bin.

Using the JNI API

  • to be written.

License

Copyright (c) the Contributors as noted in the AUTHORS file.

This file is part of Zyre, an open-source framework for proximity-based peer-to-peer applications -- See http://zyre.org.

This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.

Information for maintainers

Building the gradle wrapper

The gradle wrapper is a tool that allows to use gradle on multiple platforms without installing it beforehand. Make sure you have installed a version of gradle that is at least the version the wrapper should have (local version >= wrapper version). Then just run

gradle wrapper

Now commit all generated files to the project. Yes the jar file as well! Users will now be able to call the gradle wrapper (gradlew) which will install gradle for them.

Travis build

Travis can build and check this jni layer there add the following line to your travis environment matrix

- BUILD_TYPE=bindings BINDING=jni

Travis deploy to bintray

When tagging a release travis can automatically deploy this jni layer to bintray. Therefore you'll need to supply travis with three environment variables:

  • BINTRAY_USER - your personal user name
  • BINTRAY_KEY - your personal api key
  • BINTRAY_USER_ORG - the organisation you like to publish to

You may extent .travis.yml as follows

- BUILD_TYPE=bindings BINDING=jni BINTRAY_USER=<user> BINTRAY_KEY=<key> BINTRAY_USER_ORG=<org>

But I recommend to encrypt your bintray api key. This can be done with the travis commandline client

travis encrypt BINTRAY_KEY=123...

Please be aware that secure environmental variables can only be added as global.

global:
   - secure: "ZMvDhR..."
matrix:
   - BUILD_TYPE=bindings BINDING=jni BINTRAY_USER=<user> BINTRAY_USER_ORG=<org>
You can’t perform that action at this time.