aboutsummaryrefslogtreecommitdiff
path: root/tools/buildman/control.py
diff options
context:
space:
mode:
authorSimon Glass2019-12-05 15:59:14 -0700
committerSimon Glass2019-12-10 21:11:31 -0700
commit57cb9d52397c9051d7b3d27bd107cce04a16846f (patch)
tree107dfad7cd3d0fb03fb02800fa01a413d231212c /tools/buildman/control.py
parent7c66ead45267122c48bc854d1d5bd0d9a99bf943 (diff)
buildman: Add options to get the arch and toolchain info
Sometimes it is useful for external tools to use buildman to provide the toolchain information. Add an -a option which shows the value to use for the ARCH environment variable, and -A which does the same for CROSS_COMPILE Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'tools/buildman/control.py')
-rw-r--r--tools/buildman/control.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/tools/buildman/control.py b/tools/buildman/control.py
index a9c5022e48f..969d866547a 100644
--- a/tools/buildman/control.py
+++ b/tools/buildman/control.py
@@ -107,6 +107,34 @@ def CheckOutputDir(output_dir):
break
path = parent
+def ShowToolchainInfo(boards, toolchains, print_arch, print_prefix):
+ """Show information about a the tool chain used by one or more boards
+
+ The function checks that all boards use the same toolchain.
+
+ Args:
+ boards: Boards object containing selected boards
+ toolchains: Toolchains object containing available toolchains
+ print_arch: True to print ARCH value
+ print_prefix: True to print CROSS_COMPILE value
+
+ Return:
+ None on success, string error message otherwise
+ """
+ boards = boards.GetSelectedDict()
+ tc_set = set()
+ for brd in boards.values():
+ tc_set.add(toolchains.Select(brd.arch))
+ if len(tc_set) != 1:
+ return 'Supplied boards must share one toolchain'
+ return False
+ tc = tc_set.pop()
+ if print_arch:
+ print(tc.GetEnvArgs(toolchain.VAR_ARCH))
+ if print_prefix:
+ print(tc.GetEnvArgs(toolchain.VAR_CROSS_COMPILE))
+ return None
+
def DoBuildman(options, args, toolchains=None, make_func=None, boards=None,
clean_dir=False):
"""The main control code for buildman
@@ -200,6 +228,13 @@ def DoBuildman(options, args, toolchains=None, make_func=None, boards=None,
if not len(selected):
sys.exit(col.Color(col.RED, 'No matching boards found'))
+ if options.print_arch or options.print_prefix:
+ err = ShowToolchainInfo(boards, toolchains, options.print_arch,
+ options.print_prefix)
+ if err:
+ sys.exit(col.Color(col.RED, err))
+ return 0
+
# Work out how many commits to build. We want to build everything on the
# branch. We also build the upstream commit as a control so we can see
# problems introduced by the first commit on the branch.