Exemple #1
0
    def setup(self, options, args):
        ModTool.setup(self, options, args)

        self._info['blocktype'] = options.block_type
        if self._info['blocktype'] is None:
            # Print list out of blocktypes to user for reference
            print str(self._block_types)
            while self._info['blocktype'] not in self._block_types:
                self._info['blocktype'] = raw_input("Enter block type: ")
                if self._info['blocktype'] not in self._block_types:
                    print 'Must be one of ' + str(self._block_types)
        # Allow user to specify language interactively if not set
        self._info['lang'] = options.lang
        if self._info['lang'] is None:
            while self._info['lang'] not in ['cpp', 'python']:
                self._info['lang'] = raw_input("Language (python/cpp): ")
        if self._info['lang'] == 'c++':
            self._info['lang'] = 'cpp'

        print "Language: %s" % {'cpp': 'C++', 'python': 'Python'}[self._info['lang']]

        if ((self._skip_subdirs['lib'] and self._info['lang'] == 'cpp')
             or (self._skip_subdirs['python'] and self._info['lang'] == 'python')):
            raise ModToolException('Missing or skipping relevant subdir.')

        if self._info['blockname'] is None:
            if len(args) >= 2:
                self._info['blockname'] = args[1]
            else:
                self._info['blockname'] = raw_input("Enter name of block/code (without module name prefix): ")
        if not re.match('[a-zA-Z0-9_]+', self._info['blockname']):
            raise ModToolException('Invalid block name.')
        print "Block/code identifier: " + self._info['blockname']
        self._info['fullblockname'] = self._info['modname'] + '_' + self._info['blockname']
        if not options.license_file:
            self._info['copyrightholder'] = options.copyright
            if self._info['copyrightholder'] is None:
                self._info['copyrightholder'] = '<+YOU OR YOUR COMPANY+>'
            elif self._info['is_component']:
                print "For GNU Radio components the FSF is added as copyright holder"
        self._license_file = options.license_file
        self._info['license'] = self.setup_choose_license()
        if options.argument_list is not None:
            self._info['arglist'] = options.argument_list
        else:
            self._info['arglist'] = raw_input('Enter valid argument list, including default arguments: ')

        if not (self._info['blocktype'] in ('noblock') or self._skip_subdirs['python']):
            self._add_py_qa = options.add_python_qa
            if self._add_py_qa is None:
                self._add_py_qa = ask_yes_no('Add Python QA code?', True)
        if self._info['lang'] == 'cpp':
            self._add_cc_qa = options.add_cpp_qa
            if self._add_cc_qa is None:
                self._add_cc_qa = ask_yes_no('Add C++ QA code?', not self._add_py_qa)
        self._skip_cmakefiles = options.skip_cmakefiles
        if self._info['version'] == 'autofoo' and not self._skip_cmakefiles:
            print "Warning: Autotools modules are not supported. ",
            print "Files will be created, but Makefiles will not be edited."
            self._skip_cmakefiles = True
Exemple #2
0
    def setup(self):
        ModTool.setup(self)
        options = self.options
        self._info['blocktype'] = options.block_type
        if self._info['blocktype'] is None:
            while self._info['blocktype'] not in self._block_types:
                self._info['blocktype'] = raw_input("Enter code type: ")
                if self._info['blocktype'] not in self._block_types:
                    print 'Must be one of ' + str(self._block_types)
        self._info['lang'] = options.lang
        if self._info['lang'] == 'c++':
            self._info['lang'] = 'cpp'
        print "Language: %s" % {
            'cpp': 'C++',
            'python': 'Python'
        }[self._info['lang']]

        if ((self._skip_subdirs['lib'] and self._info['lang'] == 'cpp') or
            (self._skip_subdirs['python'] and self._info['lang'] == 'python')):
            print "Missing or skipping relevant subdir."
            exit(1)

        if self._info['blockname'] is None:
            if len(self.args) >= 2:
                self._info['blockname'] = self.args[1]
            else:
                self._info['blockname'] = raw_input(
                    "Enter name of block/code (without module name prefix): ")
        if not re.match('[a-zA-Z0-9_]+', self._info['blockname']):
            print 'Invalid block name.'
            exit(2)
        print "Block/code identifier: " + self._info['blockname']
        self._info['fullblockname'] = self._info['modname'] + '_' + self._info[
            'blockname']
        self._info['license'] = self.setup_choose_license()

        if options.argument_list is not None:
            self._info['arglist'] = options.argument_list
        else:
            self._info['arglist'] = raw_input(
                'Enter valid argument list, including default arguments: ')

        if not (self._info['blocktype'] in ('noblock')
                or self._skip_subdirs['python']):
            self._add_py_qa = options.add_python_qa
            if self._add_py_qa is None:
                self._add_py_qa = ask_yes_no('Add Python QA code?', True)
        if self._info['lang'] == 'cpp':
            self._add_cc_qa = options.add_cpp_qa
            if self._add_cc_qa is None:
                self._add_cc_qa = ask_yes_no('Add C++ QA code?',
                                             not self._add_py_qa)
        if self._info[
                'version'] == 'autofoo' and not self.options.skip_cmakefiles:
            print "Warning: Autotools modules are not supported. ",
            print "Files will be created, but Makefiles will not be edited."
            self.options.skip_cmakefiles = True
Exemple #3
0
    def setup(self, options, args):
        ModTool.setup(self, options, args)
        self._info['blocktype'] = 'rfnoc'
        self._info['lang'] = 'cpp'
        if (self._skip_subdirs['lib']) or (self._skip_subdirs['python']):
            raise ModToolException('Missing or skipping relevant subdir.')
        if self._info['blockname'] is None:
            if len(args) >= 2:
                self._info['blockname'] = args[1]
            else:
                self._info['blockname'] = raw_input("Enter name of block/code (without module name prefix): ")
        if not re.match('^([a-zA-Z]+[0-9a-zA-Z]*)$', self._info['blockname']):
            raise ModToolException('Invalid block name.')
        print("Block/code identifier: " + self._info['blockname'])
        self._info['fullblockname'] = self._info['modname'] + '_' + self._info['blockname']
        if not options.license_file:
            self._info['copyrightholder'] = options.copyright
            if self._info['copyrightholder'] is None:
                self._info['copyrightholder'] = '<+YOU OR YOUR COMPANY+>'
            elif self._info['is_component']:
                print("For GNU Radio components the FSF is added as copyright holder")
        self._license_file = options.license_file
        self._info['license'] = self.setup_choose_license()
        if options.argument_list is not None:
            self._info['arglist'] = options.argument_list
        else:
            self._info['arglist'] = raw_input('Enter valid argument list, including default arguments: ')

        if not (self._info['blocktype'] in ('noblock') or self._skip_subdirs['python']):
            self._add_py_qa = options.add_python_qa
            if self._add_py_qa is None:
                self._add_py_qa = ask_yes_no('Add Python QA code?', True)
        self._add_cc_qa = options.add_cpp_qa
        if self._add_cc_qa is None:
            self._add_cc_qa = ask_yes_no('Add C++ QA code?', not self._add_py_qa)
        self._skip_cmakefiles = options.skip_cmakefiles
        if self._info['version'] == 'autofoo' and not self._skip_cmakefiles:
            print("Warning: Autotools modules are not supported. ",)
            print("Files will be created, but Makefiles will not be edited.")
            self._skip_cmakefiles = True
        #NOC ID parse
        self._info['noc_id'] = options.noc_id
        if self._info['noc_id'] is None:
            self._info['noc_id'] = id_process(raw_input("Block NoC ID (Hexadecimal): "))
        if not re.match(r'\A[0-9A-F]+\Z', self._info['noc_id']):
            raise ModToolException('Invalid NoC ID - Only Hexadecimal Values accepted.')
        self._skip_block_ctrl = options.skip_block_ctrl
        if self._skip_block_ctrl is None:
            self._skip_block_ctrl = ask_yes_no('Skip Block Controllers Generation? [UHD block ctrl files]', False)
        self._skip_block_interface = options.skip_block_interface
        if self._skip_block_interface is None:
            self._skip_block_interface = ask_yes_no('Skip Block interface files Generation? [GRC block ctrl files]', False)
Exemple #4
0
    def setup(self):
        ModTool.setup(self)
        options = self.options
        self._info['blocktype'] = options.block_type
        if self._info['blocktype'] is None:
            while self._info['blocktype'] not in self._block_types:
                self._info['blocktype'] = raw_input("Enter code type: ")
                if self._info['blocktype'] not in self._block_types:
                    print 'Must be one of ' + str(self._block_types)
        self._info['lang'] = options.lang
        if self._info['lang'] == 'c++':
            self._info['lang'] = 'cpp'
        print "Language: %s" % {'cpp': 'C++', 'python': 'Python'}[self._info['lang']]

        if ((self._skip_subdirs['lib'] and self._info['lang'] == 'cpp')
             or (self._skip_subdirs['python'] and self._info['lang'] == 'python')):
            print "Missing or skipping relevant subdir."
            exit(1)

        if self._info['blockname'] is None:
            if len(self.args) >= 2:
                self._info['blockname'] = self.args[1]
            else:
                self._info['blockname'] = raw_input("Enter name of block/code (without module name prefix): ")
        if not re.match('[a-zA-Z0-9_]+', self._info['blockname']):
            print 'Invalid block name.'
            exit(2)
        print "Block/code identifier: " + self._info['blockname']
        self._info['fullblockname'] = self._info['modname'] + '_' + self._info['blockname']
        self._info['license'] = self.setup_choose_license()

        if options.argument_list is not None:
            self._info['arglist'] = options.argument_list
        else:
            self._info['arglist'] = raw_input('Enter valid argument list, including default arguments: ')

        if not (self._info['blocktype'] in ('noblock') or self._skip_subdirs['python']):
            self._add_py_qa = options.add_python_qa
            if self._add_py_qa is None:
                self._add_py_qa = ask_yes_no('Add Python QA code?', True)
        if self._info['lang'] == 'cpp':
            self._add_cc_qa = options.add_cpp_qa
            if self._add_cc_qa is None:
                self._add_cc_qa = ask_yes_no('Add C++ QA code?', not self._add_py_qa)
        if self._info['version'] == 'autofoo' and not self.options.skip_cmakefiles:
            print "Warning: Autotools modules are not supported. ",
            print "Files will be created, but Makefiles will not be edited."
            self.options.skip_cmakefiles = True
Exemple #5
0
 def _make_grc_xml_from_block_data(self, params, iosig, blockname):
     """ Take the return values from the parser and call the XML
     generator. Also, check the makefile if the .xml file is in there.
     If necessary, add. """
     fname_xml = '%s_%s.xml' % (self._info['modname'], blockname)
     # Some adaptions for the GRC
     for inout in ('in', 'out'):
         if iosig[inout]['max_ports'] == '-1':
             iosig[inout]['max_ports'] = '$num_%sputs' % inout
             params.append({'key': 'num_%sputs' % inout,
                            'type': 'int',
                            'name': 'Num %sputs' % inout,
                            'default': '2',
                            'in_constructor': False})
     if os.path.isfile(os.path.join('grc', fname_xml)):
         if not self._info['yes']:
             if not ask_yes_no('Overwrite existing GRC file?', False):
                 return
         else:
             print "Warning: Overwriting existing GRC file."
     grc_generator = GRCXMLGenerator(
             modname=self._info['modname'],
             blockname=blockname,
             params=params,
             iosig=iosig
     )
     grc_generator.save(os.path.join('grc', fname_xml))
     if not self._skip_subdirs['grc']:
         ed = CMakeFileEditor(self._file['cmgrc'])
         if re.search(fname_xml, ed.cfile) is None and not ed.check_for_glob('*.xml'):
             print "Adding GRC bindings to grc/CMakeLists.txt..."
             ed.append_value('install', fname_xml, to_ignore_end='DESTINATION[^()]+')
             ed.write()
Exemple #6
0
 def _make_grc_xml_from_block_data(self, params, iosig, blockname):
     """ Take the return values from the parser and call the XML
     generator. Also, check the makefile if the .xml file is in there.
     If necessary, add. """
     fname_xml = '%s_%s.xml' % (self._info['modname'], blockname)
     path_to_xml = os.path.join('grc', fname_xml)
     # Some adaptions for the GRC
     for inout in ('in', 'out'):
         if iosig[inout]['max_ports'] == '-1':
             iosig[inout]['max_ports'] = '$num_%sputs' % inout
             params.append({
                 'key': 'num_%sputs' % inout,
                 'type': 'int',
                 'name': 'Num %sputs' % inout,
                 'default': '2',
                 'in_constructor': False
             })
     file_exists = False
     if os.path.isfile(path_to_xml):
         if not self._info['yes']:
             if not ask_yes_no('Overwrite existing GRC file?', False):
                 return
         else:
             file_exists = True
             print "Warning: Overwriting existing GRC file."
     grc_generator = GRCXMLGenerator(modname=self._info['modname'],
                                     blockname=blockname,
                                     params=params,
                                     iosig=iosig)
     grc_generator.save(path_to_xml)
     if file_exists:
         self.scm.mark_files_updated((path_to_xml, ))
     else:
         self.scm.add_files((path_to_xml, ))
     if not self._skip_subdirs['grc']:
         ed = CMakeFileEditor(self._file['cmgrc'])
         if re.search(fname_xml,
                      ed.cfile) is None and not ed.check_for_glob('*.xml'):
             print "Adding GRC bindings to grc/CMakeLists.txt..."
             ed.append_value('install',
                             fname_xml,
                             to_ignore_end='DESTINATION[^()]+')
             ed.write()
             self.scm.mark_files_updated(self._file['cmgrc'])
Exemple #7
0
    def setup(self, options, args):
        ModTool.setup(self, options, args)

        self._info['blocktype'] = options.block_type
        if self._info['blocktype'] is None:
            # Print list out of blocktypes to user for reference
            print str(self._block_types)
            while self._info['blocktype'] not in self._block_types:
                self._info['blocktype'] = raw_input("Enter block type: ")
                if self._info['blocktype'] not in self._block_types:
                    print 'Must be one of ' + str(self._block_types)
        # Allow user to specify language interactively if not set
        self._info['lang'] = options.lang
        if self._info['lang'] is None:
            while self._info['lang'] not in ['cpp', 'python']:
                self._info['lang'] = raw_input("Language (python/cpp): ")

                if self._info['lang'] == 'c++':
                    self._info['lang'] = 'cpp'

        print "Language: %s" % {'cpp': 'C++', 'python': 'Python'}[self._info['lang']]

        if ((self._skip_subdirs['lib'] and self._info['lang'] == 'cpp')
             or (self._skip_subdirs['python'] and self._info['lang'] == 'python')):
            raise ModToolException('Missing or skipping relevant subdir.')

        if self._info['blockname'] is None:
            if len(args) >= 2:
                self._info['blockname'] = args[1]
            else:
                self._info['blockname'] = raw_input("Enter name of block/code (without module name prefix): ")
        if not re.match('[a-zA-Z0-9_]+', self._info['blockname']):
            raise ModToolException('Invalid block name.')
        print "Block/code identifier: " + self._info['blockname']
        self._info['fullblockname'] = self._info['modname'] + '_' + self._info['blockname']
        if not options.license_file:
            self._info['copyrightholder'] = options.copyright
            if self._info['copyrightholder'] is None:
                self._info['copyrightholder'] = '<+YOU OR YOUR COMPANY+>'
            elif self._info['is_component']:
                print "For GNU Radio components the FSF is added as copyright holder"
        self._license_file = options.license_file
        self._info['license'] = self.setup_choose_license()
        if options.argument_list is not None:
            self._info['arglist'] = options.argument_list
        else:
            self._info['arglist'] = raw_input('Enter valid argument list, including default arguments: ')

        if not (self._info['blocktype'] in ('noblock') or self._skip_subdirs['python']):
            self._add_py_qa = options.add_python_qa
            if self._add_py_qa is None:
                self._add_py_qa = ask_yes_no('Add Python QA code?', True)
        if self._info['lang'] == 'cpp':
            self._add_cc_qa = options.add_cpp_qa
            if self._add_cc_qa is None:
                self._add_cc_qa = ask_yes_no('Add C++ QA code?', not self._add_py_qa)
        self._skip_cmakefiles = options.skip_cmakefiles
        if self._info['version'] == 'autofoo' and not self._skip_cmakefiles:
            print "Warning: Autotools modules are not supported. ",
            print "Files will be created, but Makefiles will not be edited."
            self._skip_cmakefiles = True
Exemple #8
0
    def setup(self, options, args):
        ModTool.setup(self, options, args)

        if self._info['blockname'] is None:
            if len(args) >= 2:
                self._info['blockname'] = args[1]
            else:
                self._info['blockname'] = raw_input(
                    "Enter name of block/code (without module name prefix): ")
        if os.path.isfile("./lib/" + self._info['blockname'] +
                          "_impl.cc") or os.path.isfile(
                              "./python/" + self._info['blockname'] + ".py"):
            raise ModToolException('The given blockname already exists!')
        if not re.match('[a-zA-Z0-9_]+', self._info['blockname']):
            raise ModToolException('Invalid block name.')
        print "Block/code identifier: " + self._info['blockname']
        self._info['fullblockname'] = self._info['modname'] + '_' + self._info[
            'blockname']

        self._info['blocktype'] = options.block_type
        if self._info['blocktype'] is None:
            # Print list out of blocktypes to user for reference
            print str(self._block_types)
            with SequenceCompleter(sorted(self._block_types)):
                while self._info['blocktype'] not in self._block_types:
                    self._info['blocktype'] = raw_input("Enter block type: ")
                    if self._info['blocktype'] not in self._block_types:
                        print 'Must be one of ' + str(self._block_types)

        # Allow user to specify language interactively if not set
        self._info['lang'] = options.lang
        if self._info['lang'] is None:
            language_candidates = ('cpp', 'python')
            with SequenceCompleter(language_candidates):
                while self._info['lang'] not in language_candidates:
                    self._info['lang'] = raw_input("Language (python/cpp): ")
        if self._info['lang'] == 'c++':
            self._info['lang'] = 'cpp'

        print "Language: %s" % {
            'cpp': 'C++',
            'python': 'Python'
        }[self._info['lang']]

        if ((self._skip_subdirs['lib'] and self._info['lang'] == 'cpp') or
            (self._skip_subdirs['python'] and self._info['lang'] == 'python')):
            raise ModToolException('Missing or skipping relevant subdir.')

        if not options.license_file:
            self._info['copyrightholder'] = options.copyright
            if self._info['copyrightholder'] is None:
                user = getpass.getuser()
                git_user = self.scm.get_gituser()
                if git_user:
                    copyright_candidates = (user, git_user, 'GNU Radio')
                else:
                    copyright_candidates = (user, 'GNU Radio')
                with SequenceCompleter(copyright_candidates):
                    self._info['copyrightholder'] = raw_input(
                        "Please specify the copyright holder: ")
                    if not self._info['copyrightholder'] or self._info[
                            'copyrightholder'].isspace():
                        self._info['copyrightholder'] = "gr-" + self._info[
                            'modname'] + " author"
            elif self._info['is_component']:
                print "For GNU Radio components the FSF is added as copyright holder"
        self._license_file = options.license_file
        self._info['license'] = self.setup_choose_license()
        if options.argument_list is not None:
            self._info['arglist'] = options.argument_list
        else:
            self._info['arglist'] = raw_input(
                'Enter valid argument list, including default arguments: ')

        if not (self._info['blocktype'] in ('noblock')
                or self._skip_subdirs['python']):
            self._add_py_qa = options.add_python_qa
            if self._add_py_qa is None:
                self._add_py_qa = ask_yes_no('Add Python QA code?', True)
        if self._info['lang'] == 'cpp':
            self._add_cc_qa = options.add_cpp_qa
            if self._add_cc_qa is None:
                self._add_cc_qa = ask_yes_no('Add C++ QA code?',
                                             not self._add_py_qa)
        self._skip_cmakefiles = options.skip_cmakefiles
        if self._info['version'] == 'autofoo' and not self._skip_cmakefiles:
            print "Warning: Autotools modules are not supported. ",
            print "Files will be created, but Makefiles will not be edited."
            self._skip_cmakefiles = True
Exemple #9
0
    def setup(self, options, args):
        ModTool.setup(self, options, args)

        if self._info['blockname'] is None:
            if len(args) >= 2:
                self._info['blockname'] = args[1]
            else:
                self._info['blockname'] = raw_input("Enter name of block/code (without module name prefix): ")
        if os.path.isfile("./lib/"+self._info['blockname']+"_impl.cc") or os.path.isfile("./python/"+self._info['blockname']+".py"):
            raise ModToolException('The given blockname already exists!')
        if not re.match('[a-zA-Z0-9_]+', self._info['blockname']):
            raise ModToolException('Invalid block name.')
        print "Block/code identifier: " + self._info['blockname']
        self._info['fullblockname'] = self._info['modname'] + '_' + self._info['blockname']

        self._info['blocktype'] = options.block_type
        if self._info['blocktype'] is None:
            # Print list out of blocktypes to user for reference
            print str(self._block_types)
            with SequenceCompleter(sorted(self._block_types)):
                while self._info['blocktype'] not in self._block_types:
                    self._info['blocktype'] = raw_input("Enter block type: ")
                    if self._info['blocktype'] not in self._block_types:
                        print 'Must be one of ' + str(self._block_types)

        # Allow user to specify language interactively if not set
        self._info['lang'] = options.lang
        if self._info['lang'] is None:
            language_candidates = ('cpp', 'python')
            with SequenceCompleter(language_candidates):
                while self._info['lang'] not in language_candidates:
                    self._info['lang'] = raw_input("Language (python/cpp): ")
        if self._info['lang'] == 'c++':
            self._info['lang'] = 'cpp'

        print "Language: %s" % {'cpp': 'C++', 'python': 'Python'}[self._info['lang']]

        if ((self._skip_subdirs['lib'] and self._info['lang'] == 'cpp')
                or (self._skip_subdirs['python'] and self._info['lang'] == 'python')):
            raise ModToolException('Missing or skipping relevant subdir.')

        if not options.license_file:
            self._info['copyrightholder'] = options.copyright
            if self._info['copyrightholder'] is None:
                user = getpass.getuser()
                git_user = self.scm.get_gituser()
                if git_user:
                    copyright_candidates = (user, git_user, 'GNU Radio')
                else:
                    copyright_candidates = (user, 'GNU Radio')
                with SequenceCompleter(copyright_candidates):
                    self._info['copyrightholder'] = raw_input("Please specify the copyright holder: ")
                    if not self._info['copyrightholder'] or self._info['copyrightholder'].isspace():
                        self._info['copyrightholder'] = "gr-"+self._info['modname']+" author"
            elif self._info['is_component']:
                print "For GNU Radio components the FSF is added as copyright holder"
        self._license_file = options.license_file
        self._info['license'] = self.setup_choose_license()
        if options.argument_list is not None:
            self._info['arglist'] = options.argument_list
        else:
            self._info['arglist'] = raw_input('Enter valid argument list, including default arguments: ')

        if not (self._info['blocktype'] in ('noblock') or self._skip_subdirs['python']):
            self._add_py_qa = options.add_python_qa
            if self._add_py_qa is None:
                self._add_py_qa = ask_yes_no('Add Python QA code?', True)
        if self._info['lang'] == 'cpp':
            self._add_cc_qa = options.add_cpp_qa
            if self._add_cc_qa is None:
                self._add_cc_qa = ask_yes_no('Add C++ QA code?', not self._add_py_qa)
        self._skip_cmakefiles = options.skip_cmakefiles
        if self._info['version'] == 'autofoo' and not self._skip_cmakefiles:
            print "Warning: Autotools modules are not supported. ",
            print "Files will be created, but Makefiles will not be edited."
            self._skip_cmakefiles = True