示例#1
0
    def run(self):
        """ Go, go, go! """
        # This portion will be covered by the CLI
        if not self.cli:
            self.validate()
        if not have_bindtool:
            logger.error(
                "Bindtool required to generate bindings  ... Aborting")
            return

        with warnings.catch_warnings():
            warnings.filterwarnings("ignore", category=DeprecationWarning)
            blocknames_to_process = []
            if self.info['blockname']:
                # A complete block name was given
                blocknames_to_process.append(self.info['blockname'])
            elif self.info['pattern']:
                # A regex resembling one or several blocks were given
                blocknames_to_process = get_block_names(
                    self.info['pattern'], self.info['modname'])
            else:
                raise ModToolException("No block name or regex was specified!")
            bg = BindingGenerator(prefix=gr.prefix(),
                                  namespace=['gr', self.info['modname']],
                                  prefix_include_root=self.info['modname'],
                                  output_dir=os.path.join(self.dir, 'python'),
                                  define_symbols=self.info['define_symbols'],
                                  addl_includes=self.info['addl_includes'])
            files_to_process = [
                os.path.join(self.dir, self.info['includedir'],
                             f'{blockname}.h')
                for blockname in blocknames_to_process
            ]
            for file_to_process in files_to_process:
                bg.gen_file_binding(file_to_process)
示例#2
0
    def run(self):
        """ Go, go, go! """
        # This portion will be covered by the CLI
        if not self.cli:
            self.validate()
        if not have_bindtool:
            logger.error(
                "Bindtool required to generate bindings  ... Aborting")
            return

        with warnings.catch_warnings():
            warnings.filterwarnings("ignore", category=DeprecationWarning)
            file_to_process = os.path.join(self.dir, self.info['includedir'],
                                           self.info['blockname'] + '.h')
            bg = BindingGenerator(prefix=gr.prefix(),
                                  namespace=['gr', self.info['modname']],
                                  prefix_include_root=self.info['modname'],
                                  output_dir=os.path.join(self.dir, 'python'))
            bg.gen_file_binding(file_to_process)
parser.add_argument('--flag_pygccxml', default='0')

args = parser.parse_args()

prefix = args.prefix
output_dir = args.output_dir
defines = tuple(','.join(args.defines).split(','))
includes = ','.join(args.include)
name = args.module

namespace = ['gr', name]
prefix_include_root = name

with warnings.catch_warnings():
    warnings.filterwarnings("ignore", category=DeprecationWarning)

    bg = BindingGenerator(prefix,
                          namespace,
                          prefix_include_root,
                          output_dir,
                          define_symbols=defines,
                          addl_includes=includes,
                          catch_exceptions=False,
                          write_json_output=False,
                          status_output=args.status,
                          flag_automatic=True if args.flag_automatic.lower()
                          in ['1', 'true'] else False,
                          flag_pygccxml=True if args.flag_pygccxml.lower()
                          in ['1', 'true'] else False)
    bg.gen_file_binding(args.filename)