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 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