Lines Matching refs:self

120     def __init__(self, config_filename, target):  argument
121 self.target = target
122 self.config = {}
124 self.config[fname] = {}
126 def Add(self, fname, key, value): argument
127 self.config[fname][key] = value
129 def __hash__(self): argument
131 for fname in self.config:
132 for key, value in self.config[fname].items():
139 def __init__(self, target): argument
140 self.target = target
141 self.environment = {}
143 def Add(self, key, value): argument
144 self.environment[key] = value
224 def __init__(self, rc, err_lines, sizes, func_sizes, config, argument
226 self.rc = rc
227 self.err_lines = err_lines
228 self.sizes = sizes
229 self.func_sizes = func_sizes
230 self.config = config
231 self.environment = environment
233 def __init__(self, toolchains, base_dir, git_dir, num_threads, num_jobs, argument
266 self.toolchains = toolchains
267 self.base_dir = base_dir
269 self._working_dir = base_dir
271 self._working_dir = os.path.join(base_dir, '.bm-work')
272 self.threads = []
273 self.do_make = self.Make
274 self.gnu_make = gnu_make
275 self.checkout = checkout
276 self.num_threads = num_threads
277 self.num_jobs = num_jobs
278 self.already_done = 0
279 self.force_build = False
280 self.git_dir = git_dir
281 self._show_unknown = show_unknown
282 self._timestamp_count = 10
283 self._build_period_us = None
284 self._complete_delay = None
285 self._next_delay_update = datetime.now()
286 self._start_time = datetime.now()
287 self.force_config_on_failure = True
288 self.force_build_failures = False
289 self.force_reconfig = False
290 self._step = step
291 self.in_tree = False
292 self._error_lines = 0
293 self.no_subdirs = no_subdirs
294 self.full_path = full_path
295 self.verbose_build = verbose_build
296 self.config_only = config_only
297 self.squash_config_y = squash_config_y
298 self.config_filenames = BASE_CONFIG_FILENAMES
299 self.work_in_output = work_in_output
300 if not self.squash_config_y:
301 self.config_filenames += EXTRA_CONFIG_FILENAMES
303 self.warnings_as_errors = warnings_as_errors
304 self.col = terminal.Color()
306 self._re_function = re.compile('(.*): In function.*')
307 self._re_files = re.compile('In file included from.*')
308 self._re_warning = re.compile('(.*):(\d*):(\d*): warning: .*')
309 self._re_dtb_warning = re.compile('(.*): Warning .*')
310 self._re_note = re.compile('(.*):(\d*):(\d*): note: this is the location of the previous.*')
311 self._re_migration_warning = re.compile(r'^={21} WARNING ={22}\n.*\n=+\n',
314 if self.num_threads:
315 self._single_builder = None
316 self.queue = queue.Queue()
317 self.out_queue = queue.Queue()
318 for i in range(self.num_threads):
319 t = builderthread.BuilderThread(self, i, mrproper,
323 self.threads.append(t)
325 t = builderthread.ResultThread(self)
328 self.threads.append(t)
330 self._single_builder = builderthread.BuilderThread(
331 self, -1, mrproper, per_board_out_dir)
334 self.re_make_err = re.compile('|'.join(ignore_lines))
337 signal.signal(signal.SIGINT, self.signal_handler)
339 def __del__(self): argument
341 for t in self.threads:
344 def signal_handler(self, signal, frame): argument
347 def SetDisplayOptions(self, show_errors=False, show_sizes=False, argument
367 self._show_errors = show_errors
368 self._show_sizes = show_sizes
369 self._show_detail = show_detail
370 self._show_bloat = show_bloat
371 self._list_error_boards = list_error_boards
372 self._show_config = show_config
373 self._show_environment = show_environment
374 self._filter_dtb_warnings = filter_dtb_warnings
375 self._filter_migration_warnings = filter_migration_warnings
377 def _AddTimestamp(self): argument
384 self._timestamps.append(now)
385 count = len(self._timestamps)
386 delta = self._timestamps[-1] - self._timestamps[0]
391 if count > 1 and self._next_delay_update < now:
392 self._next_delay_update = now + timedelta(seconds=2)
394 self._build_period = float(seconds) / count
395 todo = self.count - self.upto
396 self._complete_delay = timedelta(microseconds=
397 self._build_period * todo * 1000000)
399 self._complete_delay -= timedelta(
400 microseconds=self._complete_delay.microseconds)
403 self._timestamps.popleft()
406 def SelectCommit(self, commit, checkout=True): argument
409 self.commit = commit
410 if checkout and self.checkout:
413 def Make(self, commit, brd, stage, cwd, *args, **kwargs): argument
424 cmd = [self.gnu_make] + list(args)
427 if self.verbose_build:
432 def ProcessResult(self, result): argument
443 self.upto += 1
445 self.fail += 1
447 self.warned += 1
449 self.already_done += 1
450 if self._verbose:
453 self.ResetResultSummary(boards_selected)
454 self.ProduceResultSummary(result.commit_upto, self.commits,
460 ok = self.upto - self.warned - self.fail
461 line = '\r' + self.col.Color(self.col.GREEN, '%5d' % ok)
462 line += self.col.Color(self.col.YELLOW, '%5d' % self.warned)
463 line += self.col.Color(self.col.RED, '%5d' % self.fail)
465 line += ' /%-5d ' % self.count
466 remaining = self.count - self.upto
468 line += self.col.Color(self.col.MAGENTA, ' -%-5d ' % remaining)
473 self._AddTimestamp()
474 if self._complete_delay:
475 line += '%s : ' % self._complete_delay
481 def _GetOutputDir(self, commit_upto): argument
489 if self.work_in_output:
490 return self._working_dir
493 if self.commits:
494 commit = self.commits[commit_upto]
499 elif not self.no_subdirs:
502 return self.base_dir
503 return os.path.join(self.base_dir, commit_dir)
505 def GetBuildDir(self, commit_upto, target): argument
514 output_dir = self._GetOutputDir(commit_upto)
515 if self.work_in_output:
519 def GetDoneFile(self, commit_upto, target): argument
526 return os.path.join(self.GetBuildDir(commit_upto, target), 'done')
528 def GetSizesFile(self, commit_upto, target): argument
535 return os.path.join(self.GetBuildDir(commit_upto, target), 'sizes')
537 def GetFuncSizesFile(self, commit_upto, target, elf_fname): argument
545 return os.path.join(self.GetBuildDir(commit_upto, target),
548 def GetObjdumpFile(self, commit_upto, target, elf_fname): argument
556 return os.path.join(self.GetBuildDir(commit_upto, target),
559 def GetErrFile(self, commit_upto, target): argument
566 output_dir = self.GetBuildDir(commit_upto, target)
569 def FilterErrors(self, lines): argument
580 if self._filter_migration_warnings:
582 text = self._re_migration_warning.sub('', text)
585 if self.re_make_err.search(line):
587 if self._filter_dtb_warnings and self._re_dtb_warning.search(line):
592 def ReadFuncSizes(self, fname, fd): argument
618 def _ProcessConfig(self, fname): argument
643 value = '1' if self.squash_config_y else ''
650 if self.squash_config_y and value == 'y':
655 def _ProcessEnvironment(self, fname): argument
680 def GetBuildOutcome(self, commit_upto, target, read_func_sizes, argument
694 done_file = self.GetDoneFile(commit_upto, target)
695 sizes_file = self.GetSizesFile(commit_upto, target)
709 err_file = self.GetErrFile(commit_upto, target)
712 err_lines = self.FilterErrors(fd.readlines())
741 pattern = self.GetFuncSizesFile(commit_upto, target, '*')
746 func_sizes[dict_name] = self.ReadFuncSizes(fname, fd)
749 output_dir = self.GetBuildDir(commit_upto, target)
750 for name in self.config_filenames:
752 config[name] = self._ProcessConfig(fname)
755 output_dir = self.GetBuildDir(commit_upto, target)
757 environment = self._ProcessEnvironment(fname)
764 def GetResultSummary(self, boards_selected, commit_upto, read_func_sizes, argument
811 outcome = self.GetBuildOutcome(commit_upto, board.target,
819 if (self._re_function.match(line) or
820 self._re_files.match(line)):
823 is_warning = (self._re_warning.match(line) or
824 self._re_dtb_warning.match(line))
825 is_note = self._re_note.match(line)
840 tconfig = Config(self.config_filenames, board.target)
841 for fname in self.config_filenames:
856 def AddOutcome(self, board_dict, arch_list, changes, char, color): argument
876 str = self.col.Color(color, ' ' + target)
878 str = ' %s %s' % (self.col.Color(color, char), str)
886 def ColourNum(self, num): argument
887 color = self.col.RED if num > 0 else self.col.GREEN
890 return self.col.Color(color, str(num))
892 def ResetResultSummary(self, board_selected): argument
905 self._base_board_dict = {}
907 self._base_board_dict[board] = Builder.Outcome(0, [], [], {}, {},
909 self._base_err_lines = []
910 self._base_warn_lines = []
911 self._base_err_line_boards = {}
912 self._base_warn_line_boards = {}
913 self._base_config = None
914 self._base_environment = None
916 def PrintFuncSizeDetail(self, fname, old, new): argument
950 args = [self.ColourNum(x) for x in args]
953 tuple([indent, self.col.Color(self.col.YELLOW, fname)] + args))
958 color = self.col.RED if diff > 0 else self.col.GREEN
964 def PrintSizeDetail(self, target_list, show_bloat): argument
983 color = self.col.RED if diff > 0 else self.col.GREEN
995 base_outcome = self._base_board_dict[target]
997 self.PrintFuncSizeDetail(fname,
1002 def PrintSizeSummary(self, board_selected, board_dict, show_detail, argument
1032 base_sizes = self._base_board_dict[target].sizes
1093 color = self.col.RED if avg_diff > 0 else self.col.GREEN
1104 self.PrintSizeDetail(target_list, show_bloat)
1107 def PrintResultSummary(self, board_selected, board_dict, err_lines, argument
1155 if self._list_error_boards:
1242 col = self.col.GREEN
1244 col = self.col.RED
1246 col = self.col.YELLOW
1267 out = self.col.Color(colour, line.char + '(')
1268 out += self.col.Color(self.col.MAGENTA, board_str,
1270 out += self.col.Color(colour, ') %s' % line.errline)
1272 out = self.col.Color(colour, line.char + line.errline)
1275 self._error_lines += 1
1289 if target in self._base_board_dict:
1290 base_outcome = self._base_board_dict[target].rc
1308 better_err, worse_err = _CalcErrorDelta(self._base_err_lines,
1309 self._base_err_line_boards, err_lines, err_line_boards, '')
1310 better_warn, worse_warn = _CalcErrorDelta(self._base_warn_lines,
1311 self._base_warn_line_boards, warn_lines, warn_line_boards, 'w')
1317 self.AddOutcome(board_selected, arch_list, ok_boards, '',
1318 self.col.GREEN)
1319 self.AddOutcome(board_selected, arch_list, warn_boards, 'w+',
1320 self.col.YELLOW)
1321 self.AddOutcome(board_selected, arch_list, err_boards, '+',
1322 self.col.RED)
1323 self.AddOutcome(board_selected, arch_list, new_boards, '*', self.col.BLUE)
1324 if self._show_unknown:
1325 self.AddOutcome(board_selected, arch_list, unknown_boards, '?',
1326 self.col.MAGENTA)
1329 self._error_lines += 1
1330 _OutputErrLines(better_err, colour=self.col.GREEN)
1331 _OutputErrLines(worse_err, colour=self.col.RED)
1332 _OutputErrLines(better_warn, colour=self.col.CYAN)
1333 _OutputErrLines(worse_warn, colour=self.col.YELLOW)
1336 self.PrintSizeSummary(board_selected, board_dict, show_detail,
1339 if show_environment and self._base_environment:
1346 tbase = self._base_environment[target]
1369 if show_config and self._base_config:
1387 for name in self.config_filenames:
1401 tbase = self._base_config[target]
1404 for name in self.config_filenames:
1448 for name in self.config_filenames:
1469 self._base_board_dict = board_dict
1470 self._base_err_lines = err_lines
1471 self._base_warn_lines = warn_lines
1472 self._base_err_line_boards = err_line_boards
1473 self._base_warn_line_boards = warn_line_boards
1474 self._base_config = config
1475 self._base_environment = environment
1486 def ProduceResultSummary(self, commit_upto, commits, board_selected): argument
1488 warn_line_boards, config, environment) = self.GetResultSummary(
1490 read_func_sizes=self._show_bloat,
1491 read_config=self._show_config,
1492 read_environment=self._show_environment)
1496 Print(msg, colour=self.col.BLUE)
1497 self.PrintResultSummary(board_selected, board_dict,
1498 err_lines if self._show_errors else [], err_line_boards,
1499 warn_lines if self._show_errors else [], warn_line_boards,
1500 config, environment, self._show_sizes, self._show_detail,
1501 self._show_bloat, self._show_config, self._show_environment)
1503 def ShowSummary(self, commits, board_selected): argument
1513 self.commit_count = len(commits) if commits else 1
1514 self.commits = commits
1515 self.ResetResultSummary(board_selected)
1516 self._error_lines = 0
1518 for commit_upto in range(0, self.commit_count, self._step):
1519 self.ProduceResultSummary(commit_upto, commits, board_selected)
1520 if not self._error_lines:
1521 Print('(no errors to report)', colour=self.col.GREEN)
1524 def SetupBuild(self, board_selected, commits): argument
1532 count = (self.commit_count + self._step - 1) // self._step
1533 self.count = len(board_selected) * count
1534 self.upto = self.warned = self.fail = 0
1535 self._timestamps = collections.deque()
1537 def GetThreadDir(self, thread_num): argument
1544 if self.work_in_output:
1545 return self._working_dir
1546 return os.path.join(self._working_dir, '%02d' % max(thread_num, 0))
1548 def _PrepareThread(self, thread_num, setup_git): argument
1561 thread_dir = self.GetThreadDir(thread_num)
1567 if setup_git and self.git_dir:
1568 src_dir = os.path.abspath(self.git_dir)
1598 def _PrepareWorkingSpace(self, max_threads, setup_git): argument
1610 builderthread.Mkdir(self._working_dir)
1611 if setup_git and self.git_dir:
1612 src_dir = os.path.abspath(self.git_dir)
1624 self._PrepareThread(thread, setup_git)
1626 def _GetOutputSpaceRemovals(self): argument
1636 if not self.commits:
1639 for commit_upto in range(self.commit_count):
1640 dir_list.append(self._GetOutputDir(commit_upto))
1643 for dirname in glob.glob(os.path.join(self.base_dir, '*')):
1645 leaf = dirname[len(self.base_dir) + 1:]
1651 def _PrepareOutputSpace(self): argument
1658 to_remove = self._GetOutputSpaceRemovals()
1666 def BuildBoards(self, commits, board_selected, keep_outputs, verbose): argument
1680 self.commit_count = len(commits) if commits else 1
1681 self.commits = commits
1682 self._verbose = verbose
1684 self.ResetResultSummary(board_selected)
1685 builderthread.Mkdir(self.base_dir, parents = True)
1686 self._PrepareWorkingSpace(min(self.num_threads, len(board_selected)),
1688 self._PrepareOutputSpace()
1690 self.SetupBuild(board_selected, commits)
1691 self.ProcessResult(None)
1699 job.work_in_output = self.work_in_output
1700 job.step = self._step
1701 if self.num_threads:
1702 self.queue.put(job)
1704 results = self._single_builder.RunJob(job)
1706 if self.num_threads:
1707 term = threading.Thread(target=self.queue.join)
1714 self.out_queue.join()
1717 msg = 'Completed: %d total built' % self.count
1718 if self.already_done:
1719 msg += ' (%d previously' % self.already_done
1720 if self.already_done != self.count:
1721 msg += ', %d newly' % (self.count - self.already_done)
1723 duration = datetime.now() - self._start_time
1728 rate = float(self.count) / duration.total_seconds()
1732 return (self.fail, self.warned)