diff options
Diffstat (limited to 'gr-howto-write-a-block/swig')
-rw-r--r-- | gr-howto-write-a-block/swig/.gitignore | 10 | ||||
-rw-r--r-- | gr-howto-write-a-block/swig/CMakeLists.txt | 61 | ||||
-rw-r--r-- | gr-howto-write-a-block/swig/Makefile.am | 58 | ||||
-rw-r--r-- | gr-howto-write-a-block/swig/Makefile.swig.gen | 145 | ||||
-rw-r--r-- | gr-howto-write-a-block/swig/howto.test | 69 | ||||
-rw-r--r-- | gr-howto-write-a-block/swig/howto_square2_ff.i | 9 | ||||
-rw-r--r-- | gr-howto-write-a-block/swig/howto_square_ff.i | 16 | ||||
-rw-r--r-- | gr-howto-write-a-block/swig/howto_swig.i | 21 | ||||
-rw-r--r-- | gr-howto-write-a-block/swig/run_guile_tests.in | 14 |
9 files changed, 71 insertions, 332 deletions
diff --git a/gr-howto-write-a-block/swig/.gitignore b/gr-howto-write-a-block/swig/.gitignore deleted file mode 100644 index 21a9eb98c..000000000 --- a/gr-howto-write-a-block/swig/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -/.deps -/.libs -/Makefile.in -/Makefile -/howto_swig.cc -/howto_swig.py -/gnuradio -/guile -/python -/run_guile_tests diff --git a/gr-howto-write-a-block/swig/CMakeLists.txt b/gr-howto-write-a-block/swig/CMakeLists.txt new file mode 100644 index 000000000..1e3e59e2c --- /dev/null +++ b/gr-howto-write-a-block/swig/CMakeLists.txt @@ -0,0 +1,61 @@ +# Copyright 2011 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. + +######################################################################## +# Include swig generation macros +######################################################################## +find_package(SWIG) +find_package(PythonLibs) +if(NOT SWIG_FOUND OR NOT PYTHONLIBS_FOUND) + return() +endif() +include(GrSwig) +include(GrPython) + +######################################################################## +# Setup swig generation +######################################################################## +foreach(incdir ${GNURADIO_CORE_INCLUDE_DIRS}) + list(APPEND GR_SWIG_INCLUDE_DIRS ${incdir}/swig) +endforeach(incdir) + +foreach(incdir ${GRUEL_INCLUDE_DIRS}) + list(APPEND GR_SWIG_INCLUDE_DIRS ${incdir}/gruel/swig) +endforeach(incdir) + +set(GR_SWIG_LIBRARIES gnuradio-howto) +set(GR_SWIG_DOC_FILE ${CMAKE_CURRENT_BINARY_DIR}/howto_swig_doc.i) +set(GR_SWIG_DOC_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/../include) + +GR_SWIG_MAKE(howto_swig howto_swig.i) + +######################################################################## +# Install the build swig module +######################################################################## +GR_SWIG_INSTALL(TARGETS howto_swig DESTINATION ${GR_PYTHON_DIR}/howto) + +######################################################################## +# Install swig .i files for development +######################################################################## +install( + FILES + howto_swig.i + ${CMAKE_CURRENT_BINARY_DIR}/howto_swig_doc.i + DESTINATION ${GR_INCLUDE_DIR}/howto/swig +) diff --git a/gr-howto-write-a-block/swig/Makefile.am b/gr-howto-write-a-block/swig/Makefile.am deleted file mode 100644 index 326004235..000000000 --- a/gr-howto-write-a-block/swig/Makefile.am +++ /dev/null @@ -1,58 +0,0 @@ -# -# Copyright 2004,2005,2006,2008,2009,2010 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -include $(top_srcdir)/Makefile.common -include $(top_srcdir)/Makefile.swig - -noinst_GUILE = howto.test - -AM_CPPFLAGS += -I$(top_srcdir)/lib - -################################### -# SWIG interfaces and libraries - -TOP_SWIG_IFILES = \ - howto_swig.i - -# Install so that they end up available as: -# import howto -# This ends up at: -# ${prefix}/lib/python${python_version}/site-packages/$(modname) -howto_swig_pythondir_category = $(modname) - -# additional libraries for linking with the SWIG-generated library -howto_swig_la_swig_libadd = \ - $(top_builddir)/lib/libgnuradio-howto.la - -# additional SWIG files to be installed -howto_swiginclude_headers = \ - howto_square_ff.i \ - howto_square2_ff.i - -EXTRA_DIST = $(howto_swiginclude_headers) - -if GUILE -TESTS = run_guile_tests -nobase_guile_DATA = \ - gnuradio/howto_swig.scm -endif - -EXTRA_DIST += $(nobase_guile_DATA) diff --git a/gr-howto-write-a-block/swig/Makefile.swig.gen b/gr-howto-write-a-block/swig/Makefile.swig.gen deleted file mode 100644 index 6b7be2185..000000000 --- a/gr-howto-write-a-block/swig/Makefile.swig.gen +++ /dev/null @@ -1,145 +0,0 @@ -# -*- Makefile -*- -# -# Copyright 2009 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -# Makefile.swig.gen for howto_swig.i - -## Default install locations for these files: -## -## Default location for the Python directory is: -## ${prefix}/lib/python${python_version}/site-packages/[category]/howto_swig -## Default location for the Python exec directory is: -## ${exec_prefix}/lib/python${python_version}/site-packages/[category]/howto_swig -## -## The following can be overloaded to change the install location, but -## this has to be done in the including Makefile.am -before- -## Makefile.swig is included. - -howto_swig_pythondir_category ?= howto_swig -howto_swig_pylibdir_category ?= $(howto_swig_pythondir_category) -howto_swig_pythondir = $(pythondir)/$(howto_swig_pythondir_category) -howto_swig_pylibdir = $(pyexecdir)/$(howto_swig_pylibdir_category) - -# The .so libraries for the guile modules get installed whereever guile -# is installed, usually /usr/lib/guile/gnuradio/ -# FIXME: determince whether these should be installed with gnuradio. -howto_swig_scmlibdir = $(libdir) - -# The scm files for the guile modules get installed where ever guile -# is installed, usually /usr/share/guile/site/howto_swig -# FIXME: determince whether these should be installed with gnuradio. -howto_swig_scmdir = $(guiledir) - -## SWIG headers are always installed into the same directory. - -howto_swig_swigincludedir = $(swigincludedir) - -## This is a template file for a "generated" Makefile addition (in -## this case, "Makefile.swig.gen"). By including the top-level -## Makefile.swig, this file will be used to generate the SWIG -## dependencies. Assign the variable TOP_SWIG_FILES to be the list of -## SWIG .i files to generated wrappings for; there can be more than 1 -## so long as the names are unique (no sorting is done on the -## TOP_SWIG_FILES list). This file explicitly assumes that a SWIG .i -## file will generate .cc, .py, and possibly .h files -- meaning that -## all of these files will have the same base name (that provided for -## the SWIG .i file). -## -## This code is setup to ensure parallel MAKE ("-j" or "-jN") does the -## right thing. For more info, see < -## http://sources.redhat.com/automake/automake.html#Multiple-Outputs > - -## Other cleaned files: dependency files generated by SWIG or this Makefile - -MOSTLYCLEANFILES += $(DEPDIR)/*.S* - -## Various SWIG variables. These can be overloaded in the including -## Makefile.am by setting the variable value there, then including -## Makefile.swig . - -howto_swig_swiginclude_HEADERS = \ - howto_swig.i \ - $(howto_swig_swiginclude_headers) - -if PYTHON -howto_swig_pylib_LTLIBRARIES = \ - _howto_swig.la - -_howto_swig_la_SOURCES = \ - python/howto_swig.cc \ - $(howto_swig_la_swig_sources) - -howto_swig_python_PYTHON = \ - howto_swig.py \ - $(howto_swig_python) - -_howto_swig_la_LIBADD = \ - $(STD_SWIG_LA_LIB_ADD) \ - $(howto_swig_la_swig_libadd) - -_howto_swig_la_LDFLAGS = \ - $(STD_SWIG_LA_LD_FLAGS) \ - $(howto_swig_la_swig_ldflags) - -_howto_swig_la_CXXFLAGS = \ - $(STD_SWIG_CXX_FLAGS) \ - -I$(top_builddir) \ - $(howto_swig_la_swig_cxxflags) - -python/howto_swig.cc: howto_swig.py -howto_swig.py: howto_swig.i - -# Include the python dependencies for this file --include python/howto_swig.d - -endif # end of if python - -if GUILE - -howto_swig_scmlib_LTLIBRARIES = \ - libguile-gnuradio-howto_swig.la -libguile_gnuradio_howto_swig_la_SOURCES = \ - guile/howto_swig.cc \ - $(howto_swig_la_swig_sources) -nobase_howto_swig_scm_DATA = \ - gnuradio/howto_swig.scm \ - gnuradio/howto_swig-primitive.scm -libguile_gnuradio_howto_swig_la_LIBADD = \ - $(STD_SWIG_LA_LIB_ADD) \ - $(howto_swig_la_swig_libadd) -libguile_gnuradio_howto_swig_la_LDFLAGS = \ - $(STD_SWIG_LA_LD_FLAGS) \ - $(howto_swig_la_swig_ldflags) -libguile_gnuradio_howto_swig_la_CXXFLAGS = \ - $(STD_SWIG_CXX_FLAGS) \ - -I$(top_builddir) \ - $(howto_swig_la_swig_cxxflags) - -guile/howto_swig.cc: gnuradio/howto_swig.scm -gnuradio/howto_swig.scm: howto_swig.i -gnuradio/howto_swig-primitive.scm: gnuradio/howto_swig.scm - -# Include the guile dependencies for this file --include guile/howto_swig.d - -endif # end of GUILE - - diff --git a/gr-howto-write-a-block/swig/howto.test b/gr-howto-write-a-block/swig/howto.test deleted file mode 100644 index dc257a61e..000000000 --- a/gr-howto-write-a-block/swig/howto.test +++ /dev/null @@ -1,69 +0,0 @@ -;;; -*- Scheme -*- -;;; -;;; Copyright 2010 Free Software Foundation, Inc. -;;; -;;; This file is part of GNU Radio -;;; -;;; GNU Radio is free software; you can redistribute it and/or modify -;;; it under the terms of the GNU General Public License as published by -;;; the Free Software Foundation; either version 3, or (at your option) -;;; any later version. -;;; -;;; GNU Radio is distributed in the hope that it will be useful, -;;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;;; GNU General Public License for more details. -;;; -;;; You should have received a copy of the GNU General Public License -;;; along with this program. If not, see <http://www.gnu.org/licenses/>. -;;; - -;;; If you're using Emacs's Scheme mode: -;;; (put 'with-test-prefix 'scheme-indent-function 1) - -;;; See the comments in gnuradio/test-suite/lib.scm for info on writing tests. -;;; See also the very end of the file, where the test-equal, test-eqv -;;; and test-eq macros are defined. - -(define-module (test-module) - #:use-module (oop goops) - #:use-module (gnuradio core) - #:use-module (gnuradio test-suite lib) - #:duplicates (merge-generics replace check)) - - -;; Use our module -(use-modules (gnuradio howto_swig)) - - -(define (vector-map f v) - (list->vector (map f (vector->list v)))) - - -(with-test-prefix "square-ff" - (let* ((src-data #(-3. 4. -5.5 2. 3.)) - (expected-result (vector-map (lambda (x) (* x x)) src-data)) - (tb (gr:top-block-swig "QA top block")) - (src (gr:vector-source-f src-data #f)) - (op (gr:howto-square-ff)) - (dst (gr:vector-sink-f))) - - (gr:connect tb src op dst) - - (gr:run tb) - (test-equal expected-result (gr:data dst)))) - - -(with-test-prefix "square2-ff" - (let* ((src-data #(-3. 4. -5.5 2. 3.)) - (expected-result (vector-map (lambda (x) (* x x)) src-data)) - (tb (gr:top-block-swig "QA top block")) - (src (gr:vector-source-f src-data #f)) - (op (gr:howto-square2-ff)) - (dst (gr:vector-sink-f))) - - (gr:connect tb src op dst) - - (gr:run tb) - (test-equal expected-result (gr:data dst)))) - diff --git a/gr-howto-write-a-block/swig/howto_square2_ff.i b/gr-howto-write-a-block/swig/howto_square2_ff.i deleted file mode 100644 index 683a93d61..000000000 --- a/gr-howto-write-a-block/swig/howto_square2_ff.i +++ /dev/null @@ -1,9 +0,0 @@ -GR_SWIG_BLOCK_MAGIC(howto,square2_ff); - -howto_square2_ff_sptr howto_make_square2_ff (); - -class howto_square2_ff : public gr_sync_block -{ -private: - howto_square2_ff (); -}; diff --git a/gr-howto-write-a-block/swig/howto_square_ff.i b/gr-howto-write-a-block/swig/howto_square_ff.i deleted file mode 100644 index f8ae76986..000000000 --- a/gr-howto-write-a-block/swig/howto_square_ff.i +++ /dev/null @@ -1,16 +0,0 @@ -/* - * First arg is the package prefix. - * Second arg is the name of the class minus the prefix. - * - * This does some behind-the-scenes magic so we can - * access howto_square_ff from python as howto.square_ff - */ -GR_SWIG_BLOCK_MAGIC(howto,square_ff); - -howto_square_ff_sptr howto_make_square_ff (); - -class howto_square_ff : public gr_block -{ -private: - howto_square_ff (); -}; diff --git a/gr-howto-write-a-block/swig/howto_swig.i b/gr-howto-write-a-block/swig/howto_swig.i index d0bbcdc11..dd662b5e5 100644 --- a/gr-howto-write-a-block/swig/howto_swig.i +++ b/gr-howto-write-a-block/swig/howto_swig.i @@ -1,21 +1,20 @@ /* -*- c++ -*- */ +#define HOWTO_API + %include "gnuradio.i" // the common stuff +//load generated python docstrings +%include "howto_swig_doc.i" + + %{ #include "howto_square_ff.h" #include "howto_square2_ff.h" %} -%include "howto_square_ff.i" -%include "howto_square2_ff.i" +GR_SWIG_BLOCK_MAGIC(howto,square_ff); +%include "howto_square_ff.h" -#if SWIGGUILE -%scheme %{ -(load-extension-global "libguile-gnuradio-howto_swig" "scm_init_gnuradio_howto_swig_module") -%} - -%goops %{ -(use-modules (gnuradio gnuradio_core_runtime)) -%} -#endif +GR_SWIG_BLOCK_MAGIC(howto,square2_ff); +%include "howto_square2_ff.h" diff --git a/gr-howto-write-a-block/swig/run_guile_tests.in b/gr-howto-write-a-block/swig/run_guile_tests.in deleted file mode 100644 index 5d08b0dd5..000000000 --- a/gr-howto-write-a-block/swig/run_guile_tests.in +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh - -. @top_builddir@/setup_guile_test_env - -# 1st argument is absolute path to hand coded guile source directory -# 2nd argument is absolute path to component C++ shared library build directory -# 3nd argument is absolute path to component SWIG build directory - -add_local_paths \ - @srcdir@ \ - @abs_builddir@ \ - @abs_builddir@ - -@GUILE@ -e main -c '(use-modules (gnuradio test-suite guile-test))' -t @srcdir@ |