aboutsummaryrefslogtreecommitdiff
path: root/swig
diff options
context:
space:
mode:
authorJamie Bullock <jamie@jamiebullock.com>2014-11-08 00:07:02 +0000
committerJamie Bullock <jamie@jamiebullock.com>2014-11-08 00:07:02 +0000
commitba706261d3fc5b436aa6f09d57e62eeb77377d8f (patch)
tree4faadd5931a89a847ae9bb2345d9fe7bb0e2f778 /swig
parent89890e226e5da72743f885cefb5273c51baf094e (diff)
parent89a9ec7a352dc35141b8f9a87c202fdd448e9a6f (diff)
downloadLibXtract-ba706261d3fc5b436aa6f09d57e62eeb77377d8f.tar.gz
LibXtract-ba706261d3fc5b436aa6f09d57e62eeb77377d8f.tar.bz2
LibXtract-ba706261d3fc5b436aa6f09d57e62eeb77377d8f.zip
Merge branch 'feature/no-autotools' into develop
Diffstat (limited to 'swig')
-rw-r--r--swig/Makefile31
-rw-r--r--swig/Makefile.am11
-rw-r--r--swig/java/Makefile.am101
-rw-r--r--swig/java/jxtract.i73
-rw-r--r--swig/java/test.java36
-rw-r--r--swig/python/.gitignore2
-rw-r--r--swig/python/Makefile.am18
-rw-r--r--swig/python/__init__.py0
-rw-r--r--swig/test.py (renamed from swig/python/test.py)2
9 files changed, 32 insertions, 242 deletions
diff --git a/swig/Makefile b/swig/Makefile
new file mode 100644
index 0000000..2d47e12
--- /dev/null
+++ b/swig/Makefile
@@ -0,0 +1,31 @@
+NAME = xtract
+
+OS := $(shell uname)
+
+# Assume that since we're building the python bindings, we have a python installed!
+INCLUDEPY = $(shell python -m sysconfig | grep -w INCLUDEPY | awk '{print $$3}')
+
+ifeq ($(OS), Darwin)
+ CFLAGS=-g -c
+ LD=gcc
+ LDFLAGS=-bundle -flat_namespace -undefined suppress
+else
+ CFLAGS=-g -c -fPIC
+ LD=ld
+ LDFLAGS=-shared
+endif
+
+.PHONY: python
+
+python:
+ @swig -I../include -python $(NAME).i
+ @$(CC) $(CFLAGS) $(NAME)_wrap.c -o $(NAME)_wrap.o -I$(INCLUDEPY) -I../include
+ @$(CC) $(LDFLAGS) ../src/lib$(NAME).a $(NAME)_wrap.o -o _$(NAME).so -framework Accelerate
+
+clean:
+ @$(RM) *.o
+ @$(RM) *.pyc
+ @$(RM) *.so
+ @$(RM) $(NAME)_wrap.c
+ @$(RM) $(NAME).py
+
diff --git a/swig/Makefile.am b/swig/Makefile.am
deleted file mode 100644
index 536bfed..0000000
--- a/swig/Makefile.am
+++ /dev/null
@@ -1,11 +0,0 @@
-MAINTAINERCLEANFILES = Makefile.in
-
-if BUILD_JAVA
-JAVA_BUILD_DIR = java
-endif
-
-if BUILD_PYTHON
-PYTHON_BUILD_DIR = python
-endif
-
-SUBDIRS = $(JAVA_BUILD_DIR) $(PYTHON_BUILD_DIR)
diff --git a/swig/java/Makefile.am b/swig/java/Makefile.am
deleted file mode 100644
index 8205201..0000000
--- a/swig/java/Makefile.am
+++ /dev/null
@@ -1,101 +0,0 @@
-MAINTAINERCLEANFILES = all-local $(javasources) Makefile.in
-TESTNAME = test
-JAVA = java
-
-javasources = \
- SWIGTYPE_p_double.java \
- SWIGTYPE_p_int.java \
- SWIGTYPE_p_p_double.java \
- SWIGTYPE_p_unit_.java \
- SWIGTYPE_p_void.java \
- xtract_bool_t.java \
- xtractConstants.java \
- xtract_feature_init_.java \
- xtract_features_.java \
- xtract_feature_types_.java \
- xtract_function_descriptor_t_algo.java \
- xtract_function_descriptor_t_argv.java \
- xtract_function_descriptor_t_data.java \
- xtract_function_descriptor_t.java \
- xtract_function_descriptor_t_result.java \
- xtract_function_descriptor_t_result_scalar.java \
- xtract_function_descriptor_t_result_vector.java \
- xtract.java \
- xtractJNI.java \
- xtract_lnorm_filter_types_.java \
- xtract_mel_filter.java \
- xtract_mfcc_types_.java \
- xtract_return_codes_.java \
- xtract_spectrum_.java \
- xtract_type_t.java \
- xtract_unit_t.java \
- xtract_vector_t.java \
- xtract_window_types_.java
-
-
-
-javaclasses = \
- SWIGTYPE_p_double.class \
- SWIGTYPE_p_int.class \
- SWIGTYPE_p_p_double.class \
- SWIGTYPE_p_unit_.class \
- SWIGTYPE_p_void.class \
- xtract_bool_t.class \
- xtractConstants.class \
- xtract_feature_init_.class \
- xtract_features_.class \
- xtract_feature_types_.class \
- xtract_function_descriptor_t_algo.class \
- xtract_function_descriptor_t_argv.class \
- xtract_function_descriptor_t_data.class \
- xtract_function_descriptor_t.class \
- xtract_function_descriptor_t_result.class \
- xtract_function_descriptor_t_result_scalar.class \
- xtract_function_descriptor_t_result_vector.class \
- xtract.class \
- xtractJNI.class \
- xtract_lnorm_filter_types_.class \
- xtract_mel_filter.class \
- xtract_mfcc_types_.class \
- xtract_return_codes_.class \
- xtract_spectrum_.class \
- xtract_type_t.class \
- xtract_unit_t.class \
- xtract_vector_t.class \
- xtract_window_types_.class
-
-BUILT_SOURCES = xtract_wrap.c
-SWIG_SOURCES = jxtract.i
-
-lib_LTLIBRARIES = libjxtract.la
-libjxtract_la_SOURCES = $(BUILT_SOURCES) $(SWIG_SOURCES)
-libjxtract_la_CFLAGS = $(SWIG_PYTHON_CPPFLAGS) -I$(top_srcdir)/src
-libjxtract_la_LDFLAGS = -lxtract
-libjxtract_la_LIBADD = $(top_srcdir)/src/libxtract.la
-
-SWIG_JAVA_OPT = -java -package xtract.core
-
-xtract_wrap.c: $(SWIG_SOURCES)
- grep xtract_.*\(const $(top_srcdir)/xtract/xtract_* | grep argv | cut -d: -f 2 | sed 's/const void/void/g' > xtract_redeclare.i
- $(SWIG) $(SWIG_JAVA_OPT) -I$(top_srcdir) -o $@ $<
- mkdir -p xtract/core
- mkdir -p xtract/core/src
- mv $(javasources) xtract/core/src
-
-java-wrap:
- cd xtract/core/src && $(JAVAC) $(javasources)
- cd xtract/core/src && mv $(javaclasses) ../
-
-test:
- $(JAVAC) $(TESTNAME).java
-
-run:
- $(JAVA) -Djava.library.path=.libs $(TESTNAME)
-
-all-local: java-wrap $(TESTNAME)
-
-clean-local:
- -rm xtract_redeclare.i
- -rm -f libjxtract.so xtract_wrap.c $(TESTNAME).class xtract_subband_scales_.java #$(javasources) $(javaclasses) $(nonautojavaclasses) $(TESTNAME).class xtract_subband_scales_.java
- -rm -rf xtract
-
diff --git a/swig/java/jxtract.i b/swig/java/jxtract.i
deleted file mode 100644
index 5c8c1db..0000000
--- a/swig/java/jxtract.i
+++ /dev/null
@@ -1,73 +0,0 @@
-
-%include "../xtract.i"
-%include "arrays_java.i"
-
-%apply double[] {const double *data};
-%apply double *OUTPUT { double *result };
-%typemap(in,numinputs=0) JNIEnv *env "$1 = jenv;"
-
-%javamethodmodifiers arr2voidd "private";
-%javamethodmodifiers arr2voidi "private";
-%javamethodmodifiers freearrd "private";
-%javamethodmodifiers freearri "private";
-
-%inline %{
-jlong arr2voidd(JNIEnv *env, jdoubleArray arr) {
- void *ptr = (*env)->GetFloatArrayElements(env, arr, NULL);
- return (intptr_t)ptr;
-}
-
-void freearrd(JNIEnv *env, jdoubleArray arr, jlong map) {
- void *ptr = 0;
- ptr = *(void **)&map;
- (*env)->ReleaseFloatArrayElements(env, arr, ptr, JNI_ABORT);
-}
-
-jlong arr2voidi(JNIEnv *env, jintArray arr) {
- void *ptr = (*env)->GetIntArrayElements(env, arr, NULL);
- return (intptr_t)ptr;
-}
-
-void freearri(JNIEnv *env, jintArray arr, jlong map) {
- void *ptr = 0;
- ptr = *(void **)&map;
- (*env)->ReleaseIntArrayElements(env, arr, ptr, JNI_ABORT);
-}
-%}
-
-
-%pragma(java) modulecode=%{
- private static long arrPtr(Object o) {
- if (o instanceof double[]) {
- return arr2voidd((double[])o);
- }
- else if (o instanceof int[]) {
- return arr2voidi((int[])o);
- }
- else if (o == null) {
- return 0L;
- }
- throw new IllegalArgumentException();
- }
-
- private static void freeArrPtr(Object o, long addr) {
- if (o instanceof double[]) {
- freearrd((double[])o, addr);
- return;
- }
- else if (o instanceof int[]) {
- freearri((int[])o, addr);
- return;
- }
- else if (o == null) {
- return;
- }
- throw new IllegalArgumentException();
- }
-%}
-
-%typemap(jstype) void *argv "Object"
-%typemap(javain,pre=" long tmp$javainput = arrPtr($javainput);",post=" freeArrPtr($javainput, tmp$javainput);") void *argv "tmp$javainput"
-
-%include xtract_redeclare.i
-
diff --git a/swig/java/test.java b/swig/java/test.java
deleted file mode 100644
index 82dd768..0000000
--- a/swig/java/test.java
+++ /dev/null
@@ -1,36 +0,0 @@
-
-import xtract.core.*;
-import java.util.Arrays;
-
-public class test {
- public static void main(String argv[]) {
-
- try {
- System.loadLibrary("jxtract");
- }
- catch (UnsatisfiedLinkError e) {
- System.out.println("Failed to load the library \"jxtract\"");
- System.out.println(e.toString());
- System.exit(0);
- }
-
- System.out.println("\nRunning libxtract Java bindings test...\n");
-
- int len = 5;
- int retval = 0;
- double mean[] = new double[1];
- double variance[] = new double[1];
- double data[] = new double[len];
-
- for (int i = 0; i < len; i++){
- System.out.print(i * 3 + ", ");
- data[i] = i * 3;
- }
-
- retval = xtract.xtract_mean(data, len, null, mean);
- retval = xtract.xtract_variance(data, len, mean, variance);
-
- System.out.print("The mean of: " + Arrays.toString(data) + " is "
- + mean[0] + "\nThe variance is: " + variance[0] + "\n");
- }
-}
diff --git a/swig/python/.gitignore b/swig/python/.gitignore
deleted file mode 100644
index 6dfa0ae..0000000
--- a/swig/python/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-xtract.py
-xtract_wrap.c \ No newline at end of file
diff --git a/swig/python/Makefile.am b/swig/python/Makefile.am
deleted file mode 100644
index 833c2f3..0000000
--- a/swig/python/Makefile.am
+++ /dev/null
@@ -1,18 +0,0 @@
-MAINTAINERCLEANFILES = xtract.py xtract_wrap.c Makefile.in _xtract.so
-
-BUILT_SOURCES = xtract_wrap.c
-SWIG_SOURCES = ../xtract.i
-
-pkgpython_PYTHON = xtract.py __init__.py
-pkgpyexec_LTLIBRARIES = _xtract.la
-_xtract_la_SOURCES = $(BUILT_SOURCES) $(SWIG_SOURCES)
-_xtract_la_CFLAGS = $(AX_SWIG_PYTHON_CPPFLAGS) -I$(top_srcdir)/src
-_xtract_la_LDFLAGS = -module
-_xtract_la_LIBADD = $(top_srcdir)/src/libxtract.la
-
-$(srcdir)/xtract_wrap.c : $(SWIG_SOURCES)
- $(SWIG) $(AX_SWIG_PYTHON_OPT) -I$(top_srcdir) -o $@ $<
-
-clean-local:
- -rm -f _xtract.so xtract.py xtract_wrap.c xtract.pyc
-
diff --git a/swig/python/__init__.py b/swig/python/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/swig/python/__init__.py
+++ /dev/null
diff --git a/swig/python/test.py b/swig/test.py
index a89a6f9..4d14171 100644
--- a/swig/python/test.py
+++ b/swig/test.py
@@ -1,7 +1,7 @@
#!/usr/bin/python
try:
- import libxtract.xtract as xtract
+ import xtract
except ImportError:
print 'Failed to load the library "xtract"'