JAVA: Remove library source compile from JAVA packages

Previously the JAVA packages re-compile UPM library source files.  This
was a work-around for compiling JAVA-specific functionality from the UPM
source into the SWIG'ed JAVA pacakges.

This commit removes the source from the JAVA SWIG compile and provides
an example on how to add the JAVA-specific code with a swig extend call.

    * Added _upm.i file for %import (not %include)
    * Added macros to _upm.i; 1 which performs the loadLibrary, and one
      which adds the java installISR runnable.
    * Updated the src/CMakeLists.txt file to NOT build library src into
      pacakges.
    * Updated the a110x library with examples on how to use the macros.

Signed-off-by: Noel Eck <noel.eck@intel.com>
This commit is contained in:
Noel Eck
2018-01-08 11:36:05 -08:00
parent 680649ba6f
commit 6725559669
10 changed files with 52 additions and 50 deletions

29
src/_upm.i Normal file
View File

@ -0,0 +1,29 @@
/* Macro for adding JAVA runnables.
example usage: JAVA_ADD_INSTALLISR(upm::A110x)
UPMClassName - UPM class name w/namespace.
*/
%define JAVA_ADD_INSTALLISR(UPMClassName)
%extend UPMClassName {
void installISR(jobject runnable)
{
$self->installISR(mraa_java_isr_callback, runnable);
}
}
%enddef
/* Macro for adding JNI loadLibrary dependency.
example usage: JAVA_JNI_LOADLIBRARY(javaupm_rhusb)
PackageName: Target UPM JAVA package.
*/
%define JAVA_JNI_LOADLIBRARY(PackageName)
%pragma(java) jniclasscode=%{
static {
try {
System.loadLibrary("PackageName");
} catch (UnsatisfiedLinkError e) {
System.err.println("Native code library (PackageName) failed to load. \n" + e);
System.exit(1);
}
}
%}
%enddef