Commit ed6f4e33 authored by Pavel Vainerman's avatar Pavel Vainerman

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

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