diff options
author | Martin Braun <martin.braun@kit.edu> | 2013-11-19 14:47:01 +0100 |
---|---|---|
committer | Martin Braun <martin.braun@kit.edu> | 2013-11-19 15:02:06 +0100 |
commit | 0cb397ce39dbdc22ab990cc860e35ef503a08fda (patch) | |
tree | 3a0d86e985f5df84498d74ee5bde2abb9f166280 /gr-utils/python | |
parent | 86845ea15ab8d36f5c196c8ab56e5b77d43b4cf9 (diff) |
modtool: bugfixes for in-tree operation (include paths, license, cmake editing)
Diffstat (limited to 'gr-utils/python')
-rw-r--r-- | gr-utils/python/modtool/code_generator.py | 4 | ||||
-rw-r--r-- | gr-utils/python/modtool/modtool_add.py | 7 | ||||
-rw-r--r-- | gr-utils/python/modtool/templates.py | 35 |
3 files changed, 36 insertions, 10 deletions
diff --git a/gr-utils/python/modtool/code_generator.py b/gr-utils/python/modtool/code_generator.py index 1bdffa501b..99f91761af 100644 --- a/gr-utils/python/modtool/code_generator.py +++ b/gr-utils/python/modtool/code_generator.py @@ -48,6 +48,10 @@ class GRMTemplate(Cheetah.Template.Template): searchList['strip_arg_types_grc'] = strip_arg_types_grc Cheetah.Template.Template.__init__(self, src, searchList=searchList) self.grblocktype = self.grtypelist[searchList['blocktype']] + if searchList['is_component']: + self.include_dir_prefix = "gnuradio/" + searchList['modname'] + else: + self.include_dir_prefix = searchList['modname'] def get_template(tpl_id, **kwargs): """ Return the template given by tpl_id, parsed through Cheetah """ diff --git a/gr-utils/python/modtool/modtool_add.py b/gr-utils/python/modtool/modtool_add.py index 60748e3f1b..88b9068cda 100644 --- a/gr-utils/python/modtool/modtool_add.py +++ b/gr-utils/python/modtool/modtool_add.py @@ -126,6 +126,8 @@ class ModToolAdd(ModTool): return open('LICENSE').read() elif os.path.isfile('LICENCE'): return open('LICENCE').read() + elif self._info['is_component']: + return Templates['grlicense'] else: return Templates['defaultlicense'] @@ -221,8 +223,7 @@ class ModToolAdd(ModTool): self._write_tpl('block_cpp36', 'lib', fname_cc) if not self.options.skip_cmakefiles: ed = CMakeFileEditor(self._file['cmlib']) - cmake_list_var = self._info['modname'] + '_sources' - if self._info['is_component']: cmake_list_var = 'gr_' + cmake_list_var + cmake_list_var = '[a-z]*_?' + self._info['modname'] + '_sources' if not ed.append_value('list', fname_cc, to_ignore_start='APPEND ' + cmake_list_var): ed.append_value('add_library', fname_cc) ed.write() @@ -251,7 +252,7 @@ class ModToolAdd(ModTool): swig_block_magic_str = get_template('swig_block_magic', **self._info) open(self._file['swig'], 'a').write(swig_block_magic_str) include_str = '#include "%s%s%s.h"' % ( - self._info['modname'], + {True: 'gnuradio/' + self._info['modname'], False: self._info['modname']}[self._info['is_component']], mod_block_sep, self._info['blockname']) if re.search('#include', open(self._file['swig'], 'r').read()): diff --git a/gr-utils/python/modtool/templates.py b/gr-utils/python/modtool/templates.py index f8957938a6..6b68c21aa7 100644 --- a/gr-utils/python/modtool/templates.py +++ b/gr-utils/python/modtool/templates.py @@ -44,13 +44,34 @@ the Free Software Foundation, Inc., 51 Franklin Street, Boston, MA 02110-1301, USA. ''' % datetime.now().year +Templates['grlicense'] = ''' +Copyright %d 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. +''' % datetime.now().year + # Header file of a sync/decimator/interpolator block Templates['block_impl_h'] = '''/* -*- c++ -*- */ ${str_to_fancyc_comment($license)} \#ifndef INCLUDED_${modname.upper()}_${blockname.upper()}_IMPL_H \#define INCLUDED_${modname.upper()}_${blockname.upper()}_IMPL_H -\#include <${modname}/${blockname}.h> +\#include <${include_dir_prefix}/${blockname}.h> namespace gr { namespace ${modname} { @@ -107,7 +128,7 @@ ${str_to_fancyc_comment($license)} \#include <gnuradio/io_signature.h> #if $blocktype == 'noblock' -\#include <${modname}/${blockname}.h> +\#include <${include_dir_prefix}/${blockname}.h> #else \#include "${blockname}_impl.h" #end if @@ -259,7 +280,7 @@ ${str_to_fancyc_comment($license)} \#ifndef INCLUDED_${modname.upper()}_${blockname.upper()}_H \#define INCLUDED_${modname.upper()}_${blockname.upper()}_H -\#include <${modname}/api.h> +\#include <${include_dir_prefix}/api.h> #if $blocktype != 'noblock' \#include <gnuradio/${grblocktype}.h> #end if @@ -414,10 +435,10 @@ class ${blockname}(${parenttype}): Templates['qa_cpp'] = '''/* -*- c++ -*- */ ${str_to_fancyc_comment($license)} -\#include "qa_${blockname}.h" +\#include <gnuradio/attributes.h> \#include <cppunit/TestAssert.h> - -\#include <$modname/${blockname}.h> +\#include "qa_${blockname}.h" +\#include <${include_dir_prefix}/${blockname}.h> namespace gr { namespace ${modname} { @@ -549,7 +570,7 @@ GR_SWIG_BLOCK_MAGIC($modname, $blockname); #end if %include "${modname}_${blockname}.h" #else -%include "${modname}/${blockname}.h" +%include "${include_dir_prefix}/${blockname}.h" #if $blocktype != 'noblock' GR_SWIG_BLOCK_MAGIC2($modname, $blockname); #end if |