Lines Matching refs:self

114     def __init__(self, config_filename, target):  argument
115 self.target = target
116 self.config = {}
118 self.config[fname] = {}
120 def Add(self, fname, key, value): argument
121 self.config[fname][key] = value
123 def __hash__(self): argument
125 for fname in self.config:
126 for key, value in self.config[fname].iteritems():
204 def __init__(self, rc, err_lines, sizes, func_sizes, config): argument
205 self.rc = rc
206 self.err_lines = err_lines
207 self.sizes = sizes
208 self.func_sizes = func_sizes
209 self.config = config
211 def __init__(self, toolchains, base_dir, git_dir, num_threads, num_jobs, argument
241 self.toolchains = toolchains
242 self.base_dir = base_dir
243 self._working_dir = os.path.join(base_dir, '.bm-work')
244 self.threads = []
245 self.do_make = self.Make
246 self.gnu_make = gnu_make
247 self.checkout = checkout
248 self.num_threads = num_threads
249 self.num_jobs = num_jobs
250 self.already_done = 0
251 self.force_build = False
252 self.git_dir = git_dir
253 self._show_unknown = show_unknown
254 self._timestamp_count = 10
255 self._build_period_us = None
256 self._complete_delay = None
257 self._next_delay_update = datetime.now()
258 self.force_config_on_failure = True
259 self.force_build_failures = False
260 self.force_reconfig = False
261 self._step = step
262 self.in_tree = False
263 self._error_lines = 0
264 self.no_subdirs = no_subdirs
265 self.full_path = full_path
266 self.verbose_build = verbose_build
267 self.config_only = config_only
268 self.squash_config_y = squash_config_y
269 self.config_filenames = BASE_CONFIG_FILENAMES
270 if not self.squash_config_y:
271 self.config_filenames += EXTRA_CONFIG_FILENAMES
273 self.col = terminal.Color()
275 self._re_function = re.compile('(.*): In function.*')
276 self._re_files = re.compile('In file included from.*')
277 self._re_warning = re.compile('(.*):(\d*):(\d*): warning: .*')
278 self._re_note = re.compile('(.*):(\d*):(\d*): note: this is the location of the previous.*')
280 self.queue = Queue.Queue()
281 self.out_queue = Queue.Queue()
282 for i in range(self.num_threads):
283 t = builderthread.BuilderThread(self, i, incremental,
287 self.threads.append(t)
289 self.last_line_len = 0
290 t = builderthread.ResultThread(self)
293 self.threads.append(t)
296 self.re_make_err = re.compile('|'.join(ignore_lines))
299 signal.signal(signal.SIGINT, self.signal_handler)
301 def __del__(self): argument
303 for t in self.threads:
306 def signal_handler(self, signal, frame): argument
309 def SetDisplayOptions(self, show_errors=False, show_sizes=False, argument
321 self._show_errors = show_errors
322 self._show_sizes = show_sizes
323 self._show_detail = show_detail
324 self._show_bloat = show_bloat
325 self._list_error_boards = list_error_boards
326 self._show_config = show_config
328 def _AddTimestamp(self): argument
335 self._timestamps.append(now)
336 count = len(self._timestamps)
337 delta = self._timestamps[-1] - self._timestamps[0]
342 if count > 1 and self._next_delay_update < now:
343 self._next_delay_update = now + timedelta(seconds=2)
345 self._build_period = float(seconds) / count
346 todo = self.count - self.upto
347 self._complete_delay = timedelta(microseconds=
348 self._build_period * todo * 1000000)
350 self._complete_delay -= timedelta(
351 microseconds=self._complete_delay.microseconds)
354 self._timestamps.popleft()
357 def ClearLine(self, length): argument
367 if length < self.last_line_len:
368 Print(' ' * (self.last_line_len - length), newline=False)
370 self.last_line_len = length
373 def SelectCommit(self, commit, checkout=True): argument
376 self.commit = commit
377 if checkout and self.checkout:
380 def Make(self, commit, brd, stage, cwd, *args, **kwargs): argument
391 cmd = [self.gnu_make] + list(args)
394 if self.verbose_build:
399 def ProcessResult(self, result): argument
410 self.upto += 1
412 self.fail += 1
414 self.warned += 1
416 self.already_done += 1
417 if self._verbose:
419 self.ClearLine(0)
421 self.ResetResultSummary(boards_selected)
422 self.ProduceResultSummary(result.commit_upto, self.commits,
428 ok = self.upto - self.warned - self.fail
429 line = '\r' + self.col.Color(self.col.GREEN, '%5d' % ok)
430 line += self.col.Color(self.col.YELLOW, '%5d' % self.warned)
431 line += self.col.Color(self.col.RED, '%5d' % self.fail)
433 name = ' /%-5d ' % self.count
436 self._AddTimestamp()
437 if self._complete_delay:
438 name += '%s : ' % self._complete_delay
442 name += 'commit %2d/%-3d' % (self.commit_upto + 1,
443 self.commit_count)
448 self.ClearLine(length)
450 def _GetOutputDir(self, commit_upto): argument
459 if self.commits:
460 commit = self.commits[commit_upto]
463 self.commit_count, commit.hash, subject[:20]))
464 elif not self.no_subdirs:
467 return self.base_dir
468 return os.path.join(self.base_dir, commit_dir)
470 def GetBuildDir(self, commit_upto, target): argument
479 output_dir = self._GetOutputDir(commit_upto)
482 def GetDoneFile(self, commit_upto, target): argument
489 return os.path.join(self.GetBuildDir(commit_upto, target), 'done')
491 def GetSizesFile(self, commit_upto, target): argument
498 return os.path.join(self.GetBuildDir(commit_upto, target), 'sizes')
500 def GetFuncSizesFile(self, commit_upto, target, elf_fname): argument
508 return os.path.join(self.GetBuildDir(commit_upto, target),
511 def GetObjdumpFile(self, commit_upto, target, elf_fname): argument
519 return os.path.join(self.GetBuildDir(commit_upto, target),
522 def GetErrFile(self, commit_upto, target): argument
529 output_dir = self.GetBuildDir(commit_upto, target)
532 def FilterErrors(self, lines): argument
544 if not self.re_make_err.search(line):
548 def ReadFuncSizes(self, fname, fd): argument
573 def _ProcessConfig(self, fname): argument
598 value = '1' if self.squash_config_y else ''
605 if self.squash_config_y and value == 'y':
610 def GetBuildOutcome(self, commit_upto, target, read_func_sizes, argument
623 done_file = self.GetDoneFile(commit_upto, target)
624 sizes_file = self.GetSizesFile(commit_upto, target)
632 err_file = self.GetErrFile(commit_upto, target)
635 err_lines = self.FilterErrors(fd.readlines())
664 pattern = self.GetFuncSizesFile(commit_upto, target, '*')
669 func_sizes[dict_name] = self.ReadFuncSizes(fname, fd)
672 output_dir = self.GetBuildDir(commit_upto, target)
673 for name in self.config_filenames:
675 config[name] = self._ProcessConfig(fname)
681 def GetResultSummary(self, boards_selected, commit_upto, read_func_sizes, argument
723 outcome = self.GetBuildOutcome(commit_upto, board.target,
730 if (self._re_function.match(line) or
731 self._re_files.match(line)):
734 is_warning = self._re_warning.match(line)
735 is_note = self._re_note.match(line)
750 tconfig = Config(self.config_filenames, board.target)
751 for fname in self.config_filenames:
760 def AddOutcome(self, board_dict, arch_list, changes, char, color): argument
780 str = self.col.Color(color, ' ' + target)
782 str = ' %s %s' % (self.col.Color(color, char), str)
790 def ColourNum(self, num): argument
791 color = self.col.RED if num > 0 else self.col.GREEN
794 return self.col.Color(color, str(num))
796 def ResetResultSummary(self, board_selected): argument
809 self._base_board_dict = {}
811 self._base_board_dict[board] = Builder.Outcome(0, [], [], {}, {})
812 self._base_err_lines = []
813 self._base_warn_lines = []
814 self._base_err_line_boards = {}
815 self._base_warn_line_boards = {}
816 self._base_config = None
818 def PrintFuncSizeDetail(self, fname, old, new): argument
852 args = [self.ColourNum(x) for x in args]
855 tuple([indent, self.col.Color(self.col.YELLOW, fname)] + args))
860 color = self.col.RED if diff > 0 else self.col.GREEN
866 def PrintSizeDetail(self, target_list, show_bloat): argument
885 color = self.col.RED if diff > 0 else self.col.GREEN
897 base_outcome = self._base_board_dict[target]
899 self.PrintFuncSizeDetail(fname,
904 def PrintSizeSummary(self, board_selected, board_dict, show_detail, argument
934 base_sizes = self._base_board_dict[target].sizes
995 color = self.col.RED if avg_diff > 0 else self.col.GREEN
1006 self.PrintSizeDetail(target_list, show_bloat)
1009 def PrintResultSummary(self, board_selected, board_dict, err_lines, argument
1051 if self._list_error_boards:
1121 col = self.col.GREEN
1123 col = self.col.RED
1125 col = self.col.YELLOW
1139 if target in self._base_board_dict:
1140 base_outcome = self._base_board_dict[target].rc
1152 better_err, worse_err = _CalcErrorDelta(self._base_err_lines,
1153 self._base_err_line_boards, err_lines, err_line_boards, '')
1154 better_warn, worse_warn = _CalcErrorDelta(self._base_warn_lines,
1155 self._base_warn_line_boards, warn_lines, warn_line_boards, 'w')
1161 self.AddOutcome(board_selected, arch_list, better, '',
1162 self.col.GREEN)
1163 self.AddOutcome(board_selected, arch_list, worse, '+',
1164 self.col.RED)
1165 self.AddOutcome(board_selected, arch_list, new, '*', self.col.BLUE)
1166 if self._show_unknown:
1167 self.AddOutcome(board_selected, arch_list, unknown, '?',
1168 self.col.MAGENTA)
1171 self._error_lines += 1
1173 Print('\n'.join(better_err), colour=self.col.GREEN)
1174 self._error_lines += 1
1176 Print('\n'.join(worse_err), colour=self.col.RED)
1177 self._error_lines += 1
1179 Print('\n'.join(better_warn), colour=self.col.CYAN)
1180 self._error_lines += 1
1182 Print('\n'.join(worse_warn), colour=self.col.MAGENTA)
1183 self._error_lines += 1
1186 self.PrintSizeSummary(board_selected, board_dict, show_detail,
1189 if show_config and self._base_config:
1207 for name in self.config_filenames:
1221 tbase = self._base_config[target]
1224 for name in self.config_filenames:
1268 for name in self.config_filenames:
1289 self._base_board_dict = board_dict
1290 self._base_err_lines = err_lines
1291 self._base_warn_lines = warn_lines
1292 self._base_err_line_boards = err_line_boards
1293 self._base_warn_line_boards = warn_line_boards
1294 self._base_config = config
1305 def ProduceResultSummary(self, commit_upto, commits, board_selected): argument
1307 warn_line_boards, config) = self.GetResultSummary(
1309 read_func_sizes=self._show_bloat,
1310 read_config=self._show_config)
1314 Print(msg, colour=self.col.BLUE)
1315 self.PrintResultSummary(board_selected, board_dict,
1316 err_lines if self._show_errors else [], err_line_boards,
1317 warn_lines if self._show_errors else [], warn_line_boards,
1318 config, self._show_sizes, self._show_detail,
1319 self._show_bloat, self._show_config)
1321 def ShowSummary(self, commits, board_selected): argument
1331 self.commit_count = len(commits) if commits else 1
1332 self.commits = commits
1333 self.ResetResultSummary(board_selected)
1334 self._error_lines = 0
1336 for commit_upto in range(0, self.commit_count, self._step):
1337 self.ProduceResultSummary(commit_upto, commits, board_selected)
1338 if not self._error_lines:
1339 Print('(no errors to report)', colour=self.col.GREEN)
1342 def SetupBuild(self, board_selected, commits): argument
1350 count = (self.commit_count + self._step - 1) / self._step
1351 self.count = len(board_selected) * count
1352 self.upto = self.warned = self.fail = 0
1353 self._timestamps = collections.deque()
1355 def GetThreadDir(self, thread_num): argument
1361 return os.path.join(self._working_dir, '%02d' % thread_num)
1363 def _PrepareThread(self, thread_num, setup_git): argument
1372 thread_dir = self.GetThreadDir(thread_num)
1379 if setup_git and self.git_dir:
1380 src_dir = os.path.abspath(self.git_dir)
1389 def _PrepareWorkingSpace(self, max_threads, setup_git): argument
1398 builderthread.Mkdir(self._working_dir)
1400 self._PrepareThread(thread, setup_git)
1402 def _PrepareOutputSpace(self): argument
1409 if not self.commits:
1412 for commit_upto in range(self.commit_count):
1413 dir_list.append(self._GetOutputDir(commit_upto))
1416 for dirname in glob.glob(os.path.join(self.base_dir, '*')):
1425 def BuildBoards(self, commits, board_selected, keep_outputs, verbose): argument
1439 self.commit_count = len(commits) if commits else 1
1440 self.commits = commits
1441 self._verbose = verbose
1443 self.ResetResultSummary(board_selected)
1444 builderthread.Mkdir(self.base_dir, parents = True)
1445 self._PrepareWorkingSpace(min(self.num_threads, len(board_selected)),
1447 self._PrepareOutputSpace()
1449 self.SetupBuild(board_selected, commits)
1450 self.ProcessResult(None)
1458 job.step = self._step
1459 self.queue.put(job)
1461 term = threading.Thread(target=self.queue.join)
1468 self.out_queue.join()
1470 self.ClearLine(0)
1471 return (self.fail, self.warned)