1 # Copyright (c) 2012 The Chromium OS Authors.
3 # SPDX-License-Identifier: GPL-2.0+
9 """A particular board that we can build"""
10 def __init__(self, status, arch, cpu, soc, vendor, board_name, target, options):
11 """Create a new board type.
14 status: define whether the board is 'Active' or 'Orphaned'
15 arch: Architecture name (e.g. arm)
16 cpu: Cpu name (e.g. arm1136)
17 soc: Name of SOC, or '' if none (e.g. mx31)
18 vendor: Name of vendor (e.g. armltd)
19 board_name: Name of board (e.g. integrator)
20 target: Target name (use make <target>_config to configure)
21 options: board-specific options (e.g. integratorcp:CM1136)
26 self.board_name = board_name
29 self.props = [self.target, self.arch, self.cpu, self.board_name,
30 self.vendor, self.soc]
31 self.options = options
36 """Manage a list of boards."""
38 # Use a simple list here, sinc OrderedDict requires Python 2.7
41 def AddBoard(self, board):
42 """Add a new board to the list.
44 The board's target member must not already exist in the board list.
49 self._boards.append(board)
51 def ReadBoards(self, fname):
52 """Read a list of boards from a board file.
54 Create a board object for each and add it to our _boards list.
57 fname: Filename of boards.cfg file
59 with open(fname, 'r') as fd:
66 for upto in range(len(fields)):
67 if fields[upto] == '-':
69 while len(fields) < 8:
74 board = Board(*fields)
79 """Return a list of available boards.
87 """Build a dictionary containing all the boards.
95 for board in self._boards:
96 board_dict[board.target] = board
99 def GetSelectedDict(self):
100 """Return a dictionary containing the selected boards
103 List of Board objects that are marked selected
106 for board in self._boards:
108 board_dict[board.target] = board
111 def GetSelected(self):
112 """Return a list of selected boards
115 List of Board objects that are marked selected
117 return [board for board in self._boards if board.build_it]
119 def GetSelectedNames(self):
120 """Return a list of selected boards
123 List of board names that are marked selected
125 return [board.target for board in self._boards if board.build_it]
127 def SelectBoards(self, args):
128 """Mark boards selected based on args
131 List of strings specifying boards to include, either named, or
132 by their target, architecture, cpu, vendor or soc. If empty, all
136 Dictionary which holds the number of boards which were selected
137 due to each argument, arranged by argument.
143 argres[arg] = re.compile(arg)
146 for board in self._boards:
151 for prop in board.props:
152 match = argre.match(prop)
156 if not board.build_it:
157 board.build_it = True
161 board.build_it = True