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, status, arch, cpu, soc, vendor, board_name, target, options):
9 """Create a new board type.
12 status: define whether the board is 'Active' or 'Orphaned'
13 arch: Architecture name (e.g. arm)
14 cpu: Cpu name (e.g. arm1136)
15 soc: Name of SOC, or '' if none (e.g. mx31)
16 vendor: Name of vendor (e.g. armltd)
17 board_name: Name of board (e.g. integrator)
18 target: Target name (use make <target>_config to configure)
19 options: board-specific options (e.g. integratorcp:CM1136)
24 self.board_name = board_name
27 self.props = [self.target, self.arch, self.cpu, self.board_name,
28 self.vendor, self.soc]
29 self.options = options
34 """Manage a list of boards."""
36 # Use a simple list here, sinc OrderedDict requires Python 2.7
39 def AddBoard(self, board):
40 """Add a new board to the list.
42 The board's target member must not already exist in the board list.
47 self._boards.append(board)
49 def ReadBoards(self, fname):
50 """Read a list of boards from a board file.
52 Create a board object for each and add it to our _boards list.
55 fname: Filename of boards.cfg file
57 with open(fname, 'r') as fd:
64 for upto in range(len(fields)):
65 if fields[upto] == '-':
67 while len(fields) < 8:
72 board = Board(*fields)
77 """Return a list of available boards.
85 """Build a dictionary containing all the boards.
93 for board in self._boards:
94 board_dict[board.target] = board
97 def GetSelectedDict(self):
98 """Return a dictionary containing the selected boards
101 List of Board objects that are marked selected
104 for board in self._boards:
106 board_dict[board.target] = board
109 def GetSelected(self):
110 """Return a list of selected boards
113 List of Board objects that are marked selected
115 return [board for board in self._boards if board.build_it]
117 def GetSelectedNames(self):
118 """Return a list of selected boards
121 List of board names that are marked selected
123 return [board.target for board in self._boards if board.build_it]
125 def SelectBoards(self, args):
126 """Mark boards selected based on args
129 List of strings specifying boards to include, either named, or
130 by their target, architecture, cpu, vendor or soc. If empty, all
134 Dictionary which holds the number of boards which were selected
135 due to each argument, arranged by argument.
142 for board in self._boards:
145 if arg in board.props:
146 if not board.build_it:
147 board.build_it = True
151 board.build_it = True