Exemplo n.º 1
0
 def _remove_cc_test_case(filename=None, ed=None):
     """ Special function that removes the occurrences of a qa*.cc file
     from the CMakeLists.txt. """
     if filename[:2] != 'qa':
         return
     if self._info['version'] == '37':
         (base, ext) = os.path.splitext(filename)
         if ext == '.h':
             remove_pattern_from_file(self._file['qalib'],
                                      r'^#include "%s"\s*$' % filename)
             remove_pattern_from_file(self._file['qalib'],
                                      r'^\s*s->addTest\(gr::%s::%s::suite\(\)\);\s*$' % (
                                          self._info['modname'], base)
                                     )
             self.scm.mark_file_updated(self._file['qalib'])
         elif ext == '.cc':
             ed.remove_value('list',
                             r'\$\{CMAKE_CURRENT_SOURCE_DIR\}/%s' % filename,
                             to_ignore_start='APPEND test_%s_sources' % self._info['modname'])
             self.scm.mark_file_updated(ed.filename)
     else:
         filebase = os.path.splitext(filename)[0]
         ed.delete_entry('add_executable', filebase)
         ed.delete_entry('target_link_libraries', filebase)
         ed.delete_entry('GR_ADD_TEST', filebase)
         ed.remove_double_newlines()
         self.scm.mark_file_updated(ed.filename)
Exemplo n.º 2
0
 def _remove_cc_test_case(filename=None, ed=None):
     """ Special function that removes the occurrences of a qa*.cc file
     from the CMakeLists.txt. """
     if filename[:2] != 'qa':
         return
     if self._info['version'] == '37':
         (base, ext) = os.path.splitext(filename)
         if ext == '.h':
             remove_pattern_from_file(self._file['qalib'],
                                      '^#include "%s"\s*$' % filename)
             remove_pattern_from_file(
                 self._file['qalib'],
                 '^\s*s->addTest\(gr::%s::%s::suite\(\)\);\s*$' %
                 (self._info['modname'], base))
         elif ext == '.cc':
             ed.remove_value('list',
                             '\$\{CMAKE_CURRENT_SOURCE_DIR\}/%s' %
                             filename,
                             to_ignore_start='APPEND test_%s_sources' %
                             self._info['modname'])
     else:
         filebase = os.path.splitext(filename)[0]
         ed.delete_entry('add_executable', filebase)
         ed.delete_entry('target_link_libraries', filebase)
         ed.delete_entry('GR_ADD_TEST', filebase)
         ed.remove_double_newlines()
Exemplo n.º 3
0
 def _run_subdir_mk(self, path, globs, cmakeedit_func=None):
     """
     Runs almost like _run_subdir function, but intended for filename occurrences
     at  the rfnoc/fpga-src folder, which has no CMakelist.txt
     """
     # 1. Create a filtered list
     files = []
     for g in globs:
         files = files + glob.glob("%s/%s" % (path, g))
     files_filt = []
     print "Searching for matching files in %s/:" % path
     for f in files:
         if re.search(self._info['pattern'],
                      os.path.basename(f)) is not None:
             files_filt.append(f)
     if len(files_filt) == 0:
         print "None found."
         return []
     # 2. Delete files, Makefile entries and other occurrences
     files_deleted = []
     yes = self._info['yes']
     for f in files_filt:
         b = os.path.basename(f)
         if not yes:
             ans = raw_input("Really delete %s? [Y/n/a/q]: " %
                             f).lower().strip()
             if ans == 'a':
                 yes = True
             if ans == 'q':
                 sys.exit(0)
             if ans == 'n':
                 continue
         files_deleted.append(b)
         print "Deleting %s." % f
         self.scm.remove_file(f)
         os.unlink(f)
         print "Deleting occurrences of %s from %s/Makefile.srcs..." % (
             b, path)
         b = re.escape(b + ' \\\n')
         remove_pattern_from_file(os.path.join(path, 'Makefile.srcs'), b)
     self.scm.mark_files_updated(('%s/Makefile.srcs' % path, ))
     return files_deleted
Exemplo n.º 4
0
    def run(self):
        """ Go, go, go! """
        def _remove_cc_test_case(filename=None, ed=None):
            """ Special function that removes the occurrences of a qa*.cc file
            from the CMakeLists.txt. """
            if filename[:2] != 'qa':
                return
            filebase = os.path.splitext(filename)[0]
            ed.delete_entry('add_executable', filebase)
            ed.delete_entry('target_link_libraries', filebase)
            ed.delete_entry('GR_ADD_TEST', filebase)
            ed.remove_double_newlines()

        def _remove_py_test_case(filename=None, ed=None):
            """ Special function that removes the occurrences of a qa*.py file
            from the CMakeLists.txt. """
            if filename[:2] != 'qa':
                return
            filebase = os.path.splitext(filename)[0]
            ed.delete_entry('GR_ADD_TEST', filebase)
            ed.remove_double_newlines()

        def _make_swig_regex(filename):
            filebase = os.path.splitext(filename)[0]
            pyblockname = filebase.replace(self._info['modname'] + '_', '')
            regexp = r'^\s*GR_SWIG_BLOCK_MAGIC\(%s,\s*%s\);\s*%%include\s*"%s"\s*' % \
                    (self._info['modname'], pyblockname, filename)
            return regexp

        if not self._skip_subdirs['lib']:
            self._run_subdir('lib', ('*.cc', '*.h'), ('add_library', ),
                             cmakeedit_func=_remove_cc_test_case)
        if not self._skip_subdirs['include']:
            incl_files_deleted = self._run_subdir(
                'include', ('*.cc', '*.h'), ('install', ),
                cmakeedit_func=_remove_cc_test_case)
        if not self._skip_subdirs['swig']:
            for f in incl_files_deleted:
                remove_pattern_from_file('swig/' + self._get_mainswigfile(),
                                         _make_swig_regex(f))
                remove_pattern_from_file('swig/' + self._get_mainswigfile(),
                                         '#include "%s".*\n' % f)
        if not self._skip_subdirs['python']:
            py_files_deleted = self._run_subdir(
                'python', ('*.py', ), ('GR_PYTHON_INSTALL', ),
                cmakeedit_func=_remove_py_test_case)
            for f in py_files_deleted:
                remove_pattern_from_file('python/__init__.py',
                                         '.*import.*%s.*' % f[:-3])
        if not self._skip_subdirs['grc']:
            self._run_subdir('grc', ('*.xml', ), ('install', ))
Exemplo n.º 5
0
    def run(self):
        """ Go, go, go! """
        def _remove_cc_test_case(filename=None, ed=None):
            """ Special function that removes the occurrences of a qa*.cc file
            from the CMakeLists.txt. """
            if filename[:2] != 'qa':
                return
            filebase = os.path.splitext(filename)[0]
            ed.delete_entry('add_executable', filebase)
            ed.delete_entry('target_link_libraries', filebase)
            ed.delete_entry('GR_ADD_TEST', filebase)
            ed.remove_double_newlines()

        def _remove_py_test_case(filename=None, ed=None):
            """ Special function that removes the occurrences of a qa*.py file
            from the CMakeLists.txt. """
            if filename[:2] != 'qa':
                return
            filebase = os.path.splitext(filename)[0]
            ed.delete_entry('GR_ADD_TEST', filebase)
            ed.remove_double_newlines()

        def _make_swig_regex(filename):
            filebase = os.path.splitext(filename)[0]
            pyblockname = filebase.replace(self._info['modname'] + '_', '')
            regexp = r'^\s*GR_SWIG_BLOCK_MAGIC\(%s,\s*%s\);\s*%%include\s*"%s"\s*' % \
                    (self._info['modname'], pyblockname, filename)
            return regexp

        if not self._skip_subdirs['lib']:
            self._run_subdir('lib', ('*.cc', '*.h'), ('add_library',),
                             cmakeedit_func=_remove_cc_test_case)
        if not self._skip_subdirs['include']:
            incl_files_deleted = self._run_subdir('include', ('*.cc', '*.h'), ('install',),
                             cmakeedit_func=_remove_cc_test_case)
        if not self._skip_subdirs['swig']:
            for f in incl_files_deleted:
                remove_pattern_from_file('swig/'+self._get_mainswigfile(), _make_swig_regex(f))
                remove_pattern_from_file('swig/'+self._get_mainswigfile(), '#include "%s".*\n' % f)
        if not self._skip_subdirs['python']:
            py_files_deleted = self._run_subdir('python', ('*.py',), ('GR_PYTHON_INSTALL',),
                                                cmakeedit_func=_remove_py_test_case)
            for f in py_files_deleted:
                remove_pattern_from_file('python/__init__.py', '.*import.*%s.*' % f[:-3])
        if not self._skip_subdirs['grc']:
            self._run_subdir('grc', ('*.xml',), ('install',))
Exemplo n.º 6
0
    def run(self):
        """ Go, go, go! """
        def _remove_cc_test_case(filename=None, ed=None):
            """ Special function that removes the occurrences of a qa*.cc file
            from the CMakeLists.txt. """
            if filename[:2] != 'qa':
                return
            if self._info['version'] == '37':
                (base, ext) = os.path.splitext(filename)
                if ext == '.h':
                    remove_pattern_from_file(self._file['qalib'],
                                             '^#include "%s"\s*$' % filename)
                    remove_pattern_from_file(
                        self._file['qalib'],
                        '^\s*s->addTest\(gr::%s::%s::suite\(\)\);\s*$' %
                        (self._info['modname'], base))
                elif ext == '.cc':
                    ed.remove_value('list',
                                    '\$\{CMAKE_CURRENT_SOURCE_DIR\}/%s' %
                                    filename,
                                    to_ignore_start='APPEND test_%s_sources' %
                                    self._info['modname'])
            else:
                filebase = os.path.splitext(filename)[0]
                ed.delete_entry('add_executable', filebase)
                ed.delete_entry('target_link_libraries', filebase)
                ed.delete_entry('GR_ADD_TEST', filebase)
                ed.remove_double_newlines()

        def _remove_py_test_case(filename=None, ed=None):
            """ Special function that removes the occurrences of a qa*.{cc,h} file
            from the CMakeLists.txt and the qa_$modname.cc. """
            if filename[:2] != 'qa':
                return
            filebase = os.path.splitext(filename)[0]
            ed.delete_entry('GR_ADD_TEST', filebase)
            ed.remove_double_newlines()

        def _make_swig_regex(filename):
            filebase = os.path.splitext(filename)[0]
            pyblockname = filebase.replace(self._info['modname'] + '_', '')
            regexp = r'(^\s*GR_SWIG_BLOCK_MAGIC2?\(%s,\s*%s\);|^\s*.include\s*"(%s/)?%s"\s*)' % \
                    (self._info['modname'], pyblockname, self._info['modname'], filename)
            return regexp

        # Go, go, go!
        if not self._skip_subdirs['lib']:
            self._run_subdir('lib', ('*.cc', '*.h'), ('add_library', 'list'),
                             cmakeedit_func=_remove_cc_test_case)
        if not self._skip_subdirs['include']:
            incl_files_deleted = self._run_subdir(self._info['includedir'],
                                                  ('*.h', ), ('install', ))
        if not self._skip_subdirs['swig']:
            swig_files_deleted = self._run_subdir('swig', ('*.i', ),
                                                  ('install', ))
            for f in incl_files_deleted + swig_files_deleted:
                # TODO do this on all *.i files
                remove_pattern_from_file(self._file['swig'],
                                         _make_swig_regex(f))
        if not self._skip_subdirs['python']:
            py_files_deleted = self._run_subdir(
                'python', ('*.py', ), ('GR_PYTHON_INSTALL', ),
                cmakeedit_func=_remove_py_test_case)
            for f in py_files_deleted:
                remove_pattern_from_file(self._file['pyinit'],
                                         '.*import\s+%s.*' % f[:-3])
                remove_pattern_from_file(self._file['pyinit'],
                                         '.*from\s+%s\s+import.*\n' % f[:-3])
        if not self._skip_subdirs['grc']:
            self._run_subdir('grc', ('*.xml', ), ('install', ))
Exemplo n.º 7
0
    def run(self):
        """ Go, go, go! """
        def _remove_cc_test_case(filename=None, ed=None):
            """ Special function that removes the occurrences of a qa*.cc file
            from the CMakeLists.txt. """
            if filename[:2] != 'qa':
                return
            if self._info['version'] == '37':
                (base, ext) = os.path.splitext(filename)
                if ext == '.h':
                    remove_pattern_from_file(self._file['qalib'],
                                             '^#include "%s"\s*$' % filename)
                    remove_pattern_from_file(self._file['qalib'],
                                             '^\s*s->addTest\(gr::%s::%s::suite\(\)\);\s*$' % (
                                                    self._info['modname'], base)
                                            )
                elif ext == '.cc':
                    ed.remove_value('list',
                                    '\$\{CMAKE_CURRENT_SOURCE_DIR\}/%s' % filename,
                                    'APPEND test_%s_sources' % self._info['modname'])
            else:
                filebase = os.path.splitext(filename)[0]
                ed.delete_entry('add_executable', filebase)
                ed.delete_entry('target_link_libraries', filebase)
                ed.delete_entry('GR_ADD_TEST', filebase)
                ed.remove_double_newlines()

        def _remove_py_test_case(filename=None, ed=None):
            """ Special function that removes the occurrences of a qa*.{cc,h} file
            from the CMakeLists.txt and the qa_$modname.cc. """
            if filename[:2] != 'qa':
                return
            filebase = os.path.splitext(filename)[0]
            ed.delete_entry('GR_ADD_TEST', filebase)
            ed.remove_double_newlines()

        def _make_swig_regex(filename):
            filebase = os.path.splitext(filename)[0]
            pyblockname = filebase.replace(self._info['modname'] + '_', '')
            regexp = r'(^\s*GR_SWIG_BLOCK_MAGIC2?\(%s,\s*%s\);|^\s*.include\s*"(%s/)?%s"\s*)' % \
                    (self._info['modname'], pyblockname, self._info['modname'], filename)
            return regexp
        # Go, go, go!
        if not self._skip_subdirs['lib']:
            self._run_subdir('lib', ('*.cc', '*.h'), ('add_library',),
                             cmakeedit_func=_remove_cc_test_case)
        if not self._skip_subdirs['include']:
            incl_files_deleted = self._run_subdir(self._info['includedir'], ('*.h',), ('install',))
        if not self._skip_subdirs['swig']:
            swig_files_deleted = self._run_subdir('swig', ('*.i',), ('install',))
            for f in incl_files_deleted + swig_files_deleted:
                # TODO do this on all *.i files
                remove_pattern_from_file(self._file['swig'], _make_swig_regex(f))
        if not self._skip_subdirs['python']:
            py_files_deleted = self._run_subdir('python', ('*.py',), ('GR_PYTHON_INSTALL',),
                                                cmakeedit_func=_remove_py_test_case)
            for f in py_files_deleted:
                remove_pattern_from_file(self._file['pyinit'], '.*import\s+%s.*' % f[:-3])
                remove_pattern_from_file(self._file['pyinit'], '.*from\s+%s\s+import.*\n' % f[:-3])
        if not self._skip_subdirs['grc']:
            self._run_subdir('grc', ('*.xml',), ('install',))