def process_arguments(args, resources): # noqa # -- Check arguments var_board = args.get('board') var_fpga = args.get('fpga') var_size = args.get('size') var_type = args.get('type') var_pack = args.get('pack') var_verbose = args.get('verbose') if var_board: if isfile('apio.ini'): click.secho('Info: ignore apio.ini board', fg='yellow') if var_board in resources.boards: fpga = resources.boards.get(var_board).get('fpga') if fpga in resources.fpgas: fpga_size = resources.fpgas.get(fpga).get('size') fpga_type = resources.fpgas.get(fpga).get('type') fpga_pack = resources.fpgas.get(fpga).get('pack') redundant_arguments = [] contradictory_arguments = [] if var_fpga: if var_fpga in resources.fpgas: if var_fpga == fpga: # Redundant argument redundant_arguments += ['fpga'] else: # Contradictory argument contradictory_arguments += ['fpga'] else: # Unknown FPGA raise Exception('unknown FPGA: {0}'.format(var_fpga)) if var_size: if var_size == fpga_size: # Redundant argument redundant_arguments += ['size'] else: # Contradictory argument contradictory_arguments += ['size'] if var_type: if var_type == fpga_type: # Redundant argument redundant_arguments += ['type'] else: # Contradictory argument contradictory_arguments += ['type'] if var_pack: if var_pack == fpga_pack: # Redundant argument redundant_arguments += ['pack'] else: # Contradictory argument contradictory_arguments += ['pack'] if redundant_arguments: # Redundant argument click.secho('Warning: redundant arguments: {}'.format( ', '.join(redundant_arguments)), fg='yellow') if contradictory_arguments: # Contradictory argument raise Exception('contradictory arguments: {}'.format( ', '.join(contradictory_arguments))) else: # Unknown FPGA pass else: # Unknown board raise Exception('unknown board: {0}'.format(var_board)) else: if var_fpga: if isfile('apio.ini'): click.secho('Info: ignore apio.ini board', fg='yellow') if var_fpga in resources.fpgas: fpga_size = resources.fpgas.get(var_fpga).get('size') fpga_type = resources.fpgas.get(var_fpga).get('type') fpga_pack = resources.fpgas.get(var_fpga).get('pack') redundant_arguments = [] contradictory_arguments = [] if var_size: if var_size == fpga_size: # Redundant argument redundant_arguments += ['size'] else: # Contradictory argument contradictory_arguments += ['size'] if var_type: if var_type == fpga_type: # Redundant argument redundant_arguments += ['type'] else: # Contradictory argument contradictory_arguments += ['type'] if var_pack: if var_pack == fpga_pack: # Redundant argument redundant_arguments += ['pack'] else: # Contradictory argument contradictory_arguments += ['pack'] if redundant_arguments: # Redundant argument click.secho('Warning: redundant arguments: {}'.format( ', '.join(redundant_arguments)), fg='yellow') if contradictory_arguments: # Contradictory argument raise Exception('contradictory arguments: {}'.format( ', '.join(contradictory_arguments))) else: # Unknown FPGA raise Exception('unknown FPGA: {0}'.format(var_fpga)) else: if var_size and var_type and var_pack: if isfile('apio.ini'): click.secho('Info: ignore apio.ini board', fg='yellow') fpga_size = var_size fpga_type = var_type fpga_pack = var_pack else: if not var_size and not var_type and not var_pack: # No arguments: use apio.ini board p = Project() p.read() if p.board: var_board = p.board if var_board in resources.boards: fpga = resources.boards.get(var_board).get('fpga') fpga_size = resources.fpgas.get(fpga).get('size') fpga_type = resources.fpgas.get(fpga).get('type') fpga_pack = resources.fpgas.get(fpga).get('pack') else: # Unknown board raise Exception( 'unknown board: {0}'.format(var_board)) else: click.secho( 'Error: insufficient arguments: missing board', fg='red') click.secho('You have two options:\n' + ' 1) Execute your command with\n' + ' `--board <boardname>`\n' + ' 2) Create an ini file using\n' + ' `apio init --board <boardname>`', fg='yellow') raise Exception else: if isfile('apio.ini'): click.secho('Info: ignore apio.ini board', fg='yellow') # Insufficient arguments missing = [] if not var_size: missing += ['size'] if not var_type: missing += ['type'] if not var_pack: missing += ['pack'] raise Exception( 'insufficient arguments: missing {}'.format( ', '.join(missing))) # -- Build Scons variables list variables = format_vars({ 'fpga_size': fpga_size, 'fpga_type': fpga_type, 'fpga_pack': fpga_pack, 'verbose_all': var_verbose.get('all'), 'verbose_yosys': var_verbose.get('yosys'), 'verbose_arachne': var_verbose.get('arachne') }) return variables, var_board
def process_arguments(self, args): # -- Check arguments var_board = args['board'] var_fpga = args['fpga'] var_size = args['size'] var_type = args['type'] var_pack = args['pack'] # TODO: reduce code size if var_board: if isfile('apio.ini'): click.secho('Info: ignore apio.ini board', fg='yellow') if var_board in self.resources.boards: fpga = self.resources.boards[var_board]['fpga'] if fpga in self.resources.fpgas: fpga_size = self.resources.fpgas[fpga]['size'] fpga_type = self.resources.fpgas[fpga]['type'] fpga_pack = self.resources.fpgas[fpga]['pack'] redundant_arguments = [] contradictory_arguments = [] if var_fpga: if var_fpga in self.resources.fpgas: if var_fpga == fpga: # Redundant argument redundant_arguments += ['fpga'] else: # Contradictory argument contradictory_arguments += ['fpga'] else: # Unknown fpga click.secho( 'Error: unknown fpga: {0}'.format( var_fpga), fg='red') return 1 if var_size: if var_size == fpga_size: # Redundant argument redundant_arguments += ['size'] else: # Contradictory argument contradictory_arguments += ['size'] if var_type: if var_type == fpga_type: # Redundant argument redundant_arguments += ['type'] else: # Contradictory argument contradictory_arguments += ['type'] if var_pack: if var_pack == fpga_pack: # Redundant argument redundant_arguments += ['pack'] else: # Contradictory argument contradictory_arguments += ['pack'] if redundant_arguments: # Redundant argument click.secho( 'Warning: redundant arguments: {}'.format( ', '.join(redundant_arguments)), fg='yellow') if contradictory_arguments: # Contradictory argument click.secho( 'Error: contradictory arguments: {}'.format( ', '.join(contradictory_arguments)), fg='red') return 1 else: # Unknown fpga pass else: # Unknown board click.secho( 'Error: unknown board: {0}'.format(var_board), fg='red') return 1 else: if var_fpga: if isfile('apio.ini'): click.secho('Info: ignore apio.ini board', fg='yellow') if var_fpga in self.resources.fpgas: fpga_size = self.resources.fpgas[var_fpga]['size'] fpga_type = self.resources.fpgas[var_fpga]['type'] fpga_pack = self.resources.fpgas[var_fpga]['pack'] redundant_arguments = [] contradictory_arguments = [] if var_size: if var_size == fpga_size: # Redundant argument redundant_arguments += ['size'] else: # Contradictory argument contradictory_arguments += ['size'] if var_type: if var_type == fpga_type: # Redundant argument redundant_arguments += ['type'] else: # Contradictory argument contradictory_arguments += ['type'] if var_pack: if var_pack == fpga_pack: # Redundant argument redundant_arguments += ['pack'] else: # Contradictory argument contradictory_arguments += ['pack'] if redundant_arguments: # Redundant argument click.secho( 'Warning: redundant arguments: {}'.format( ', '.join(redundant_arguments)), fg='yellow') if contradictory_arguments: # Contradictory argument click.secho( 'Error: contradictory arguments: {}'.format( ', '.join(contradictory_arguments)), fg='red') return 1 else: # Unknown fpga click.secho( 'Error: unknown fpga: {0}'.format(var_fpga), fg='red') return 1 else: if var_size and var_type and var_pack: if isfile('apio.ini'): click.secho('Info: ignore apio.ini board', fg='yellow') fpga_size = var_size fpga_type = var_type fpga_pack = var_pack else: if not var_size and not var_type and not var_pack: # No arguments: use apio.ini board p = Project() p.read() if p.board: var_board = p.board click.secho( 'Info: use apio.ini board: {}'.format( var_board)) fpga = self.resources.boards[var_board]['fpga'] fpga_size = self.resources.fpgas[fpga]['size'] fpga_type = self.resources.fpgas[fpga]['type'] fpga_pack = self.resources.fpgas[fpga]['pack'] else: click.secho( 'Error: insufficient arguments: missing board', fg='red') click.secho( 'You have two options:\n' + ' 1) Execute your command with\n' + ' `--board <boardname>`\n' + ' 2) Create an ini file using\n' + ' `apio init --board <boardname>`', fg='yellow') return 1 else: if isfile('apio.ini'): click.secho('Info: ignore apio.ini board', fg='yellow') # Insufficient arguments missing = [] if not var_size: missing += ['size'] if not var_type: missing += ['type'] if not var_pack: missing += ['pack'] pass click.secho( 'Error: insufficient arguments: missing {}'.format( ', '.join(missing)), fg='red') return 1 # -- Build Scons variables list variables = self.format_vars({ 'fpga_size': fpga_size, 'fpga_type': fpga_type, 'fpga_pack': fpga_pack }) return variables, var_board
def process_arguments(self, args): # -- Check arguments var_board = args['board'] var_fpga = args['fpga'] var_size = args['size'] var_type = args['type'] var_pack = args['pack'] # TODO: reduce code size if var_board: if isfile('apio.ini'): click.secho('Info: ignore apio.ini board', fg='yellow') if var_board in self.resources.boards: fpga = self.resources.boards[var_board]['fpga'] if fpga in self.resources.fpgas: fpga_size = self.resources.fpgas[fpga]['size'] fpga_type = self.resources.fpgas[fpga]['type'] fpga_pack = self.resources.fpgas[fpga]['pack'] redundant_arguments = [] contradictory_arguments = [] if var_fpga: if var_fpga in self.resources.fpgas: if var_fpga == fpga: # Redundant argument redundant_arguments += ['fpga'] else: # Contradictory argument contradictory_arguments += ['fpga'] else: # Unknown fpga click.secho( 'Error: unknown fpga: {0}'.format(var_fpga), fg='red') return 1 if var_size: if var_size == fpga_size: # Redundant argument redundant_arguments += ['size'] else: # Contradictory argument contradictory_arguments += ['size'] if var_type: if var_type == fpga_type: # Redundant argument redundant_arguments += ['type'] else: # Contradictory argument contradictory_arguments += ['type'] if var_pack: if var_pack == fpga_pack: # Redundant argument redundant_arguments += ['pack'] else: # Contradictory argument contradictory_arguments += ['pack'] if redundant_arguments: # Redundant argument click.secho('Warning: redundant arguments: {}'.format( ', '.join(redundant_arguments)), fg='yellow') if contradictory_arguments: # Contradictory argument click.secho( 'Error: contradictory arguments: {}'.format( ', '.join(contradictory_arguments)), fg='red') return 1 else: # Unknown fpga pass else: # Unknown board click.secho('Error: unknown board: {0}'.format(var_board), fg='red') return 1 else: if var_fpga: if isfile('apio.ini'): click.secho('Info: ignore apio.ini board', fg='yellow') if var_fpga in self.resources.fpgas: fpga_size = self.resources.fpgas[var_fpga]['size'] fpga_type = self.resources.fpgas[var_fpga]['type'] fpga_pack = self.resources.fpgas[var_fpga]['pack'] redundant_arguments = [] contradictory_arguments = [] if var_size: if var_size == fpga_size: # Redundant argument redundant_arguments += ['size'] else: # Contradictory argument contradictory_arguments += ['size'] if var_type: if var_type == fpga_type: # Redundant argument redundant_arguments += ['type'] else: # Contradictory argument contradictory_arguments += ['type'] if var_pack: if var_pack == fpga_pack: # Redundant argument redundant_arguments += ['pack'] else: # Contradictory argument contradictory_arguments += ['pack'] if redundant_arguments: # Redundant argument click.secho('Warning: redundant arguments: {}'.format( ', '.join(redundant_arguments)), fg='yellow') if contradictory_arguments: # Contradictory argument click.secho( 'Error: contradictory arguments: {}'.format( ', '.join(contradictory_arguments)), fg='red') return 1 else: # Unknown fpga click.secho('Error: unknown fpga: {0}'.format(var_fpga), fg='red') return 1 else: if var_size and var_type and var_pack: if isfile('apio.ini'): click.secho('Info: ignore apio.ini board', fg='yellow') fpga_size = var_size fpga_type = var_type fpga_pack = var_pack else: if not var_size and not var_type and not var_pack: # No arguments: use apio.ini board p = Project() p.read() if p.board: var_board = p.board click.secho('Info: use apio.ini board: {}'.format( var_board)) fpga = self.resources.boards[var_board]['fpga'] fpga_size = self.resources.fpgas[fpga]['size'] fpga_type = self.resources.fpgas[fpga]['type'] fpga_pack = self.resources.fpgas[fpga]['pack'] else: click.secho( 'Error: insufficient arguments: missing board', fg='red') click.secho( 'You have two options:\n' + ' 1) Execute your command with\n' + ' `--board <boardname>`\n' + ' 2) Create an ini file using\n' + ' `apio init --board <boardname>`', fg='yellow') return 1 else: if isfile('apio.ini'): click.secho('Info: ignore apio.ini board', fg='yellow') # Insufficient arguments missing = [] if not var_size: missing += ['size'] if not var_type: missing += ['type'] if not var_pack: missing += ['pack'] pass click.secho( 'Error: insufficient arguments: missing {}'.format( ', '.join(missing)), fg='red') return 1 # -- Build Scons variables list variables = self.format_vars({ "fpga_size": fpga_size, "fpga_type": fpga_type, "fpga_pack": fpga_pack }) return variables, var_board
def process_arguments(args, resources): # noqa # -- Check arguments var_board = args.get('board') var_fpga = args.get('fpga') var_size = args.get('size') var_type = args.get('type') var_pack = args.get('pack') var_verbose = args.get('verbose') if var_board: if isfile('apio.ini'): click.secho('Info: ignore apio.ini board', fg='yellow') if var_board in resources.boards: fpga = resources.boards.get(var_board).get('fpga') if fpga in resources.fpgas: fpga_size = resources.fpgas.get(fpga).get('size') fpga_type = resources.fpgas.get(fpga).get('type') fpga_pack = resources.fpgas.get(fpga).get('pack') redundant_arguments = [] contradictory_arguments = [] if var_fpga: if var_fpga in resources.fpgas: if var_fpga == fpga: # Redundant argument redundant_arguments += ['fpga'] else: # Contradictory argument contradictory_arguments += ['fpga'] else: # Unknown FPGA raise Exception('unknown FPGA: {0}'.format(var_fpga)) if var_size: if var_size == fpga_size: # Redundant argument redundant_arguments += ['size'] else: # Contradictory argument contradictory_arguments += ['size'] if var_type: if var_type == fpga_type: # Redundant argument redundant_arguments += ['type'] else: # Contradictory argument contradictory_arguments += ['type'] if var_pack: if var_pack == fpga_pack: # Redundant argument redundant_arguments += ['pack'] else: # Contradictory argument contradictory_arguments += ['pack'] if redundant_arguments: # Redundant argument click.secho( 'Warning: redundant arguments: {}'.format( ', '.join(redundant_arguments)), fg='yellow') if contradictory_arguments: # Contradictory argument raise Exception('contradictory arguments: {}'.format( ', '.join(contradictory_arguments))) else: # Unknown FPGA pass else: # Unknown board raise Exception('unknown board: {0}'.format(var_board)) else: if var_fpga: if isfile('apio.ini'): click.secho('Info: ignore apio.ini board', fg='yellow') if var_fpga in resources.fpgas: fpga_size = resources.fpgas.get(var_fpga).get('size') fpga_type = resources.fpgas.get(var_fpga).get('type') fpga_pack = resources.fpgas.get(var_fpga).get('pack') redundant_arguments = [] contradictory_arguments = [] if var_size: if var_size == fpga_size: # Redundant argument redundant_arguments += ['size'] else: # Contradictory argument contradictory_arguments += ['size'] if var_type: if var_type == fpga_type: # Redundant argument redundant_arguments += ['type'] else: # Contradictory argument contradictory_arguments += ['type'] if var_pack: if var_pack == fpga_pack: # Redundant argument redundant_arguments += ['pack'] else: # Contradictory argument contradictory_arguments += ['pack'] if redundant_arguments: # Redundant argument click.secho( 'Warning: redundant arguments: {}'.format( ', '.join(redundant_arguments)), fg='yellow') if contradictory_arguments: # Contradictory argument raise Exception('contradictory arguments: {}'.format( ', '.join(contradictory_arguments))) else: # Unknown FPGA raise Exception('unknown FPGA: {0}'.format(var_fpga)) else: if var_size and var_type and var_pack: if isfile('apio.ini'): click.secho('Info: ignore apio.ini board', fg='yellow') fpga_size = var_size fpga_type = var_type fpga_pack = var_pack else: if not var_size and not var_type and not var_pack: # No arguments: use apio.ini board p = Project() p.read() if p.board: var_board = p.board if var_board in resources.boards: fpga = resources.boards.get(var_board).get('fpga') fpga_size = resources.fpgas.get(fpga).get('size') fpga_type = resources.fpgas.get(fpga).get('type') fpga_pack = resources.fpgas.get(fpga).get('pack') else: # Unknown board raise Exception('unknown board: {0}'.format( var_board)) else: click.secho( 'Error: insufficient arguments: missing board', fg='red') click.secho( 'You have two options:\n' + ' 1) Execute your command with\n' + ' `--board <boardname>`\n' + ' 2) Create an ini file using\n' + ' `apio init --board <boardname>`', fg='yellow') raise Exception else: if isfile('apio.ini'): click.secho('Info: ignore apio.ini board', fg='yellow') # Insufficient arguments missing = [] if not var_size: missing += ['size'] if not var_type: missing += ['type'] if not var_pack: missing += ['pack'] raise Exception( 'insufficient arguments: missing {}'.format( ', '.join(missing))) # -- Build Scons variables list variables = format_vars({ 'fpga_size': fpga_size, 'fpga_type': fpga_type, 'fpga_pack': fpga_pack, 'verbose_all': var_verbose.get('all'), 'verbose_yosys': var_verbose.get('yosys'), 'verbose_arachne': var_verbose.get('arachne') }) return variables, var_board