The branch, master has been updated
via fdfee60311accfc15144f88a31e5618e6aaee35a (commit)
via 05c0dae8a9c05ef2eb945feae80b3fcec87f16b1 (commit)
from 3ab8f642787d972f9ceb8ed4a385c09aeb39848d (commit)
- Log -----------------------------------------------------------------
commit fdfee60311accfc15144f88a31e5618e6aaee35a
Author: Thomas Jarosch <thomas.jarosch@xxxxxxxxxxxxx>
Date: Tue Apr 7 19:30:20 2009 +0200
cmake support for the new python bindings
commit 05c0dae8a9c05ef2eb945feae80b3fcec87f16b1
Author: Tarek Heiland <tarek@xxxxxxxxxxxxxxx>
Date: Tue Apr 7 19:07:56 2009 +0200
Added python bindings
-----------------------------------------------------------------------
Summary of changes:
CMakeLists.txt | 1 +
ChangeLog | 2 +-
Makefile.am | 2 +-
bindings/CMakeLists.txt | 15 ++++++++++
bindings/Makefile.am | 4 +++
bindings/ftdi.i | 47 +++++++++++++++++++++++++++++++++
bindings/python/Makefile.am | 61 +++++++++++++++++++++++++++++++++++++++++++
bindings/python/setup.py.in | 17 ++++++++++++
configure.in | 55 ++++++++++++++++++++++++++++++++++++++-
9 files changed, 201 insertions(+), 3 deletions(-)
create mode 100644 bindings/CMakeLists.txt
create mode 100644 bindings/Makefile.am
create mode 100644 bindings/ftdi.i
create mode 100644 bindings/python/Makefile.am
create mode 100644 bindings/python/setup.py.in
diff --git a/CMakeLists.txt b/CMakeLists.txt
index dbf6052..9203c82 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -76,6 +76,7 @@ endif(${UNIX})
add_subdirectory(src)
add_subdirectory(ftdipp)
+add_subdirectory(bindings)
add_subdirectory(examples)
add_subdirectory(packages)
diff --git a/ChangeLog b/ChangeLog
index 00dfa0e..86dda1f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,7 +3,7 @@ New in 0.16 - 2009-XX-XX
* Relicensed C++ wrapper under GPLv2 + linking exception (Marek Vavruša and
Intra2net)
* Support for FT2232H and FT4232H (David Challis and Intra2net)
* Support for mingw cross compile (Uwe Bonnes)
-* Minor autoconf cleanup (Tarek Heiland)
+* Python bindings and minor autoconf cleanup (Tarek Heiland)
* Code cleanup in various places (Intra2net)
* Fixed ftdi_read_chipid in some cases (Matthias Richter)
* eeprom decode function and small cleanups (Marius Kintel)
diff --git a/Makefile.am b/Makefile.am
index 5d5e4c1..f764b35 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -2,7 +2,7 @@
# have all needed files, that a GNU package needs
AUTOMAKE_OPTIONS = foreign 1.4
-SUBDIRS = src $(LIBFTDI_MODULES) examples doc
+SUBDIRS = src bindings $(LIBFTDI_MODULES) examples doc
EXTRA_DIST = libftdi.spec libftdi.spec.in COPYING.LIB COPYING.GPL LICENSE
README AUTHORS ChangeLog libftdi-config.in CMakeLists.txt packages
diff --git a/bindings/CMakeLists.txt b/bindings/CMakeLists.txt
new file mode 100644
index 0000000..5d1061e
--- /dev/null
+++ b/bindings/CMakeLists.txt
@@ -0,0 +1,15 @@
+include(FindSWIG)
+include(FindPythonLibs)
+include(UseSWIG)
+
+if(SWIG_FOUND)
+if(PYTHONLIBS_FOUND)
+ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../src)
+ INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH})
+
+ SWIG_ADD_MODULE(ftdi python ftdi.i)
+ SWIG_LINK_LIBRARIES(ftdi ${PYTHON_LIBRARIES})
+
+ message(STATUS "Building python bindings via swig")
+endif(PYTHONLIBS_FOUND)
+endif(SWIG_FOUND)
diff --git a/bindings/Makefile.am b/bindings/Makefile.am
new file mode 100644
index 0000000..8405a12
--- /dev/null
+++ b/bindings/Makefile.am
@@ -0,0 +1,4 @@
+SUBDIRS = python
+
+EXTRA_DIST = ftdi.i
+
diff --git a/bindings/ftdi.i b/bindings/ftdi.i
new file mode 100644
index 0000000..ce24b58
--- /dev/null
+++ b/bindings/ftdi.i
@@ -0,0 +1,47 @@
+/* File: example.i */
+%module ftdi
+%include "typemaps.i"
+%include "cpointer.i"
+%typemap(in) unsigned char* = char*;
+%ignore ftdi_write_data_async;
+%ignore ftdi_async_complete;
+
+%include ftdi.h
+%{
+#include <ftdi.h>
+%}
+
+extern "C" {
+
+%apply char *OUTPUT { unsigned char *buf };
+ int ftdi_read_data(struct ftdi_context *ftdi, unsigned char *buf, int
size);
+%clear unsigned char *buf;
+%apply int *OUTPUT { unsigned int *chunksize };
+ int ftdi_read_data_get_chunksize(struct ftdi_context *ftdi, unsigned int
*chunksize);
+ int ftdi_write_data_get_chunksize(struct ftdi_context *ftdi, unsigned int
*chunksize);
+%clear unsigned int *chunksize;
+ //int ftdi_write_data_async(struct ftdi_context *ftdi, unsigned char *buf,
int size);
+ //void ftdi_async_complete(struct ftdi_context *ftdi, int wait_for_more);
+%apply char *OUTPUT { unsigned char *pins };
+ int ftdi_read_pins(struct ftdi_context *ftdi, unsigned char *pins);
+%clear unsigned char *pins;
+%apply char *OUTPUT { unsigned char *latency };
+ int ftdi_get_latency_timer(struct ftdi_context *ftdi, unsigned char
*latency);
+%clear unsigned char *status;
+%apply char *OUTPUT { unsigned char *latency };
+ int ftdi_poll_modem_status(struct ftdi_context *ftdi, unsigned short
*status);
+%clear unsigned char *status;
+%apply char *OUTPUT { unsigned char *output };
+ int ftdi_eeprom_build(struct ftdi_eeprom *eeprom, unsigned char *output);
+%clear unsigned char *output;
+%apply char *OUTPUT { unsigned char *eeprom };
+ int ftdi_read_eeprom(struct ftdi_context *ftdi, unsigned char *eeprom);
+ int ftdi_write_eeprom(struct ftdi_context *ftdi, unsigned char *eeprom);
+%clear unsigned char *eeprom;
+%apply int *OUTPUT { unsigned int *chipid };
+ int ftdi_read_chipid(struct ftdi_context *ftdi, unsigned int *chipid);
+%clear unsigned int *chipid;
+
+}
+
+
diff --git a/bindings/python/Makefile.am b/bindings/python/Makefile.am
new file mode 100644
index 0000000..2b47b6a
--- /dev/null
+++ b/bindings/python/Makefile.am
@@ -0,0 +1,61 @@
+
+## Process this file with automake to produce Makefile.in
+
+if HAVE_SWIG
+if HAVE_PYTHON
+if ENABLE_PYTHON_BINDING
+
+LIBFTDI_INTERFACE = $(top_srcdir)/src/ftdi.h
+SWIG_INTERFACE = ../ftdi.i
+
+BUILT_SOURCES = ftdi_wrap.c ftdi.py
+CLEANFILES = ftdi_wrap.c ftdi.py
+
+all-local: ftdi_wrap.c ftdi.py
+ @case "`uname`" in \
+ MINGW*) \
+ $(PYTHON) setup.py build --compiler=mingw32 \
+ ;; \
+ *) \
+ $(PYTHON) setup.py build \
+ ;; \
+ esac;
+
+# python on MinGW/MSYS requires pure Windows style paths
+# Using following (cd $dir && pwd -W) hack to get a nearly
+# native Windows path, then translating the forward slash
+# to a backward slash to make python distutils jolly.
+# P.S. the backslash has to be escaped thrice, hence a single
+# backslash turns into a sequence of eight (neat, huh?)
+#
+install-exec-local:
+ @case "`uname`" in \
+ MINGW*) \
+ NATIVE_WINDOWS_PREFIX="`cd $(DESTDIR)$(prefix) && pwd -W`"; \
+ NATIVE_WINDOWS_PREFIX="`echo $$NATIVE_WINDOWS_PREFIX | sed -e
's|/|\\\\\\\\|g'`"; \
+ $(PYTHON) setup.py install --prefix="$$NATIVE_WINDOWS_PREFIX" \
+ ;; \
+ *) \
+ $(PYTHON) setup.py install --prefix=$(DESTDIR)$(prefix) \
+ ;; \
+ esac;
+
+# This rule cleans up stuff installed by Python's setup.py
+# Unfortunately, Python's distutils do not provide an uninstall
+# command, so we have to make up for it here in uninstall-local
+# hook. This might break if distutils' behaviour changes as automake
+# has no control over what distutils install command does.
+#
+uninstall-local:
+ rm -rf $(DESTDIR)$(libdir)/python*/site-packages/*ftdi*
+
+clean-local:
+ $(PYTHON) setup.py clean --all
+
+ftdi_wrap.c ftdi.py: $(SWIG_INTERFACE) $(LIBFTDI_INTERFACE)
+ $(SWIG) -python -I$(top_srcdir)/src -o ftdi_wrap.c -outdir .
$(srcdir)/$(SWIG_INTERFACE)
+
+
+endif # ENABLE_PYTHON_BINDING
+endif # HAVE_PYTHON
+endif # HAVE_SWIG
diff --git a/bindings/python/setup.py.in b/bindings/python/setup.py.in
new file mode 100644
index 0000000..6140858
--- /dev/null
+++ b/bindings/python/setup.py.in
@@ -0,0 +1,17 @@
+# Process this file with configure to produce setup.py
+
+from distutils.core import setup, Extension
+setup(name='@PACKAGE_NAME@',
+ version='@PACKAGE_VERSION@',
+ description='libftdi Python binding',
+ author='Tarek Heiland',
+ author_email='@PACKAGE_BUGREPORT@',
+ maintainer='',
+ maintainer_email='@PACKAGE_BUGREPORT@',
+ url='',
+ py_modules=['ftdi'],
+ ext_modules=[Extension('_ftdi', ['ftdi_wrap.c'],
+ include_dirs=['@top_srcdir@/src'],
+
library_dirs=['@top_srcdir@/src/.libs','lib','/usr/lib'],
+ libraries=['ftdi'])],
+ )
diff --git a/configure.in b/configure.in
index d44f38d..4840777 100644
--- a/configure.in
+++ b/configure.in
@@ -84,11 +84,64 @@ dnl check for doxygen
AC_PATH_PROG(DOXYGEN, doxygen)
AM_CONDITIONAL(HAVE_DOXYGEN, test -n $DOXYGEN)
+dnl ============================
+dnl Bindings for other languages
+dnl ==
+
+dnl ===============
+dnl Checks for SWIG
+dnl ===============
+AC_PATH_PROG([SWIG], [swig])
+AM_CONDITIONAL(HAVE_SWIG, test "$SWIG")
+
+dnl =================
+dnl Checks for Python
+dnl =================
+AM_PATH_PYTHON([2.0],
+ [],
+ [AC_MSG_WARN([Python not found. Python is required to build
presage python binding. Python can be obtained from http://www.pyth
+on.org])])
+if test "$PYTHON"
+then
+ python_include_path=`$PYTHON -c "import distutils.sysconfig; print
distutils.sysconfig.get_python_inc();"`
+ AC_CHECK_HEADERS([${python_include_path}/Python.h],
+ [have_python_header=true],
+ [AC_MSG_WARN([Python.h header file not found. Python
development files are required to build presage python binding. Pyt
+hon can be obtained from http://www.python.org])],
+ [])
+fi
+AM_CONDITIONAL(HAVE_PYTHON, test "$PYTHON" -a "x$have_python_header" = "xtrue")
+
+AC_ARG_ENABLE([python-binding],
+ AS_HELP_STRING([--enable-python-binding],
+ [build python binding (default=no)]),
+ [ac_enable_python_binding=$enableval],
+ [ac_enable_python_binding=no])
+if test "x$ac_enable_python_binding" = "xyes"
+then
+ if test ! "$SWIG" -o ! "$PYTHON" -o ! "x$have_python_header" = "xtrue"
+ then
+ AC_MSG_WARN([Python binding for libftdi cannot be built. Ensure that
SWIG and Python packages are available.])
+ fi
+else
+ AC_MSG_NOTICE([Python binding for libftdi will not be built.])
+ AC_MSG_NOTICE([Enable Python binding module building with
--enable-python-binding])
+fi
+AM_CONDITIONAL(ENABLE_PYTHON_BINDING, test "x$ac_enable_python_binding" =
"xyes")
+
+if test "$SWIG" -a "$PYTHON" -a "x$have_python_header" = "xtrue" -a
"x$ac_enable_python_binding" = "xyes"
+then
+ AC_MSG_NOTICE([Python binding for libftdi will be built.])
+ build_python_binding="yes"
+else
+ build_python_binding="no"
+fi
+
AC_SUBST(LIBFTDI_MODULES)
AC_SUBST(LIBFTDI_MODULES_PKGCONFIG)
AC_OUTPUT([libftdi-config],[chmod a+x libftdi-config])
-AC_OUTPUT(Makefile src/Makefile examples/Makefile doc/Doxyfile doc/Makefile
libftdi.pc libftdi.spec)
+AC_OUTPUT(Makefile src/Makefile bindings/Makefile bindings/python/Makefile
bindings/python/setup.py examples/Makefile doc/Doxyfile doc/Makefile libftdi.pc
libftdi.spec)
if test "x$ENABLE_LIBFTDIPP" = "x1"; then
AC_OUTPUT(ftdipp/Makefile libftdipp.pc)
hooks/post-receive
--
A library to talk to FTDI chips
--
libftdi-git - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi-git+unsubscribe@xxxxxxxxxxxxxxxxxxxxxxx
|