1 # Copyright (c) 2012 The Chromium OS Authors.
3 # SPDX-License-Identifier: GPL-2.0+
7 """A particular board that we can build"""
8 def __init__(self, target, arch, cpu, board_name, vendor, soc, options):
9 """Create a new board type.
12 target: Target name (use make <target>_config to configure)
13 arch: Architecture name (e.g. arm)
14 cpu: Cpu name (e.g. arm1136)
15 board_name: Name of board (e.g. integrator)
16 vendor: Name of vendor (e.g. armltd)
17 soc: Name of SOC, or '' if none (e.g. mx31)
18 options: board-specific options (e.g. integratorcp:CM1136)
23 self.board_name = board_name
26 self.props = [self.target, self.arch, self.cpu, self.board_name,
27 self.vendor, self.soc]
28 self.options = options
33 """Manage a list of boards."""
35 # Use a simple list here, sinc OrderedDict requires Python 2.7
38 def AddBoard(self, board):
39 """Add a new board to the list.
41 The board's target member must not already exist in the board list.
46 self._boards.append(board)
48 def ReadBoards(self, fname):
49 """Read a list of boards from a board file.
51 Create a board object for each and add it to our _boards list.
54 fname: Filename of boards.cfg file
56 with open(fname, 'r') as fd:
63 for upto in range(len(fields)):
64 if fields[upto] == '-':
66 while len(fields) < 7:
69 board = Board(*fields)
74 """Return a list of available boards.
82 """Build a dictionary containing all the boards.
90 for board in self._boards:
91 board_dict[board.target] = board
94 def GetSelectedDict(self):
95 """Return a dictionary containing the selected boards
98 List of Board objects that are marked selected
101 for board in self._boards:
103 board_dict[board.target] = board
106 def GetSelected(self):
107 """Return a list of selected boards
110 List of Board objects that are marked selected
112 return [board for board in self._boards if board.build_it]
114 def GetSelectedNames(self):
115 """Return a list of selected boards
118 List of board names that are marked selected
120 return [board.target for board in self._boards if board.build_it]
122 def SelectBoards(self, args):
123 """Mark boards selected based on args
126 List of strings specifying boards to include, either named, or
127 by their target, architecture, cpu, vendor or soc. If empty, all
131 Dictionary which holds the number of boards which were selected
132 due to each argument, arranged by argument.
139 for board in self._boards:
142 if arg in board.props:
143 if not board.build_it:
144 board.build_it = True
148 board.build_it = True