1 # Copyright (c) 2012 The Chromium OS Authors.
3 # See file CREDITS for list of people who contributed to this
6 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License as
8 # published by the Free Software Foundation; either version 2 of
9 # the License, or (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston,
23 """A particular board that we can build"""
24 def __init__(self, target, arch, cpu, board_name, vendor, soc, options):
25 """Create a new board type.
28 target: Target name (use make <target>_config to configure)
29 arch: Architecture name (e.g. arm)
30 cpu: Cpu name (e.g. arm1136)
31 board_name: Name of board (e.g. integrator)
32 vendor: Name of vendor (e.g. armltd)
33 soc: Name of SOC, or '' if none (e.g. mx31)
34 options: board-specific options (e.g. integratorcp:CM1136)
39 self.board_name = board_name
42 self.props = [self.target, self.arch, self.cpu, self.board_name,
43 self.vendor, self.soc]
44 self.options = options
49 """Manage a list of boards."""
51 # Use a simple list here, sinc OrderedDict requires Python 2.7
54 def AddBoard(self, board):
55 """Add a new board to the list.
57 The board's target member must not already exist in the board list.
62 self._boards.append(board)
64 def ReadBoards(self, fname):
65 """Read a list of boards from a board file.
67 Create a board object for each and add it to our _boards list.
70 fname: Filename of boards.cfg file
72 with open(fname, 'r') as fd:
79 for upto in range(len(fields)):
80 if fields[upto] == '-':
82 while len(fields) < 7:
85 board = Board(*fields)
90 """Return a list of available boards.
98 """Build a dictionary containing all the boards.
106 for board in self._boards:
107 board_dict[board.target] = board
110 def GetSelectedDict(self):
111 """Return a dictionary containing the selected boards
114 List of Board objects that are marked selected
117 for board in self._boards:
119 board_dict[board.target] = board
122 def GetSelected(self):
123 """Return a list of selected boards
126 List of Board objects that are marked selected
128 return [board for board in self._boards if board.build_it]
130 def GetSelectedNames(self):
131 """Return a list of selected boards
134 List of board names that are marked selected
136 return [board.target for board in self._boards if board.build_it]
138 def SelectBoards(self, args):
139 """Mark boards selected based on args
142 List of strings specifying boards to include, either named, or
143 by their target, architecture, cpu, vendor or soc. If empty, all
147 Dictionary which holds the number of boards which were selected
148 due to each argument, arranged by argument.
155 for board in self._boards:
158 if arg in board.props:
159 if not board.build_it:
160 board.build_it = True
164 board.build_it = True