Merge branch '2019-10-08-master-imports'
[oweals/u-boot.git] / tools / buildman / board.py
index 5d536d5f20049fc40dd78880632ac10257bcd4c8..2a1d021574c1396098dafd41689e62311aa9f289 100644 (file)
@@ -1,7 +1,5 @@
+# SPDX-License-Identifier: GPL-2.0+
 # Copyright (c) 2012 The Chromium OS Authors.
-#
-# SPDX-License-Identifier:     GPL-2.0+
-#
 
 import re
 
@@ -92,9 +90,9 @@ class Board:
         self.board_name = board_name
         self.vendor = vendor
         self.soc = soc
-        self.props = [self.target, self.arch, self.cpu, self.board_name,
-                      self.vendor, self.soc]
         self.options = options
+        self.props = [self.target, self.arch, self.cpu, self.board_name,
+                      self.vendor, self.soc, self.options]
         self.build_it = False
 
 
@@ -239,30 +237,41 @@ class Boards:
             terms.append(term)
         return terms
 
-    def SelectBoards(self, args, exclude=[]):
+    def SelectBoards(self, args, exclude=[], boards=None):
         """Mark boards selected based on args
 
+        Normally either boards (an explicit list of boards) or args (a list of
+        terms to match against) is used. It is possible to specify both, in
+        which case they are additive.
+
+        If boards and args are both empty, all boards are selected.
+
         Args:
             args: List of strings specifying boards to include, either named,
                   or by their target, architecture, cpu, vendor or soc. If
                   empty, all boards are selected.
             exclude: List of boards to exclude, regardless of 'args'
+            boards: List of boards to build
 
         Returns:
-            Dictionary which holds the number of boards which were selected
-            due to each argument, arranged by argument.
+            Tuple
+                Dictionary which holds the list of boards which were selected
+                    due to each argument, arranged by argument.
+                List of errors found
         """
         result = {}
+        warnings = []
         terms = self._BuildTerms(args)
 
-        result['all'] = 0
+        result['all'] = []
         for term in terms:
-            result[str(term)] = 0
+            result[str(term)] = []
 
         exclude_list = []
         for expr in exclude:
             exclude_list.append(Expr(expr))
 
+        found = []
         for board in self._boards:
             matching_term = None
             build_it = False
@@ -273,6 +282,10 @@ class Boards:
                         matching_term = str(term)
                         build_it = True
                         break
+            elif boards:
+                if board.target in boards:
+                    build_it = True
+                    found.append(board.target)
             else:
                 build_it = True
 
@@ -285,7 +298,12 @@ class Boards:
             if build_it:
                 board.build_it = True
                 if matching_term:
-                    result[matching_term] += 1
-                result['all'] += 1
+                    result[matching_term].append(board.target)
+                result['all'].append(board.target)
+
+        if boards:
+            remaining = set(boards) - set(found)
+            if remaining:
+                warnings.append('Boards not found: %s\n' % ', '.join(remaining))
 
-        return result
+        return result, warnings