diff options
-rw-r--r-- | config/grc_gruel.m4 | 8 | ||||
-rw-r--r-- | gruel/src/python/Makefile.am | 2 | ||||
-rw-r--r-- | gruel/src/python/__init__.py | 26 | ||||
-rwxr-xr-x | gruel/src/python/qa_pmt.py | 48 | ||||
-rw-r--r-- | gruel/src/python/run_tests.in | 4 | ||||
-rw-r--r-- | gruel/src/swig/Makefile.am | 60 | ||||
-rw-r--r-- | gruel/src/swig/Makefile.swig.gen | 54 | ||||
-rw-r--r-- | gruel/src/swig/pmt_swig.i (renamed from gruel/src/swig/pmt.i) | 6 |
8 files changed, 123 insertions, 85 deletions
diff --git a/config/grc_gruel.m4 b/config/grc_gruel.m4 index 729571434..c3238b39e 100644 --- a/config/grc_gruel.m4 +++ b/config/grc_gruel.m4 @@ -42,12 +42,16 @@ AC_DEFUN([GRC_GRUEL],[ gruel/src/include/gruel/Makefile \ gruel/src/include/gruel/inet.h \ gruel/src/lib/Makefile \ + gruel/src/swig/Makefile \ + gruel/src/python/Makefile \ + gruel/src/python/run_tests \ gruel/src/lib/pmt/Makefile \ gruel/src/lib/msg/Makefile \ gruel/src/scheme/Makefile \ gruel/src/scheme/gnuradio/Makefile \ ]) + dnl Allow creating autoconf independent header files for bytesex routines AC_CHECK_HEADER(arpa/inet.h, [GR_HAVE_ARPA_INET=1],[GR_HAVE_ARPA_INET=0]) AC_CHECK_HEADER(netinet/in.h, [GR_HAVE_NETINET_IN=1],[GR_HAVE_NETINET_IN=0]) @@ -56,5 +60,7 @@ AC_DEFUN([GRC_GRUEL],[ AC_SUBST(GR_HAVE_NETINET_IN) AC_SUBST(GR_HAVE_BYTESWAP) - GRC_BUILD_CONDITIONAL(gruel,[]) + GRC_BUILD_CONDITIONAL(gruel,[ + AC_CONFIG_COMMANDS([run_tests_gruel],[chmod +x gruel/src/python/run_tests]) + ]) ]) diff --git a/gruel/src/python/Makefile.am b/gruel/src/python/Makefile.am index 0eeaa9ad7..5a45510d5 100644 --- a/gruel/src/python/Makefile.am +++ b/gruel/src/python/Makefile.am @@ -1,5 +1,5 @@ # -# Copyright 2004,2005,2006,2008,2009 Free Software Foundation, Inc. +# Copyright 2011 Free Software Foundation, Inc. # # This file is part of GNU Radio # diff --git a/gruel/src/python/__init__.py b/gruel/src/python/__init__.py index a4917cf64..421a9aaa8 100644 --- a/gruel/src/python/__init__.py +++ b/gruel/src/python/__init__.py @@ -1 +1,25 @@ -# make this a package +# +# 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. +# + +# The presence of this file turns this directory into a Python package + +from pmt_swig import * + diff --git a/gruel/src/python/qa_pmt.py b/gruel/src/python/qa_pmt.py index fa6e680ec..00cdb064e 100755 --- a/gruel/src/python/qa_pmt.py +++ b/gruel/src/python/qa_pmt.py @@ -1,14 +1,42 @@ #!/usr/bin/env python +# +# 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. +# -import sys; -sys.path.append("../swig/"); -sys.path.append("../swig/.libs/"); -from gruel import pmt; +import unittest +import pmt_swig -a = pmt.pmt_intern("a"); -b = pmt.pmt_from_double(123765); -d1 = pmt.pmt_make_dict(); -d2 = pmt.pmt_dict_add(d1, a, b); -pmt.pmt_print(d2); -print pmt.pmt_serialize_str(d2); +class test_gruel_pmt(unittest.TestCase): + def test01 (self): + a = pmt_swig.pmt_intern("a") + b = pmt_swig.pmt_from_double(123765) + d1 = pmt_swig.pmt_make_dict() + d2 = pmt_swig.pmt_dict_add(d1, a, b) + pmt_swig.pmt_print(d2) + + def test02 (self): + const = 123765 + x_pmt = pmt_swig.pmt_from_double(const) + x_int = pmt_swig.pmt_to_double(x_pmt) + self.assertEqual(x_int, const) + +if __name__ == '__main__': + unittest.main() diff --git a/gruel/src/python/run_tests.in b/gruel/src/python/run_tests.in index 5f7bdc067..ff399bcc6 100644 --- a/gruel/src/python/run_tests.in +++ b/gruel/src/python/run_tests.in @@ -12,6 +12,6 @@ export DYLD_LIBRARY_PATH PATH=@abs_top_builddir@/gruel/:@abs_top_builddir@/gruel/.libs:$PATH @top_builddir@/run_tests.sh \ - @abs_top_srcdir@/gruel \ - @abs_top_builddir@/gruel \ + @abs_top_srcdir@/gruel/src \ + @abs_top_builddir@/gruel/src \ @srcdir@ diff --git a/gruel/src/swig/Makefile.am b/gruel/src/swig/Makefile.am index c6e9246e5..294045567 100644 --- a/gruel/src/swig/Makefile.am +++ b/gruel/src/swig/Makefile.am @@ -1,5 +1,5 @@ # -# Copyright 2001,2003,2004,2005,2006,2007,2008,2009,2010 Free Software Foundation, Inc. +# Copyright 2011 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -22,50 +22,34 @@ include $(top_srcdir)/Makefile.common include $(top_srcdir)/Makefile.swig -AM_CPPFLAGS = -I$(srcdir) $(STD_DEFINES_AND_INCLUDES) $(PYTHON_CPPFLAGS) \ - $(WITH_INCLUDES) - -TOP_SWIG_IFILES = \ - pmt.i - - -# SWIG headers get installed in ${prefix}/include/gnuradio/swig -swiginclude_HEADERS = \ - pmt.i - -# SWIG headers that get installed in ${prefix}/include/gnuradio/swig/... -nobase_swiginclude_HEADERS = +TESTS = +AM_CPPFLAGS = \ + -I$(top_srcdir)/gruel/src/lib \ + $(STD_DEFINES_AND_INCLUDES) \ + $(PYTHON_CPPFLAGS) \ + $(WITH_INCLUDES) -# special install for this top-level Python script which includes all -# of the split Python libraries. -ourpythondir = $(pythondir)/gruel -ourpython_PYTHON = \ - pmt.py \ - __init__.py - -# ---------------------------------------------------------------- -# FIXME As of swig 1.3.31, this still seems to be required... -# gnuradio_swig_bug_workaround.h : gnuradio_core_runtime.py $(srcdir)/gen-swig-bug-fix -# $(PYTHON) $(srcdir)/gen-swig-bug-fix python/gnuradio_core_runtime.cc $@ - -EXTRA_DIST += gen-swig-bug-fix - -# C/C++ headers get installed in ${prefix}/include/gnuradio -#grinclude_HEADERS = gnuradio_swig_bug_workaround.h -grinclude_HEADERS = +TOP_SWIG_IFILES = \ + pmt_swig.i +############################## +# SWIG interface and library +TOP_SWIG_IFILES = \ + pmt_swig.i # Install so that they end up available as: -# import gnuradio.gr +# import gruel.pmt # This ends up at: -# ${prefix}/lib/python${python_version}/site-packages/gnuradio/gr -pmt_pythondir_category = gruel - -# additional libraries for linking with each SWIG-generated library -pmt_la_swig_libadd = $(GRUEL_LA) +# ${prefix}/lib/python${python_version}/site-packages/gruel/pmt +pmt_swig_pythondir_category = \ + gruel/pmt -SWIG_GUILE_FLAGS += -DIN_GNURADIO_CORE +# additional libraries for linking with the SWIG-generated library +pmt_swig_la_swig_libadd = \ + $(abs_top_builddir)/gruel/src/lib/pmt/libpmt.la +# additional SWIG files to be installed +pmt_swig_swiginclude_headers = diff --git a/gruel/src/swig/Makefile.swig.gen b/gruel/src/swig/Makefile.swig.gen index 9b4f62f77..c6a2fb956 100644 --- a/gruel/src/swig/Makefile.swig.gen +++ b/gruel/src/swig/Makefile.swig.gen @@ -33,24 +33,24 @@ ## this has to be done in the including Makefile.am -before- ## Makefile.swig is included. -pmt_pythondir_category ?= gruel/pmt -pmt_pylibdir_category ?= $(pmt_pythondir_category) -pmt_pythondir = $(pythondir)/$(pmt_pythondir_category) -pmt_pylibdir = $(pyexecdir)/$(pmt_pylibdir_category) +pmt_swig_pythondir_category ?= gruel/pmt_swig +pmt_swig_pylibdir_category ?= $(pmt_swig_pythondir_category) +pmt_swig_pythondir = $(pythondir)/$(pmt_swig_pythondir_category) +pmt_swig_pylibdir = $(pyexecdir)/$(pmt_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. -pmt_scmlibdir = $(libdir) +pmt_swig_scmlibdir = $(libdir) # The scm files for the guile modules get installed where ever guile # is installed, usually /usr/share/guile/site/gnuradio_core_runtime # FIXME: determince whether these should be installed with gnuradio. -pmt_scmdir = $(guiledir) +pmt_swig_scmdir = $(guiledir) ## SWIG headers are always installed into the same directory. -pmt_swigincludedir = $(swigincludedir) +pmt_swig_swigincludedir = $(swigincludedir) ## This is a template file for a "generated" Makefile addition (in ## this case, "Makefile.swig.gen"). By including the top-level @@ -75,40 +75,40 @@ MOSTLYCLEANFILES += $(DEPDIR)/*.S* ## Makefile.am by setting the variable value there, then including ## Makefile.swig . -pmt_swiginclude_HEADERS = \ - pmt.i \ - $(pmt_swiginclude_headers) +pmt_swig_swiginclude_HEADERS = \ + pmt_swig.i \ + $(pmt_swig_swiginclude_headers) if PYTHON -pmt_pylib_LTLIBRARIES = \ - _pmt.la +pmt_swig_pylib_LTLIBRARIES = \ + _pmt_swig.la -_pmt_la_SOURCES = \ - python/pmt.cc \ - $(pmt_la_swig_sources) +_pmt_swig_la_SOURCES = \ + python/pmt_swig.cc \ + $(pmt_swig_la_swig_sources) -pmt_python_PYTHON = \ - pmt.py \ - $(pmt_python) +pmt_swig_python_PYTHON = \ + pmt_swig.py \ + $(pmt_swig_python) -_pmt_la_LIBADD = \ +_pmt_swig_la_LIBADD = \ $(STD_SWIG_LA_LIB_ADD) \ - $(pmt_la_swig_libadd) + $(pmt_swig_la_swig_libadd) -_pmt_la_LDFLAGS = \ +_pmt_swig_la_LDFLAGS = \ $(STD_SWIG_LA_LD_FLAGS) \ - $(pmt_la_swig_ldflags) + $(pmt_swig_la_swig_ldflags) -_pmt_la_CXXFLAGS = \ +_pmt_swig_la_CXXFLAGS = \ $(STD_SWIG_CXX_FLAGS) \ -I$(top_builddir) \ - $(pmt_la_swig_cxxflags) + $(pmt_swig_la_swig_cxxflags) -python/pmt.cc: pmt.py -pmt.py: pmt.i +python/pmt_swig.cc: pmt_swig.py +pmt_swig.py: pmt_swig.i # Include the python dependencies for this file --include python/pmt.d +-include python/pmt_swig.d endif # end of if python diff --git a/gruel/src/swig/pmt.i b/gruel/src/swig/pmt_swig.i index e5f9ba0a2..54b50660d 100644 --- a/gruel/src/swig/pmt.i +++ b/gruel/src/swig/pmt_swig.i @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2006,2009,2010 Free Software Foundation, Inc. + * Copyright 2011 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -753,7 +753,3 @@ std::string pmt_serialize_str(pmt_t obj); * \brief Provide a simple string generating interface to pmt's deserialize function */ pmt_t pmt_deserialize_str(std::string str); - - - - |