def run(self, command, variables=[], board=None, packages=[]): """Executes scons for building""" # -- Check for the SConstruct file if not isfile(util.safe_join(util.get_project_dir(), 'SConstruct')): variables += ['-f'] variables += [util.safe_join( util.get_folder('resources'), 'SConstruct')] else: click.secho('Info: use custom SConstruct file') # -- Resolve packages if self.profile.check_exe_default(): # Run on `default` config mode if not util.resolve_packages( packages, self.profile.packages, self.resources.distribution.get('packages') ): # Exit if a package is not installed raise Exception else: click.secho('Info: native config mode') # -- Execute scons return self._execute_scons(command, variables, board)
def run(self, command, variables=[], board=None, packages=[]): """Executes scons for building""" # -- Check for the SConstruct file if not isfile(util.safe_join(util.get_project_dir(), 'SConstruct')): variables += ['-f'] variables += [ util.safe_join(util.get_folder('resources'), 'SConstruct') ] else: click.secho('Info: use custom SConstruct file') # -- Resolve packages if self.profile.check_exe_default(): # Run on `default` config mode if not util.resolve_packages( packages, self.profile.packages, self.resources.distribution.get('packages')): # Exit if a package is not installed raise Exception else: click.secho('Info: native config mode') # -- Execute scons return self._execute_scons(command, variables, board)
def copy_example_files(self, example, project_dir, sayno): if isdir(self.examples_dir): if project_dir is not None: example_path = project_dir else: example_path = util.get_project_dir() local_example_path = join(self.examples_dir, example) if isdir(local_example_path): self._copy_files(example, local_example_path, example_path, sayno) else: click.secho(EXAMPLE_NOT_FOUND_MSG, fg='yellow') else: click.secho('Error: examples are not installed', fg='red') click.secho('Please run:\n' ' apio install examples', fg='yellow') return 1 return 0
def copy_example_dir(self, example, project_dir, sayno): if isdir(self.examples_dir): # -- Target dir not specified if project_dir is not None: example_path = join(project_dir, example) else: # -- Not specified: use the current working dir example_path = join(util.get_project_dir(), example) # -- Get the local example path local_example_path = join(self.examples_dir, example) if isdir(local_example_path): if isdir(example_path): # -- If sayno, do not copy anything if not sayno: click.secho('Warning: ' + example + ' directory already exists', fg='yellow') if click.confirm('Do you want to replace it?'): shutil.rmtree(example_path) self._copy_dir(example, local_example_path, example_path) elif isfile(example_path): click.secho('Warning: ' + example + ' is already a file', fg='yellow') else: self._copy_dir(example, local_example_path, example_path) else: click.secho(EXAMPLE_NOT_FOUND_MSG, fg='yellow') else: click.secho('Error: examples are not installed', fg='red') click.secho('Please run:\n' ' apio install examples', fg='yellow') return 1 return 0
def copy_example_dir(self, example, project_dir, sayno): if isdir(self.examples_dir): # -- Target dir not specified if project_dir is not None: example_path = join(project_dir, example) else: # -- Not specified: use the current working dir example_path = join(util.get_project_dir(), example) # -- Get the local example path local_example_path = join(self.examples_dir, example) if isdir(local_example_path): if isdir(example_path): # -- If sayno, do not copy anything if not sayno: click.secho( 'Warning: ' + example + ' directory already exists', fg='yellow') if click.confirm('Do you want to replace it?'): shutil.rmtree(example_path) self._copy_dir(example, local_example_path, example_path) elif isfile(example_path): click.secho( 'Warning: ' + example + ' is already a file', fg='yellow') else: self._copy_dir(example, local_example_path, example_path) else: click.secho(EXAMPLE_NOT_FOUND_MSG, fg='yellow') else: click.secho('Error: examples are not installed', fg='red') click.secho('Please run:\n' ' apio install examples', fg='yellow') return 1 return 0
def run(self, command, variables=[], board=None): """Executes scons for building""" packages_dir = os.path.join(util.get_home_dir(), 'packages') icestorm_dir = os.path.join(packages_dir, 'toolchain-icestorm', 'bin') iverilog_dir = os.path.join(packages_dir, 'toolchain-iverilog', 'bin') scons_dir = os.path.join(packages_dir, 'tool-scons', 'script') sconstruct_name = 'SConstruct' # Give the priority to the packages installed by apio os.environ['PATH'] = os.pathsep.join( [iverilog_dir, icestorm_dir, os.environ['PATH']]) # Add environment variables os.environ['IVL'] = os.path.join(packages_dir, 'toolchain-iverilog', 'lib', 'ivl') os.environ['VLIB'] = os.path.join(packages_dir, 'toolchain-iverilog', 'vlib', 'system.v') # -- Check for the scons if not isdir(scons_dir): click.secho('Error: scons toolchain is not installed', fg='red') click.secho('Please run:\n' ' apio install scons', fg='yellow') # -- Check for the icestorm tools if not isdir(icestorm_dir): click.secho('Error: icestorm toolchain is not installed', fg='red') click.secho('Please run:\n' ' apio install icestorm', fg='yellow') # -- Check for the iverilog tools if not isdir(iverilog_dir): click.secho('Error: iverilog toolchain is not installed', fg='red') click.secho('Please run:\n' ' apio install iverilog', fg='yellow') # -- Check for the SConstruct file if not isfile(join(util.get_project_dir(), sconstruct_name)): click.secho('Using default SConstruct file') variables += [ '-f', join(dirname(__file__), '..', 'resources', sconstruct_name) ] # -- Execute scons if isdir(scons_dir) and isdir(icestorm_dir) and isdir(iverilog_dir): terminal_width, _ = click.get_terminal_size() start_time = time.time() if command == 'build' or \ command == 'upload' or \ command == 'time': if board: processing_board = board else: processing_board = 'custom board' click.echo( "[%s] Processing %s" % (datetime.datetime.now().strftime("%c"), click.style(processing_board, fg="cyan", bold=True))) click.secho("-" * terminal_width, bold=True) click.secho("Executing: scons -Q {0} {1}".format( command, ' '.join(variables))) result = util.exec_command([ os.path.normpath(sys.executable), os.path.join(scons_dir, 'scons'), '-Q', command ] + variables, stdout=util.AsyncPipe(self._on_run_out), stderr=util.AsyncPipe(self._on_run_err)) # -- Print result exit_code = result['returncode'] is_error = exit_code != 0 summary_text = " Took %.2f seconds " % (time.time() - start_time) half_line = "=" * int( ((terminal_width - len(summary_text) - 10) / 2)) click.echo( "%s [%s]%s%s" % (half_line, (click.style(" ERROR ", fg="red", bold=True) if is_error else click.style("SUCCESS", fg="green", bold=True)), summary_text, half_line), err=is_error) if False: if is_error: print(""" ______ _ | ____| | | | |__ _ __ _ __ ___ _ __| | | __| | '__| '__/ _ \| '__| | | |____| | | | | (_) | | |_| |______|_| |_| \___/|_| (_) """) else: print(""" _____ _ / ____| | | | (___ _ _ ___ ___ ___ ___ ___| | \___ \| | | |/ __/ __/ _ \/ __/ __| | ____) | |_| | (_| (_| __/\__ \__ \_| |_____/ \__,_|\___\___\___||___/___(_) """) return exit_code else: return 1
def run(self, command, variables=[], board=None, deps=[]): """Executes scons for building""" # -- Check for the SConstruct file if not isfile(join(util.get_project_dir(), 'SConstruct')): click.secho('Using default SConstruct file') variables += ['-f', join( dirname(__file__), '..', 'resources', 'SConstruct')] # -- Resolve packages if self.profile.check_exe_default(): # Run on `default` config mode if not util.resolve_packages(self.resources.packages, deps): # Exit if a package is not installed return 1 # -- Execute scons terminal_width, _ = click.get_terminal_size() start_time = time.time() if command == 'build' or \ command == 'upload' or \ command == 'time': if board: processing_board = board else: processing_board = 'custom board' click.echo('[%s] Processing %s' % ( datetime.datetime.now().strftime('%c'), click.style(processing_board, fg='cyan', bold=True))) click.secho('-' * terminal_width, bold=True) if self.profile.get_verbose_mode() > 0: click.secho('Executing: scons -Q {0} {1}'.format( command, ' '.join(variables))) result = util.exec_command( util.scons_command + ['-Q', command] + variables, stdout=util.AsyncPipe(self._on_run_out), stderr=util.AsyncPipe(self._on_run_err) ) # -- Print result exit_code = result['returncode'] is_error = exit_code != 0 summary_text = ' Took %.2f seconds ' % (time.time() - start_time) half_line = '=' * int( ((terminal_width - len(summary_text) - 10) / 2)) click.echo('%s [%s]%s%s' % ( half_line, (click.style(' ERROR ', fg='red', bold=True) if is_error else click.style('SUCCESS', fg='green', bold=True)), summary_text, half_line ), err=is_error) if False: if is_error: print(""" ______ _ | ____| | | | |__ _ __ _ __ ___ _ __| | | __| | '__| '__/ _ \| '__| | | |____| | | | | (_) | | |_| |______|_| |_| \___/|_| (_) """) else: print(""" _____ _ / ____| | | | (___ _ _ ___ ___ ___ ___ ___| | \___ \| | | |/ __/ __/ _ \/ __/ __| | ____) | |_| | (_| (_| __/\__ \__ \_| |_____/ \__,_|\___\___\___||___/___(_) """) return exit_code
def run(self, command, variables=[], board=None, deps=[]): """Executes scons for building""" # -- Check for the SConstruct file if not isfile(util.safe_join(util.get_project_dir(), 'SConstruct')): click.secho('Info: default SConstruct file') variables += ['-f'] variables += [ util.safe_join(util.get_folder('resources'), 'SConstruct') ] # -- Resolve packages if self.profile.check_exe_default(): # Run on `default` config mode if not util.resolve_packages(self.resources.packages, deps): # Exit if a package is not installed return 1 else: click.secho('Info: native config mode') # -- Execute scons terminal_width, _ = click.get_terminal_size() start_time = time.time() if command == 'build' or \ command == 'upload' or \ command == 'time': if board: processing_board = board else: processing_board = 'custom board' click.echo('[%s] Processing %s' % (datetime.datetime.now().strftime('%c'), click.style(processing_board, fg='cyan', bold=True))) click.secho('-' * terminal_width, bold=True) if self.profile.get_verbose_mode() > 0: click.secho('Executing: scons -Q {0} {1}'.format( command, ' '.join(variables))) result = util.exec_command(util.scons_command + ['-Q', command] + variables, stdout=util.AsyncPipe(self._on_run_out), stderr=util.AsyncPipe(self._on_run_err)) # -- Print result exit_code = result['returncode'] is_error = exit_code != 0 summary_text = ' Took %.2f seconds ' % (time.time() - start_time) half_line = '=' * int(((terminal_width - len(summary_text) - 10) / 2)) click.echo('%s [%s]%s%s' % (half_line, (click.style(' ERROR ', fg='red', bold=True) if is_error else click.style('SUCCESS', fg='green', bold=True)), summary_text, half_line), err=is_error) if False: if is_error: print(""" ______ _ | ____| | | | |__ _ __ _ __ ___ _ __| | | __| | '__| '__/ _ \| '__| | | |____| | | | | (_) | | |_| |______|_| |_| \___/|_| (_) """) else: print(""" _____ _ / ____| | | | (___ _ _ ___ ___ ___ ___ ___| | \___ \| | | |/ __/ __/ _ \/ __/ __| | ____) | |_| | (_| (_| __/\__ \__ \_| |_____/ \__,_|\___\___\___||___/___(_) """) return exit_code