buildman: Avoid using board as a variable

We have a module called 'board'. Sometimes buildman uses 'brd' as an
instance variable but sometimes it uses 'board', which is confusing and
can mess with the module handling. Update the code to use 'brd'
consistently, making it easier for tools to determine when the module
is being referenced.

Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Simon Glass 2022-07-11 19:03:57 -06:00 committed by Tom Rini
parent ae1a09f803
commit f4ed4706ef
6 changed files with 55 additions and 56 deletions

View File

@ -103,15 +103,15 @@ class Boards:
# Use a simple list here, sinc OrderedDict requires Python 2.7 # Use a simple list here, sinc OrderedDict requires Python 2.7
self._boards = [] self._boards = []
def AddBoard(self, board): def AddBoard(self, brd):
"""Add a new board to the list. """Add a new board to the list.
The board's target member must not already exist in the board list. The board's target member must not already exist in the board list.
Args: Args:
board: board to add brd: board to add
""" """
self._boards.append(board) self._boards.append(brd)
def ReadBoards(self, fname): def ReadBoards(self, fname):
"""Read a list of boards from a board file. """Read a list of boards from a board file.
@ -136,8 +136,8 @@ class Boards:
if len(fields) > 8: if len(fields) > 8:
fields = fields[:8] fields = fields[:8]
board = Board(*fields) brd = Board(*fields)
self.AddBoard(board) self.AddBoard(brd)
def GetList(self): def GetList(self):
@ -157,8 +157,8 @@ class Boards:
value is board value is board
""" """
board_dict = OrderedDict() board_dict = OrderedDict()
for board in self._boards: for brd in self._boards:
board_dict[board.target] = board board_dict[brd.target] = brd
return board_dict return board_dict
def GetSelectedDict(self): def GetSelectedDict(self):
@ -168,9 +168,9 @@ class Boards:
List of Board objects that are marked selected List of Board objects that are marked selected
""" """
board_dict = OrderedDict() board_dict = OrderedDict()
for board in self._boards: for brd in self._boards:
if board.build_it: if brd.build_it:
board_dict[board.target] = board board_dict[brd.target] = brd
return board_dict return board_dict
def GetSelected(self): def GetSelected(self):
@ -179,7 +179,7 @@ class Boards:
Returns: Returns:
List of Board objects that are marked selected List of Board objects that are marked selected
""" """
return [board for board in self._boards if board.build_it] return [brd for brd in self._boards if brd.build_it]
def GetSelectedNames(self): def GetSelectedNames(self):
"""Return a list of selected boards """Return a list of selected boards
@ -187,7 +187,7 @@ class Boards:
Returns: Returns:
List of board names that are marked selected List of board names that are marked selected
""" """
return [board.target for board in self._boards if board.build_it] return [brd.target for brd in self._boards if brd.build_it]
def _BuildTerms(self, args): def _BuildTerms(self, args):
"""Convert command line arguments to a list of terms. """Convert command line arguments to a list of terms.
@ -273,34 +273,34 @@ class Boards:
exclude_list.append(Expr(expr)) exclude_list.append(Expr(expr))
found = [] found = []
for board in self._boards: for brd in self._boards:
matching_term = None matching_term = None
build_it = False build_it = False
if terms: if terms:
match = False match = False
for term in terms: for term in terms:
if term.Matches(board.props): if term.Matches(brd.props):
matching_term = str(term) matching_term = str(term)
build_it = True build_it = True
break break
elif boards: elif boards:
if board.target in boards: if brd.target in boards:
build_it = True build_it = True
found.append(board.target) found.append(brd.target)
else: else:
build_it = True build_it = True
# Check that it is not specifically excluded # Check that it is not specifically excluded
for expr in exclude_list: for expr in exclude_list:
if expr.Matches(board.props): if expr.Matches(brd.props):
build_it = False build_it = False
break break
if build_it: if build_it:
board.build_it = True brd.build_it = True
if matching_term: if matching_term:
result[matching_term].append(board.target) result[matching_term].append(brd.target)
result['all'].append(board.target) result['all'].append(brd.target)
if boards: if boards:
remaining = set(boards) - set(found) remaining = set(boards) - set(found)

View File

@ -875,11 +875,11 @@ class Builder:
config = {} config = {}
environment = {} environment = {}
for board in boards_selected.values(): for brd in boards_selected.values():
outcome = self.GetBuildOutcome(commit_upto, board.target, outcome = self.GetBuildOutcome(commit_upto, brd.target,
read_func_sizes, read_config, read_func_sizes, read_config,
read_environment) read_environment)
board_dict[board.target] = outcome board_dict[brd.target] = outcome
last_func = None last_func = None
last_was_warning = False last_was_warning = False
for line in outcome.err_lines: for line in outcome.err_lines:
@ -894,29 +894,29 @@ class Builder:
if is_warning or (last_was_warning and is_note): if is_warning or (last_was_warning and is_note):
if last_func: if last_func:
AddLine(warn_lines_summary, warn_lines_boards, AddLine(warn_lines_summary, warn_lines_boards,
last_func, board) last_func, brd)
AddLine(warn_lines_summary, warn_lines_boards, AddLine(warn_lines_summary, warn_lines_boards,
line, board) line, brd)
else: else:
if last_func: if last_func:
AddLine(err_lines_summary, err_lines_boards, AddLine(err_lines_summary, err_lines_boards,
last_func, board) last_func, brd)
AddLine(err_lines_summary, err_lines_boards, AddLine(err_lines_summary, err_lines_boards,
line, board) line, brd)
last_was_warning = is_warning last_was_warning = is_warning
last_func = None last_func = None
tconfig = Config(self.config_filenames, board.target) tconfig = Config(self.config_filenames, brd.target)
for fname in self.config_filenames: for fname in self.config_filenames:
if outcome.config: if outcome.config:
for key, value in outcome.config[fname].items(): for key, value in outcome.config[fname].items():
tconfig.Add(fname, key, value) tconfig.Add(fname, key, value)
config[board.target] = tconfig config[brd.target] = tconfig
tenvironment = Environment(board.target) tenvironment = Environment(brd.target)
if outcome.environment: if outcome.environment:
for key, value in outcome.environment.items(): for key, value in outcome.environment.items():
tenvironment.Add(key, value) tenvironment.Add(key, value)
environment[board.target] = tenvironment environment[brd.target] = tenvironment
return (board_dict, err_lines_summary, err_lines_boards, return (board_dict, err_lines_summary, err_lines_boards,
warn_lines_summary, warn_lines_boards, config, environment) warn_lines_summary, warn_lines_boards, config, environment)
@ -971,9 +971,8 @@ class Builder:
board.target board.target
""" """
self._base_board_dict = {} self._base_board_dict = {}
for board in board_selected: for brd in board_selected:
self._base_board_dict[board] = Builder.Outcome(0, [], [], {}, {}, self._base_board_dict[brd] = Builder.Outcome(0, [], [], {}, {}, {})
{})
self._base_err_lines = [] self._base_err_lines = []
self._base_warn_lines = [] self._base_warn_lines = []
self._base_err_line_boards = {} self._base_err_line_boards = {}
@ -1220,10 +1219,10 @@ class Builder:
boards = [] boards = []
board_set = set() board_set = set()
if self._list_error_boards: if self._list_error_boards:
for board in line_boards[line]: for brd in line_boards[line]:
if not board in board_set: if not brd in board_set:
boards.append(board) boards.append(brd)
board_set.add(board) board_set.add(brd)
return boards return boards
def _CalcErrorDelta(base_lines, base_line_boards, lines, line_boards, def _CalcErrorDelta(base_lines, base_line_boards, lines, line_boards,
@ -1328,7 +1327,7 @@ class Builder:
out_list = [] out_list = []
for line in err_lines: for line in err_lines:
boards = '' boards = ''
names = [board.target for board in line.boards] names = [brd.target for brd in line.boards]
board_str = ' '.join(names) if names else '' board_str = ' '.join(names) if names else ''
if board_str: if board_str:
out = self.col.build(colour, line.char + '(') out = self.col.build(colour, line.char + '(')
@ -1549,9 +1548,9 @@ class Builder:
# Get a list of boards that did not get built, if needed # Get a list of boards that did not get built, if needed
not_built = [] not_built = []
for board in board_selected: for brd in board_selected:
if not board in board_dict: if not brd in board_dict:
not_built.append(board) not_built.append(brd)
if not_built: if not_built:
tprint("Boards not built (%d): %s" % (len(not_built), tprint("Boards not built (%d): %s" % (len(not_built),
', '.join(not_built))) ', '.join(not_built)))
@ -1768,7 +1767,7 @@ class Builder:
# Create jobs to build all commits for each board # Create jobs to build all commits for each board
for brd in board_selected.values(): for brd in board_selected.values():
job = builderthread.BuilderJob() job = builderthread.BuilderJob()
job.board = brd job.brd = brd
job.commits = commits job.commits = commits
job.keep_outputs = keep_outputs job.keep_outputs = keep_outputs
job.work_in_output = self.work_in_output job.work_in_output = self.work_in_output

View File

@ -40,7 +40,7 @@ class BuilderJob:
"""Holds information about a job to be performed by a thread """Holds information about a job to be performed by a thread
Members: Members:
board: Board object to build brd: Board object to build
commits: List of Commit objects to build commits: List of Commit objects to build
keep_outputs: True to save build output files keep_outputs: True to save build output files
step: 1 to process every commit, n to process every nth commit step: 1 to process every commit, n to process every nth commit
@ -48,7 +48,7 @@ class BuilderJob:
don't write to a separate output directory. don't write to a separate output directory.
""" """
def __init__(self): def __init__(self):
self.board = None self.brd = None
self.commits = [] self.commits = []
self.keep_outputs = False self.keep_outputs = False
self.step = 1 self.step = 1
@ -491,7 +491,7 @@ class BuilderThread(threading.Thread):
Returns: Returns:
List of Result objects List of Result objects
""" """
brd = job.board brd = job.brd
work_dir = self.builder.GetThreadDir(self.thread_num) work_dir = self.builder.GetThreadDir(self.thread_num)
self.toolchain = None self.toolchain = None
if job.commits: if job.commits:

View File

@ -476,12 +476,12 @@ class TestFunctional(unittest.TestCase):
self.assertEqual(ret_code, 100) self.assertEqual(ret_code, 100)
for commit in range(self._commits): for commit in range(self._commits):
for board in self._boards.GetList(): for brd in self._boards.GetList():
if board.arch != 'sandbox': if brd.arch != 'sandbox':
errfile = self._builder.GetErrFile(commit, board.target) errfile = self._builder.GetErrFile(commit, brd.target)
fd = open(errfile) fd = open(errfile)
self.assertEqual(fd.readlines(), self.assertEqual(fd.readlines(),
['No tool chain for %s\n' % board.arch]) ['No tool chain for %s\n' % brd.arch])
fd.close() fd.close()
def testBranch(self): def testBranch(self):

View File

@ -184,8 +184,8 @@ class TestBuild(unittest.TestCase):
# TODO(sjg@chromium.org): If plus is '', we shouldn't need this # TODO(sjg@chromium.org): If plus is '', we shouldn't need this
expect += ' ' + col.build(expected_colour, plus) expect += ' ' + col.build(expected_colour, plus)
expect += ' ' expect += ' '
for board in boards: for brd in boards:
expect += col.build(expected_colour, ' %s' % board) expect += col.build(expected_colour, ' %s' % brd)
self.assertEqual(text, expect) self.assertEqual(text, expect)
def _SetupTest(self, echo_lines=False, threads=1, **kwdisplay_args): def _SetupTest(self, echo_lines=False, threads=1, **kwdisplay_args):

View File

@ -441,7 +441,7 @@ class Toolchains:
args = args[:m.start(0)] + value + args[m.end(0):] args = args[:m.start(0)] + value + args[m.end(0):]
return args return args
def GetMakeArguments(self, board): def GetMakeArguments(self, brd):
"""Returns 'make' arguments for a given board """Returns 'make' arguments for a given board
The flags are in a section called 'make-flags'. Flags are named The flags are in a section called 'make-flags'. Flags are named
@ -462,13 +462,13 @@ class Toolchains:
A special 'target' variable is set to the board target. A special 'target' variable is set to the board target.
Args: Args:
board: Board object for the board to check. brd: Board object for the board to check.
Returns: Returns:
'make' flags for that board, or '' if none 'make' flags for that board, or '' if none
""" """
self._make_flags['target'] = board.target self._make_flags['target'] = brd.target
arg_str = self.ResolveReferences(self._make_flags, arg_str = self.ResolveReferences(self._make_flags,
self._make_flags.get(board.target, '')) self._make_flags.get(brd.target, ''))
args = re.findall("(?:\".*?\"|\S)+", arg_str) args = re.findall("(?:\".*?\"|\S)+", arg_str)
i = 0 i = 0
while i < len(args): while i < len(args):