Mercurial > hg > libxtract
changeset 87:0df00d5c9269
Added basic SWIG wrapper generator (use ./configure --enable-swig etc)
author | Jamie Bullock <jamie@postlude.co.uk> |
---|---|
date | Tue, 04 Sep 2007 19:07:55 +0000 |
parents | ff9678537244 |
children | 525bfdf936c6 |
files | ChangeLog Makefile.am autogen.sh bootstrap configure.in src/scalar.c swig/Makefile.am swig/test.py swig/xtract.i |
diffstat | 9 files changed, 99 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Mon Sep 03 15:03:21 2007 +0000 +++ b/ChangeLog Tue Sep 04 19:07:55 2007 +0000 @@ -1,3 +1,7 @@ +2007-09-04 Jamie Bullock <jamie@postlude.co.uk> + * version 0.4.8 + * Added cursory SWIG Python wrapper generator + 2007-04-20 Jamie Bullock <jamie@postlude.co.uk> * version 0.4.7 * Added MSP example
--- a/Makefile.am Mon Sep 03 15:03:21 2007 +0000 +++ b/Makefile.am Tue Sep 04 19:07:55 2007 +0000 @@ -1,7 +1,14 @@ -MAINTAINERCLEANFILES = Makefile.in configure depcomp compile config.guess ltmain.sh config.sub missing install-sh aclocal.m4 config.h.in config.h.in~ +MAINTAINERCLEANFILES = Makefile.in configure depcomp compile config.guess ltmain.sh config.sub missing install-sh aclocal.m4 config.h.in config.h.in~ py-compile -SUBDIRS = src xtract examples @DOXYGEN@ +if BUILD_SWIG +SWIG_DIR = swig +endif + +SUBDIRS = src xtract examples $(SWIG_DIR) @DOXYGEN@ pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = libxtract.pc +ACLOCAL_AMFLAGS = -I m4 + +EXTRA_DIST = bootstrap autogen.sh README TODO
--- a/autogen.sh Mon Sep 03 15:03:21 2007 +0000 +++ b/autogen.sh Tue Sep 04 19:07:55 2007 +0000 @@ -8,11 +8,11 @@ case `uname -s` in Linux) LIBTOOLIZE=libtoolize - ACLOCALARGS='' + ACLOCALARGS='-I m4' ;; Darwin) LIBTOOLIZE=glibtoolize - ACLOCALARGS='-I /usr/share/aclocal' + ACLOCALARGS='-I /usr/share/aclocal -I m4' ;; *) echo error: unrecognized OS exit 1
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bootstrap Tue Sep 04 19:07:55 2007 +0000 @@ -0,0 +1,4 @@ +#!/bin/sh + +autoreconf --force --install -I config -I m4 +
--- a/configure.in Mon Sep 03 15:03:21 2007 +0000 +++ b/configure.in Tue Sep 04 19:07:55 2007 +0000 @@ -4,13 +4,13 @@ # Increment for feature additions and enhancements m4_define(libxtract_minor_version, 4) # Increment for fixes -m4_define(libxtract_fix_version, 7) +m4_define(libxtract_fix_version, 8) m4_define(libxtract_version, libxtract_major_version.libxtract_minor_version.libxtract_fix_version) PACKAGE=libxtract -AC_INIT(libxtract, libxtract_version, bugs@postlude.co.uk) +AC_INIT(libxtract, libxtract_version, libxtract-devel@lists.sourceforge.net) AC_DEFINE(LIBXTRACT_VERSION, libxtract_version, [LibXtract Version]) AM_INIT_AUTOMAKE($PACKAGE, $LIBXTRACT_VERSION) AM_CONFIG_HEADER(config.h) @@ -64,7 +64,7 @@ # age to 0. XTRACT_SO_VERSION=0:0:0 -CFLAGS="$CFLAGS -pedantic -ansi -Wall -Werror -std=c99 -I/usr/local/include" +CFLAGS="$CFLAGS -pedantic -ansi -fno-strict-aliasing -Wall -std=c99 -I/usr/local/include" LDFLAGS="$LDFLAGS -lm" AC_ARG_WITH(pd_dir, @@ -124,6 +124,7 @@ AM_CONDITIONAL(BUILD_PD_EXAMPLE, test "x${pd_example}" = 'xtrue') + dnl Enable debugging (no) AC_ARG_ENABLE(debug, [ --enable-debug[[=value]] compile with debug [[default=no]]], @@ -135,6 +136,25 @@ CFLAGS="$CFLAGS -O0 -ggdb -g" fi +AC_ARG_ENABLE(swig, + [ --enable-swig Generate swig bindings], + [case "${enableval}" in + yes) swig=true ;; + no) swig=false ;; + *) AC_MSG_ERROR(bad value ${enableval} for --enable-swig) ;; + esac],[swig=false]) + + +dnl SWIG stuff +if [[ "$swig" = "true" ]] ; then + AC_PROG_SWIG(1.3.21) + AM_PATH_PYTHON + SWIG_PYTHON + AC_DEFINE([BUILD_SWIG], [1], [Build the swig bindings]) +fi + +AM_CONDITIONAL(BUILD_SWIG, test "x${swig}" = 'xtrue') + dnl ------------------------------------------ dnl ---- do some magic to gues the host opsys dnl ---- taken from libvorbis configure.in @@ -212,7 +232,7 @@ AC_CONFIG_FILES([doc/documentation.doxygen libxtract.pc]) -AC_OUTPUT(Makefile src/Makefile xtract/Makefile doc/Makefile examples/Makefile examples/puredata/Makefile examples/simpletest/Makefile) +AC_OUTPUT(Makefile src/Makefile xtract/Makefile doc/Makefile examples/Makefile examples/puredata/Makefile examples/simpletest/Makefile swig/Makefile) echo echo "**************************************************************" @@ -240,7 +260,11 @@ else echo "PD external: no" fi - +if test "$swig" == "true"; then + echo "SWIG Python bindings: yes" +else + echo "SWIG Python bindings: no" +fi echo echo "**************************************************************" echo
--- a/src/scalar.c Mon Sep 03 15:03:21 2007 +0000 +++ b/src/scalar.c Tue Sep 04 19:07:55 2007 +0000 @@ -39,10 +39,12 @@ int xtract_mean(const float *data, const int N, const void *argv, float *result){ int n = N; + + *result = 0.f; while(n--) *result += data[n]; - + *result /= N; return XTRACT_SUCCESS;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/swig/Makefile.am Tue Sep 04 19:07:55 2007 +0000 @@ -0,0 +1,18 @@ +MAINTAINERCLEANFILES = xtract.py xtract_wrap.c Makefile.in _xtract.so + +BUILT_SOURCES = $(srcdir)/xtract_wrap.c +SWIG_SOURCES = xtract.i + +pkgpython_PYTHON = xtract.py +pkgpyexec_LTLIBRARIES = _xtract.la +_xtract_la_SOURCES = $(srcdir)/xtract_wrap.c $(SWIG_SOURCES) +_xtract_la_CFLAGS = $(SWIG_PYTHON_CPPFLAGS) -I$(top_srcdir)/src +_xtract_la_LDFLAGS = -module -lxtract +_xtract_la_LIBADD = ../src/libxtract.la + +xtract_wrap.c : $(SWIG_SOURCES) + $(SWIG) $(SWIG_PYTHON_OPT) -I$(top_srcdir) -o $@ $< + +clean-local: + -rm -f _xtract.so xtract.py xtract_wrap.c xtract.pyc +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/swig/test.py Tue Sep 04 19:07:55 2007 +0000 @@ -0,0 +1,18 @@ +#!/usr/bin/python + +import xtract + +len = 5 + +a = xtract.new_floatArray(len) + +for i in range(0, len): + xtract.floatArray_setitem(a, i, 2*i) + +retval,result = xtract.xtract_mean(a,len,None) + +print result + + + +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/swig/xtract.i Tue Sep 04 19:07:55 2007 +0000 @@ -0,0 +1,12 @@ +%module xtract +%include carrays.i +%include typemaps.i + +%{ +#include "xtract/xtract_scalar.h" +%} + +%array_functions(float, floatArray); +%apply float *OUTPUT { float *result }; + +%include "xtract/xtract_scalar.h"