Skip to content

Commit

Permalink
more java/SWIG build stuff
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2/bindings/java@8829 67ed7778-7388-44ab-90cf-0a291f65f57c
  • Loading branch information
ndim committed May 28, 2006
1 parent 7410e04 commit 06cb2ec
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 23 deletions.
35 changes: 32 additions & 3 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@

EXTRA_DIST = gphoto2.i TODO javatest.java.in

data_DATA = gphoto2.i
data_DATA = javatest.class

# FIXME: Is "sed -i" a standard?
gphoto2_wrap.c: $(srcdir)/gphoto2.i
mkdir -p swig/org/gphoto2
$(SWIG) -v -I$(top_srcdir) \
$(SWIG) -v -I$(top_builddir) \
-o gphoto2_wrap.c -oh gphoto2_wrap.h \
-java -package swig.org.gphoto2 -outdir swig/org/gphoto2 \
$(srcdir)/gphoto2.i
sed -i -e 's/ interface)/ interface1)/' \
swig/org/gphoto2/_GPPortSettingsUSB.java || exit -1

lib_LTLIBRARIES = libgphoto2_jni.la

Expand All @@ -18,9 +21,35 @@ libgphoto2_jni_la_CPPFLAGS = \
$(AM_CPPFLAGS) $(CPPFLAGS) \
$(LIBEXIF_CFLAGS)

libgphoto2_jni_la_SOURCES = gphoto2_wrap.c
nodist_libgphoto2_jni_la_SOURCES = gphoto2_wrap.c
libgphoto2_jni_la_LIBADD = \
$(top_builddir)/libgphoto2/libgphoto2.la \
$(top_builddir)/libgphoto2_port/libgphoto2_port/libgphoto2_port.la \
$(LIBEXIF_LIBS) \
$(INTLLIBS)

clean-local:
rm -rf swig

CLEANFILES = $(nodist_libgphoto2_jni_la_SOURCES) javatest.class javatest.java swig-org-gphoto2.jar

swig-org-gphoto2.jar: gphoto2_wrap.c
find swig/org/gphoto2 -type f -name '*.java' \
| xargs javac
find swig/org/gphoto2 -type f -name '*.class' \
| xargs jar cf swig-org-gphoto2.jar

javatest.java: $(srcdir)/javatest.java.in swig-org-gphoto2.jar
cat '$<' > '$@'

javatest.class: javatest.java
javac -classpath swig-org-gphoto2.jar javatest.java

javatest.sh: Makefile
echo '###' cp -f "$$PWD/.libs/libgphoto2_jni.so" "..../jre/lib/i386"
echo java -classpath .:swig-org-gphoto2.jar javatest > '$@'
chmod +x '$@'

check_SCRIPTS = javatest.sh

TESTS = javatest.sh
10 changes: 7 additions & 3 deletions TODO
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
This swig-java build process needs to be integrated into the libtool process used by the rest of the library
Bindings for other languages supported by SWIG
May need more helper functions in the SWIG interface file for dereferencing pointers and converting types.
* This swig-java build process needs to be integrated into the
libtool process used by the rest of the library
* Bindings for other languages supported by SWIG
* May need more helper functions in the SWIG interface file for
dereferencing pointers and converting types.
* Clean up build system
* Make bindings and test cases work with non-Sun java
37 changes: 22 additions & 15 deletions gphoto2.i
Original file line number Diff line number Diff line change
Expand Up @@ -17,45 +17,52 @@
%}

%{
#include <gphoto2/gphoto2.h>
#include <gphoto2/gphoto2-version.h>
#include <gphoto2/gphoto2-context.h>
#include <gphoto2/gphoto2-abilities-list.h>
#include <gphoto2/gphoto2-camera.h>
#include <gphoto2/gphoto2-context.h>
#include <gphoto2/gphoto2-endian.h>
#include <gphoto2/gphoto2-file.h>
#include <gphoto2/gphoto2-filesys.h>
#include <gphoto2/gphoto2.h>
#include <gphoto2/gphoto2-library.h>
#include <gphoto2/gphoto2-list.h>
#include <gphoto2/gphoto2-result.h>
#include <gphoto2/gphoto2-setting.h>
#include <gphoto2/gphoto2-widget.h>
#include <gphoto2/gphoto2-port.h>
#include <gphoto2/gphoto2-port-version.h>
#include <gphoto2/gphoto2-port-info-list.h>
#include <gphoto2/gphoto2-port-library.h>
#include <gphoto2/gphoto2-port-log.h>
#include <gphoto2/gphoto2-port-portability.h>
#include <gphoto2/gphoto2-port-portability-os2.h>
#include <gphoto2/gphoto2-port-result.h>
#include <gphoto2/gphoto2-port-version.h>
#include <gphoto2/gphoto2-result.h>
#include <gphoto2/gphoto2-setting.h>
#include <gphoto2/gphoto2-version.h>
#include <gphoto2/gphoto2-widget.h>
%}


%include "gphoto2/gphoto2.h"
%include "gphoto2/gphoto2-version.h"
%include "gphoto2/gphoto2-context.h"
%include "gphoto2/gphoto2-abilities-list.h"
%include "gphoto2/gphoto2-camera.h"
%include "gphoto2/gphoto2-camera.h"
%include "gphoto2/gphoto2-context.h"
%include "gphoto2/gphoto2-endian.h"
%include "gphoto2/gphoto2-file.h"
%include "gphoto2/gphoto2-filesys.h"
%include "gphoto2/gphoto2.h"
%include "gphoto2/gphoto2-library.h"
%include "gphoto2/gphoto2-list.h"
%include "gphoto2/gphoto2-result.h"
%include "gphoto2/gphoto2-setting.h"
%include "gphoto2/gphoto2-widget.h"
%include "gphoto2/gphoto2-port.h"
%include "gphoto2/gphoto2-port-version.h"
%include "gphoto2/gphoto2-port-info-list.h"
%include "gphoto2/gphoto2-port-library.h"
%include "gphoto2/gphoto2-port-log.h"
%include "gphoto2/gphoto2-port-portability.h"
%include "gphoto2/gphoto2-port-portability-os2.h"
%include "gphoto2/gphoto2-port-result.h"
%include "gphoto2/gphoto2-port-version.h"
%include "gphoto2/gphoto2-result.h"
%include "gphoto2/gphoto2-setting.h"
%include "gphoto2/gphoto2-version.h"
%include "gphoto2/gphoto2-widget.h"


%inline %{

Expand Down
11 changes: 9 additions & 2 deletions javatest.java.in
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@ public class javatest {
CameraFilePath cfpOut = new CameraFilePath();

result=-1;
int nLoops=0;
// int nLoops=0;
for (int i=0; result!=0 && i<5; i++) {
result = gphoto2.gp_camera_capture(cam, gphoto2Constants.GP_CAPTURE_IMAGE, cfpOut, context);
result = gphoto2.gp_camera_capture(cam, CameraCaptureType.GP_CAPTURE_IMAGE, cfpOut, context);
if (result != 0) System.out.println("unexpected JNI result '" + result + "', retrying...");
}
if (result != 0) throw new RuntimeException("unexpected JNI result '" + result + "'");
Expand Down Expand Up @@ -158,3 +158,10 @@ public class javatest {
System.out.println("exiting");
}
}


/*
* Local Variables:
* mode: java
* End:
*/

0 comments on commit 06cb2ec

Please sign in to comment.