Commit ed6f4e33 authored by Pavel Vainerman's avatar Pavel Vainerman

(java): добился сборки и установки пакета

parent 4fc054de
......@@ -2,7 +2,7 @@
%def_enable mysql
%def_enable sqlite
%def_enable python
%def_disable java
%def_enable java
%def_enable rrd
%def_enable io
%def_enable logicproc
......@@ -13,7 +13,7 @@
Name: libuniset2
Version: 2.0
Release: alt23.1
Release: alt23.2
Summary: UniSet - library for building distributed industrial control systems
......@@ -50,9 +50,11 @@ BuildRequires: librrd-devel
%if_enabled python
BuildRequires: python-devel
BuildRequires(pre): rpm-build-python
%endif
# swig
# add_findprov_lib_path %python_sitelibdir/%oname
%if_enabled java
BuildRequires(pre): rpm-build-java
# BuildRequires: jpackage-compat
%endif
%if_enabled docs
......@@ -99,6 +101,16 @@ Requires: %name = %version-%release
Python interface for %name
%endif
%if_enabled java
%package -n %name-extension-java
Group: Development/Java
Summary: java wrapper for uniset
Requires: %name = %version-%release
%description -n %name-extension-java
%name-extension-java provides Java bindings for %name though a JNI wrapper.
%endif
%package utils
Summary: UniSet utilities
Group: Development/Tools
......@@ -321,7 +333,12 @@ mv -f %buildroot%python_sitelibdir_noarch/* %buildroot%python_sitelibdir/%oname
%dir %python_sitelibdir/%oname
%python_sitelibdir/*
%python_sitelibdir/%oname/*
%endif
%if_enabled java
%files -n %name-extension-java
%_javadir/*.jar
%_libdir/libjU*.so
%endif
%if_enabled docs
......@@ -410,6 +427,9 @@ mv -f %buildroot%python_sitelibdir_noarch/* %buildroot%python_sitelibdir/%oname
# ..
%changelog
* Sun Mar 29 2015 Pavel Vainerman <pv@altlinux.ru> 2.0-alt23.2
- java bindigs test build
* Sat Mar 28 2015 Pavel Vainerman <pv@altlinux.ru> 2.0-alt23.1
- add java support
......
......@@ -172,7 +172,17 @@ if test ${buildjava} = true; then
AC_MSG_RESULT([enabled])
dnl Java
# PKG_CHECK_MODULES(JAVA,java,,exit)
# AC_CHECK_PROG(SWIG, swig, yes, exit)
# HACK! absolute path!
JAVA_CFLAGS="-I/usr/lib/jdk/include -I/usr/lib/jdk/include/linux"
JAVA_LIBS=
AC_CHECK_PROG(JAR,jar,jar, exit)
AC_CHECK_PROG(JAVAC, javac, javac, exit)
AC_CHECK_PROG(SWIG, swig, swig, exit)
AC_SUBST(JAVA_CFLAGS)
AC_SUBST(JAVA_LIBS)
AC_SUBST(SWIG)
AC_SUBST(JAR)
else
AC_MSG_RESULT([disabled])
fi
......@@ -371,6 +381,7 @@ AC_CONFIG_FILES([Makefile
testsuite/Makefile
wrappers/Makefile
wrappers/java/Makefile
wrappers/java/MANIFEST.MF
wrappers/python/lib/Makefile
wrappers/python/lib/pyUniSet/Makefile
wrappers/python/Makefile])
......
......@@ -654,7 +654,7 @@ INPUT = DocPages/ \
../conf \
../Utilities \
../extensions \
../python
../wrappers
# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is
......
......@@ -654,7 +654,7 @@ INPUT = DocPages/ \
../conf \
../Utilities \
../extensions \
../python
../wrappers
# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is
......
Manifest-Version: 1.0
Name: ru/etersoft/uniset/
Specification-Title: "Java wrapper for the uniset library"
Specification-Version: "@VERSION@"
Specification-Vendor: "Etersoft"
Implementation-Title: "ru.etersoft.uniset"
Implementation-Version: "@VERSION@"
Implementation-Vendor: "Etersoft"
Extension-List: uniset
uniset-Extension-Name: "ru.etersoft.uniset"
uniset-Implementation-Version: @VERSION@
if DISABLE_JAVA
else
JAVA_CFLAGS=-I/usr/lib/jdk/include -I/usr/lib/jdk/include/linux
JAVA_LIBS=
package_name = ru.etersoft.uniset
package_dir = ru/etersoft/uniset
#python_SCRIPTS = pyUniSet.java pyUConnector.java pyUModbus.java pyUExceptions.java
# =============================================================
#lib_LTLIBRARIES = libjUConnector.la libjUModbus.la libjUExceptions.la libjUInterface.la
lib_LTLIBRARIES = libjUModbus.la
libjUModbus_la_SOURCES = UModbus.cc UModbus_wrap.cxx
libjUModbus_la_CXXFLAGS = $(UNISET_CFLAGS) $(UNISET_EXT_CFLAGS) $(COMCPP_CFLAGS) $(JAVA_CFLAGS)
libjUModbus_la_LDFLAGS = -module -avoid-version
libjUModbus_la_LIBADD = $(UNISET_LIBS) $(UNISET_EXT_LIBS) $(COMCPP_LIBS) $(JAVA_LIBS)
jUniSet.java: UInterface_wrap.cxx _jUInterface.la
jUConnector.java: UConnector_wrap.cxx _jUConnector.la
jUModbus.java: _jUModbus.la UModbus_wrap.cxx
jUExceptions.java: _jUExceptions.la
lib_LTLIBRARIES = _jUConnector.la _jUModbus.la _jUExceptions.la _jUInterface.la
UModbus_wrap.cxx: UInterface.i UModbus.h UModbus.i
mkdir -p $(package_dir)
swig -java -package $(package_name) -outdir $(package_dir) -c++ UModbus.i
_jUInterface_la_SOURCES = JUInterface.cc UInterface_wrap.cxx
_jUInterface_la_CXXFLAGS = $(UNISET_CFLAGS) $(JAVA_CFLAGS)
_jUInterface_la_LDFLAGS = -module -avoid-version
_jUInterface_la_LIBADD = $(UNISET_LIBS) $(JAVA_LIBS)
#libjUInterface_la_SOURCES = JUInterface.cc UInterface_wrap.cxx
#libjUInterface_la_CXXFLAGS = $(UNISET_CFLAGS) $(JAVA_CFLAGS)
#libjUInterface_la_LDFLAGS = -module -avoid-version
#libjUInterface_la_LIBADD = $(UNISET_LIBS) $(JAVA_LIBS)
UInterface_wrap.cxx: UInterface.i JUInterface.h
swig -java -c++ UInterface.i
#UInterface_wrap.cxx: UInterface.i JUInterface.h
# swig -java -c++ UInterface.i
_jUConnector_la_SOURCES = UConnector.cc UConnector_wrap.cxx
_jUConnector_la_CXXFLAGS = $(UNISET_CFLAGS) $(JAVA_CFLAGS)
_jUConnector_la_LDFLAGS = -module -avoid-version
_jUConnector_la_LIBADD = $(UNISET_LIBS) $(JAVA_LIBS)
#libjUConnector_la_SOURCES = UConnector.cc UConnector_wrap.cxx
#libjUConnector_la_CXXFLAGS = $(UNISET_CFLAGS) $(JAVA_CFLAGS)
#libjUConnector_la_LDFLAGS = -module -avoid-version
#libjUConnector_la_LIBADD = $(UNISET_LIBS) $(JAVA_LIBS)
UConnector_wrap.cxx: UConnector.i UConnector.h
swig -java -c++ UConnector.i
#UConnector_wrap.cxx: UConnector.i UConnector.h
# swig -java -c++ UConnector.i
_jUModbus_la_SOURCES = UModbus.cc UModbus_wrap.cxx
_jUModbus_la_CXXFLAGS = $(UNISET_CFLAGS) $(UNISET_EXT_CFLAGS) $(COMCPP_CFLAGS) $(JAVA_CFLAGS)
_jUModbus_la_LDFLAGS = -module -avoid-version
_jUModbus_la_LIBADD = $(UNISET_LIBS) $(UNISET_EXT_LIBS) $(COMCPP_LIBS) $(JAVA_LIBS)
#libjUExceptions_la_SOURCES = UExceptions_wrap.cxx
#libjUExceptions_la_CXXFLAGS = $(UNISET_CFLAGS) $(UNISET_EXT_CFLAGS) $(JAVA_CFLAGS)
#libjUExceptions_la_LDFLAGS = -module -avoid-version
#libjUExceptions_la_LIBADD = $(UNISET_LIBS) $(UNISET_EXT_LIBS) $(JAVA_LIBS)
UModbus_wrap.cxx: UInterface.i UModbus.h UModbus.i
swig -java -c++ UModbus.i
#UExceptions_wrap.cxx: UExceptions.i UExceptions.h
# swig -java -c++ UExceptions.i
_jUExceptions_la_SOURCES = UExceptions_wrap.cxx
_jUExceptions_la_CXXFLAGS = $(UNISET_CFLAGS) $(UNISET_EXT_CFLAGS) $(JAVA_CFLAGS)
_jUExceptions_la_LDFLAGS = -module -avoid-version
_jUExceptions_la_LIBADD = $(UNISET_LIBS) $(UNISET_EXT_LIBS) $(JAVA_LIBS)
clean-local:
rm -rf *_wrap.cxx *.jar classes.list *.class ru/
UExceptions_wrap.cxx: UExceptions.i UExceptions.h
swig -java -c++ UExceptions.i
javadir=@datadir@/java
java_DATA=uniset.jar
clean-local:
rm -rf *_wrap.cxx *.class
rm -rf `ls *.java | $(GREP) -v runme*`
jclasses: libjUModbus.la
find ru/ -type f -name '*.java' -print0 | xargs -0 $(JAVAC)
uniset.jar: jclasses
find ru -name '*.class' -print > classes.list
$(JAR) cmf MANIFEST.MF $@ @classes.list
endif
/*
%module mUExceptions
%{
#include "UExceptions.h"
%}
*/
%include "UExceptions.h"
%exception {
......
......@@ -3,21 +3,19 @@
#include "UModbus.h"
%}
/*
%include "UTypes.h"
%include "UExceptions.h"
%include UExceptions.i
%include "UModbus.h"
%pragma(java) jniclasscode=%{
static {
try {
System.loadLibrary("mUModbus");
System.loadLibrary("jUModbus");
} catch (UnsatisfiedLinkError e) {
System.err.println("Native code library failed to load. \n" + e);
System.err.println("JUModbus.so: Native code library failed to load. \n" + e);
System.exit(1);
}
}
%}
*/
%include "UTypes.h"
%include "UExceptions.h"
%include UExceptions.i
%include "UModbus.h"
%}
\ No newline at end of file
#!/bin/sh
javac runme_modbus.java && java -Djava.library.path=`pwd`/.libs -cp . runme_modbus
#!/bin/sh
javac runme_modbus.java && java runme_modbus
\ No newline at end of file
UJAR="/usr/share/java/uniset.jar:."
javac -cp $UJAR runme_modbus.java && java -cp $UJAR runme_modbus
import ru.etersoft.uniset.*;
public class runme_modbus {
public static void main(String argv[]) {
System.load("/home/pv/Projects/uniset-2.0/wrappers/java/.libs/_jUModbus.so");
System.load("/home/pv/Projects/uniset-2.0/wrappers/java/.libs/_jUExceptions.so");
UModbus u = new UModbus();
u.connect("localhost",2048);
for( int i=0; i<10; i++ )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment