summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2023-07-19 17:49:28 -0600
committerSimon Glass <sjg@chromium.org>2023-07-24 09:34:11 -0600
commitad0378748e3e23e09c74d931367e8e379674770b (patch)
treec543454910537912b71a139450671655cce4c8b2 /tools
parent2ecc5805ac5e9209b922f57a39cb54bc648c1a22 (diff)
downloadu-boot-ad0378748e3e23e09c74d931367e8e379674770b.tar.gz
u-boot-ad0378748e3e23e09c74d931367e8e379674770b.tar.bz2
u-boot-ad0378748e3e23e09c74d931367e8e379674770b.zip
buildman: Add a way to print the architecture for a board
This is useful for some tools and is easily available for buildman. Add a new --print-arch option. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'tools')
-rw-r--r--tools/buildman/cmdline.py2
-rw-r--r--tools/buildman/control.py24
-rw-r--r--tools/buildman/func_test.py7
3 files changed, 33 insertions, 0 deletions
diff --git a/tools/buildman/cmdline.py b/tools/buildman/cmdline.py
index e218c8ffae..047cd1a39e 100644
--- a/tools/buildman/cmdline.py
+++ b/tools/buildman/cmdline.py
@@ -122,6 +122,8 @@ def add_after_m(parser):
default=False, help="Use full toolchain path in CROSS_COMPILE")
parser.add_argument('-P', '--per-board-out-dir', action='store_true',
default=False, help="Use an O= (output) directory per board rather than per thread")
+ parser.add_argument('--print-arch', action='store_true',
+ default=False, help="Print the architecture for a board (ARCH=)")
parser.add_argument('-r', '--reproducible-builds', action='store_true',
help='Set SOURCE_DATE_EPOCH=0 to suuport a reproducible build')
parser.add_argument('-R', '--regen-board-list', type=str,
diff --git a/tools/buildman/control.py b/tools/buildman/control.py
index e6c20d6d3b..c96018252a 100644
--- a/tools/buildman/control.py
+++ b/tools/buildman/control.py
@@ -140,6 +140,26 @@ def show_toolchain_prefix(brds, toolchains):
tchain = tc_set.pop()
print(tchain.GetEnvArgs(toolchain.VAR_CROSS_COMPILE))
+def show_arch(brds):
+ """Show information about a the architecture used by one or more boards
+
+ The function checks that all boards use the same architecture, then prints
+ the correct value for ARCH.
+
+ Args:
+ boards: Boards object containing selected boards
+
+ Return:
+ None on success, string error message otherwise
+ """
+ board_selected = brds.get_selected_dict()
+ arch_set = set()
+ for brd in board_selected.values():
+ arch_set.add(brd.arch)
+ if len(arch_set) != 1:
+ sys.exit('Supplied boards must share one arch')
+ print(arch_set.pop())
+
def get_allow_missing(opt_allow, opt_no_allow, num_selected, has_branch):
"""Figure out whether to allow external blobs
@@ -605,6 +625,10 @@ def do_buildman(args, toolchains=None, make_func=None, brds=None,
show_toolchain_prefix(brds, toolchains)
return 0
+ if args.print_arch:
+ show_arch(brds)
+ return 0
+
series = determine_series(selected, col, git_dir, args.count,
args.branch, args.work_in_output)
diff --git a/tools/buildman/func_test.py b/tools/buildman/func_test.py
index 126ea9e11f..58a9bf33ab 100644
--- a/tools/buildman/func_test.py
+++ b/tools/buildman/func_test.py
@@ -1060,3 +1060,10 @@ endif
self._RunControl('--boards', 'board1,board2', '--boards', 'board4')
self.assertEqual(3, self._builder.count)
+
+ def test_print_arch(self):
+ """Test that we can print the board architecture"""
+ with test_util.capture_sys_output() as (stdout, stderr):
+ result = self._RunControl('--print-arch', 'board0')
+ self.assertEqual('arm\n', stdout.getvalue())
+ self.assertEqual('', stderr.getvalue())