diff options
author | Martin Braun <martin.braun@kit.edu> | 2013-10-24 00:11:26 +0200 |
---|---|---|
committer | Johnathan Corgan <johnathan@corganlabs.com> | 2013-10-28 08:47:19 -0700 |
commit | e24a2dbde4a2a6c1aa340d5c14ac05c2d93f4443 (patch) | |
tree | 66b62dc5e846d5460886193d9dcb672193caa125 /gr-utils/python | |
parent | d4e76a2afc13c1e2e38514eebf25e02f0a371aba (diff) |
modtool: Fixes for in-tree adds, argument parsing (&-bug)
Diffstat (limited to 'gr-utils/python')
-rw-r--r-- | gr-utils/python/modtool/modtool_add.py | 12 | ||||
-rw-r--r-- | gr-utils/python/modtool/modtool_base.py | 17 | ||||
-rw-r--r-- | gr-utils/python/modtool/modtool_info.py | 5 | ||||
-rw-r--r-- | gr-utils/python/modtool/util_functions.py | 2 |
4 files changed, 25 insertions, 11 deletions
diff --git a/gr-utils/python/modtool/modtool_add.py b/gr-utils/python/modtool/modtool_add.py index 81103e460d..10f89c569d 100644 --- a/gr-utils/python/modtool/modtool_add.py +++ b/gr-utils/python/modtool/modtool_add.py @@ -220,7 +220,9 @@ class ModToolAdd(ModTool): self._write_tpl('block_cpp36', 'lib', fname_cc) if not self.options.skip_cmakefiles: ed = CMakeFileEditor(self._file['cmlib']) - if not ed.append_value('list', fname_cc, to_ignore_start='APPEND %s_sources' % self._info['modname']): + cmake_list_var = self._info['modname'] + '_sources' + if self._info['is_component']: cmake_list_var = 'gr_' + cmake_list_var + if not ed.append_value('list', fname_cc, to_ignore_start='APPEND ' + cmake_list_var): ed.append_value('add_library', fname_cc) ed.write() ed = CMakeFileEditor(self._file['cminclude']) @@ -266,11 +268,11 @@ class ModToolAdd(ModTool): - include in CMakeLists.txt """ fname_py_qa = 'qa_' + self._info['blockname'] + '.py' - self._write_tpl('qa_python', 'python', fname_py_qa) - os.chmod(os.path.join('python', fname_py_qa), 0755) + self._write_tpl('qa_python', self._info['pydir'], fname_py_qa) + os.chmod(os.path.join(self._info['pydir'], fname_py_qa), 0755) if self.options.skip_cmakefiles or CMakeFileEditor(self._file['cmpython']).check_for_glob('qa_*.py'): return - print "Editing python/CMakeLists.txt..." + print "Editing %s/CMakeLists.txt..." % self._info['pydir'] open(self._file['cmpython'], 'a').write( 'GR_ADD_TEST(qa_%s ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/%s)\n' % \ (self._info['blockname'], fname_py_qa)) @@ -283,7 +285,7 @@ class ModToolAdd(ModTool): - include in __init__.py """ fname_py = self._info['blockname'] + '.py' - self._write_tpl('block_python', 'python', fname_py) + self._write_tpl('block_python', self._info['pydir'], fname_py) append_re_line_sequence(self._file['pyinit'], '(^from.*import.*\n|# import any pure.*\n)', 'from %s import %s' % (self._info['blockname'], self._info['blockname'])) diff --git a/gr-utils/python/modtool/modtool_base.py b/gr-utils/python/modtool/modtool_base.py index 081c10aaf9..577985b6f3 100644 --- a/gr-utils/python/modtool/modtool_base.py +++ b/gr-utils/python/modtool/modtool_base.py @@ -87,7 +87,10 @@ class ModTool(object): print "No GNU Radio module found in the given directory. Quitting." sys.exit(1) print "GNU Radio module name identified: " + self._info['modname'] - if self._info['version'] == '36' and os.path.isdir(os.path.join('include', self._info['modname'])): + if self._info['version'] == '36' and ( + os.path.isdir(os.path.join('include', self._info['modname'])) or + os.path.isdir(os.path.join('include', 'gnuradio', self._info['modname'])) + ): self._info['version'] = '37' if options.skip_lib or not self._has_subdirs['lib']: self._skip_subdirs['lib'] = True @@ -106,12 +109,17 @@ class ModTool(object): """ Initialise the self._file[] dictionary """ if not self._skip_subdirs['swig']: self._file['swig'] = os.path.join('swig', self._get_mainswigfile()) + self._info['pydir'] = 'python' + if os.path.isdir(os.path.join('python', self._info['modname'])): + self._info['pydir'] = os.path.join('python', self._info['modname']) self._file['qalib'] = os.path.join('lib', 'qa_%s.cc' % self._info['modname']) - self._file['pyinit'] = os.path.join('python', '__init__.py') + self._file['pyinit'] = os.path.join(self._info['pydir'], '__init__.py') self._file['cmlib'] = os.path.join('lib', 'CMakeLists.txt') self._file['cmgrc'] = os.path.join('grc', 'CMakeLists.txt') - self._file['cmpython'] = os.path.join('python', 'CMakeLists.txt') - if self._info['version'] in ('37', 'component'): + self._file['cmpython'] = os.path.join(self._info['pydir'], 'CMakeLists.txt') + if self._info['is_component']: + self._info['includedir'] = os.path.join('include', 'gnuradio', self._info['modname']) + elif self._info['version'] == '37': self._info['includedir'] = os.path.join('include', self._info['modname']) else: self._info['includedir'] = 'include' @@ -129,6 +137,7 @@ class ModTool(object): except OSError: print "Can't read or chdir to directory %s." % directory return False + self._info['is_component'] = False for f in files: if os.path.isfile(f) and f == 'CMakeLists.txt': if re.search('find_package\(GnuradioRuntime\)', open(f).read()) is not None or \ diff --git a/gr-utils/python/modtool/modtool_info.py b/gr-utils/python/modtool/modtool_info.py index 0f0f66f3fd..3b392a3102 100644 --- a/gr-utils/python/modtool/modtool_info.py +++ b/gr-utils/python/modtool/modtool_info.py @@ -67,7 +67,10 @@ class ModToolInfo(ModTool): else: print "No module found." exit(1) - if self._info['version'] == '36' and os.path.isdir(os.path.join('include', mod_info['modname'])): + if self._info['version'] == '36' and ( + os.path.isdir(os.path.join('include', mod_info['modname'])) or + os.path.isdir(os.path.join('include', 'gnuradio', mod_info['modname'])) + ): self._info['version'] = '37' mod_info['version'] = self._info['version'] if 'is_component' in self._info.keys(): diff --git a/gr-utils/python/modtool/util_functions.py b/gr-utils/python/modtool/util_functions.py index 6de854da88..71a7a7f535 100644 --- a/gr-utils/python/modtool/util_functions.py +++ b/gr-utils/python/modtool/util_functions.py @@ -79,7 +79,7 @@ def strip_arg_types(string): """" Strip the argument types from a list of arguments Example: "int arg1, double arg2" -> "arg1, arg2" """ string = strip_default_values(string) - return ", ".join([part.strip().split(' ')[-1] for part in string.split(',')]) + return ", ".join([part.strip().split(' ')[-1] for part in string.split(',')]).replace('&', '') def strip_arg_types_grc(string): """" Strip the argument types from a list of arguments for GRC make tag. |