Patchwork [U-Boot,2/2] buildman: make board selector argument a regex

login
register
mail settings
Submitter Stephen Warren
Date Oct. 9, 2013, 8:28 p.m.
Message ID <1381350490-25867-2-git-send-email-swarren@wwwdotorg.org>
Download mbox | patch
Permalink /patch/282010/
State Superseded
Delegated to: Simon Glass
Headers show

Comments

Stephen Warren - Oct. 9, 2013, 8:28 p.m.
From: Stephen Warren <swarren@nvidia.com>

A common use-case is to build all boards for a particular SoC. This can
be achieved by:

./tools/buildman/buildman -b mainline_dev -n tegra20

However, when the SoC is a member of a family of SoCs, and each SoC has
a different name, it would be even more useful to build all boards for
every SoC in that family. This currently isn't possible since buildman's
board selection command-line arguments are compared to board definitions
using pure string equality.

To enable this, compare using a regex match instead. This matches
MAKEALL's handling of command-line arguments. This enables:

(all Tegra)
./tools/buildman/buildman -b mainline_dev -n tegra

(all Tegra)
./tools/buildman/buildman -b mainline_dev -n '^tegra.*$'

(all Tegra114, Tegra30 boards, but not Tegra20)
./tools/buildman/buildman -b mainline_dev -n 'tegra[13]'

Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
 tools/buildman/board.py | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
Simon Glass - Oct. 9, 2013, 10:28 p.m.
Hi Stephen,

On Wed, Oct 9, 2013 at 2:28 PM, Stephen Warren <swarren@wwwdotorg.org> wrote:
> From: Stephen Warren <swarren@nvidia.com>
>
> A common use-case is to build all boards for a particular SoC. This can
> be achieved by:
>
> ./tools/buildman/buildman -b mainline_dev -n tegra20
>
> However, when the SoC is a member of a family of SoCs, and each SoC has
> a different name, it would be even more useful to build all boards for
> every SoC in that family. This currently isn't possible since buildman's
> board selection command-line arguments are compared to board definitions
> using pure string equality.
>
> To enable this, compare using a regex match instead. This matches
> MAKEALL's handling of command-line arguments. This enables:
>
> (all Tegra)
> ./tools/buildman/buildman -b mainline_dev -n tegra

Do you want the -n here?

>
> (all Tegra)
> ./tools/buildman/buildman -b mainline_dev -n '^tegra.*$'
>
> (all Tegra114, Tegra30 boards, but not Tegra20)
> ./tools/buildman/buildman -b mainline_dev -n 'tegra[13]'
>
> Signed-off-by: Stephen Warren <swarren@nvidia.com>
> ---
>  tools/buildman/board.py | 12 +++++++++++-

Great addition, will be useful. Would you mind also updating the README please?

Regards,
Simon

Patch

diff --git a/tools/buildman/board.py b/tools/buildman/board.py
index 1d3db20..5172a47 100644
--- a/tools/buildman/board.py
+++ b/tools/buildman/board.py
@@ -3,6 +3,8 @@ 
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
+import re
+
 class Board:
     """A particular board that we can build"""
     def __init__(self, status, arch, cpu, soc, vendor, board_name, target, options):
@@ -135,14 +137,22 @@  class Boards:
             due to each argument, arranged by argument.
         """
         result = {}
+        argres = {}
         for arg in args:
             result[arg] = 0
+            argres[arg] = re.compile(arg)
         result['all'] = 0
 
         for board in self._boards:
             if args:
                 for arg in args:
-                    if arg in board.props:
+                    argre = argres[arg]
+                    match = False
+                    for prop in board.props:
+                        match = argre.match(prop)
+                        if match:
+                            break
+                    if match:
                         if not board.build_it:
                             board.build_it = True
                             result[arg] += 1