diff --git a/packages/swig/Android.mk.in b/packages/swig/Android.mk.in new file mode 100644 index 000000000..44b2617eb --- /dev/null +++ b/packages/swig/Android.mk.in @@ -0,0 +1,12 @@ +# File: Android.mk +LOCAL_PATH := $(call my-dir) +NDK_TOOLCHAIN_VERSION := 4.8 +include $(CLEAR_VARS) +LOCAL_LDLIBS += @abs_top_builddir@/libYap.a @abs_top_builddir@/yapi.o +LOCAL_MODULE := example +LOCAL_SRC_FILES := yap_wrap.cpp +LOCAL_C_INCLUDES := @abs_top_builddir@ @srcdir@/../../H @srcdir@/../../include @srcdir@/../../os @srcdir@/../../OPTYap @srcdir@/../../BEAM @srcdir@/../../CXX +LOCAL_CFLAGS := @DEFS@ -D_YAP_NOT_INSTALLED_=1 +LOCAL_CPP_FEATURES := rtti +# LOCAL_ALLOW_UNDEFINED_SYMBOLS := true +include $(BUILD_SHARED_LIBRARY) diff --git a/packages/swig/Makefile.in b/packages/swig/Makefile.in index 02b45fb93..b2c1cc087 100644 --- a/packages/swig/Makefile.in +++ b/packages/swig/Makefile.in @@ -7,6 +7,7 @@ JAR=@JAR@ include ../Makefile.defs DEFS=@DEFS@ -D_YAP_NOT_INSTALLED_=1 -DDESTDIR=\"$(DESTDIR)\" YAP_EXTRAS=@YAP_EXTRAS@ +srcdir=@srcdir@ CPPFLAGS=@CPPFLAGS@ -I../.. -I$(srcdir)/../../H -I$(srcdir)/../../include -I$(srcdir)/../../os -I$(srcdir)/../../OPTYap -I$(srcdir)/../../BEAM -I$(srcdir)/../../CXX CXXFLAGS= @SHLIB_CXXFLAGS@ $(YAP_EXTRAS) $(DEFS) $(CPPFLAGS) @@ -34,16 +35,29 @@ java: jni/libyap.@SO@ java/yap.java jni/libyap.@SO@: jni/yap_wrap.o $(CXX) -shared $(LDSOFLAGS) -L ../.. -lYap -o $@ ../../yapi.o $< $(LIBS) @JPLLDFLAGS@ -L ../.. -lYap -lpthread -jni/yap_wrap.c: $(srcdir)/yap.i +jni/yap_wrap.cpp: $(srcdir)/yap.i $(SWIG) -c++ -java -package pt.up.fc.dcc.yap -outdir java -o $@ $(DEFS) $(CPPFLAGS) -Wall $< -jni/yap_wrap.o: jni/yap_wrap.c +jni/yap_wrap.o: jni/yap_wrap.cpp $(CXX) -c $(CXXFLAGS) @JPLCFLAGS@ $< -o $@ +android: android/jni/yap_wrap.cpp + +android/jni/yap_wrap.cpp: $(srcdir)/yap.i + android create project --target 1 --name SwigSimple --path ./android --activity SwigSimple --package org.swig.simple + ( cd android ; mkdir -p jni;\ + $(SWIG) -c++ -java -I$(srcdir)/../../CXX -package org.swig.simple -outdir src/org/swig/simple -o jni/yap_wrap.cpp $< ;\ + cp $(srcdir)/android/SwigSimple.java src/org/swig/simple/ ;\ + cp $(srcdir)/android/main.xml res/layout ;\ + cp ../Android.mk jni ;\ + ndk-build; \ + ant debug \ + ) + R: -yap.i: $(srcdir)/../../include/YapInterface.h +yap.i: $(srcdir)/../../../../include/YapInterface.h install: diff --git a/packages/swig/android/Application.mk b/packages/swig/android/Application.mk new file mode 100644 index 000000000..242e06845 --- /dev/null +++ b/packages/swig/android/Application.mk @@ -0,0 +1,2 @@ +# File: Application.mk +NDK_TOOLCHAIN_VERSION = 4.8 diff --git a/packages/swig/android/SwigSimple.java b/packages/swig/android/SwigSimple.java new file mode 100644 index 000000000..8d759acfc --- /dev/null +++ b/packages/swig/android/SwigSimple.java @@ -0,0 +1,55 @@ +package org.swig.simple; + +import android.app.Activity; +import android.os.Bundle; +import android.view.View; +import android.widget.TextView; +import android.widget.ScrollView; +import android.text.method.ScrollingMovementMethod; + +public class SwigSimple extends Activity +{ + TextView outputText = null; + ScrollView scroller = null; + + /** Called when the activity is first created. */ + @Override + public void onCreate(Bundle savedInstanceState) + { + super.onCreate(savedInstanceState); + setContentView(R.layout.main); + + outputText = (TextView)findViewById(R.id.OutputText); + outputText.setText("Press 'Run' to start...\n"); + outputText.setMovementMethod(new ScrollingMovementMethod()); + + scroller = (ScrollView)findViewById(R.id.Scroller); + } + + public void onRunButtonClick(View view) + { + outputText.append("Started...\n"); + nativeCall(); + outputText.append("Finished!\n"); + + // Ensure scroll to end of text + scroller.post(new Runnable() { + public void run() { + scroller.fullScroll(ScrollView.FOCUS_DOWN); + } + }); + } + + /** Calls into C/C++ code */ + public void nativeCall() + { + // YAPParams p = new YAPParams(); + //YAPEngine t = new YAPEngine( p ); // TODO + } + + /** static constructor */ + static { + System.loadLibrary("example"); + } + +} diff --git a/packages/swig/android/main.xml b/packages/swig/android/main.xml new file mode 100644 index 000000000..786da0304 --- /dev/null +++ b/packages/swig/android/main.xml @@ -0,0 +1,26 @@ + + +