From patchwork Thu Dec 5 22:59:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1204871 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="NXmI65yb"; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47TWYr2qRQz9sPJ for ; Fri, 6 Dec 2019 10:06:40 +1100 (AEDT) Received: from phobos.denx.de (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7317A81710; Thu, 5 Dec 2019 23:59:28 +0100 (CET) Authentication-Results: mail.denx.de; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: mail.denx.de; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="NXmI65yb"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5F16C8170B; Thu, 5 Dec 2019 23:59:26 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-f194.google.com (mail-il1-f194.google.com [209.85.166.194]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id A638581670 for ; Thu, 5 Dec 2019 23:59:22 +0100 (CET) Authentication-Results: mail.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: mail.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-f194.google.com with SMTP id u17so4554290ilq.5 for ; Thu, 05 Dec 2019 14:59:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2/Nn84NmutRxjW/dS/fK+920PVEjdXv7wUYQC3Km2/Q=; b=NXmI65ybhnJBXDLU0/e76NqZMsoOUT/+DosrD477J25b90mPkGwVPaLfMQHQ5tkMX4 DjPqAxx+CL1FDwdGhTZzDcCMAxuUFglRSy+qMcGBzCPqf5TiM5FSrf6iVVsiHLSX8fma BxJ2WXRmjSQiX8OHOd5lDaTMC9xdtV4IngIZA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2/Nn84NmutRxjW/dS/fK+920PVEjdXv7wUYQC3Km2/Q=; b=WqFqfXUAgT2tJDsX6b+h5WPT/qekxlPqNottz29aayiK5MUAHpPIfqs3ivOGyiQfI1 E3yT2tU5IXUvt544qIz79GoNZUrJQzlRSGdXxv14QLKVsLMgZaOZtQ/zPzwpky/42rVj FvC9MpGOJd8DdraUCtl+2ke1dGWX7y353Xm8fhLQehRvt5r+qSVaG2mlKj7SZA46IMgr j3Wic4MblUxXvocOqNrLKlCdTtnga6RKjEJXApTfmsL943DcnTHWPgmvf3jD5VTY3DJJ Juuup5U+LOqA2KaPippbTtMDsUmiGGmflSnyj4N3Wi2ZLSrPiotzJV8D8NSMdxR7l8yW yc5A== X-Gm-Message-State: APjAAAUO/r54G9iMuTqQqAroRT6h/b6araJ6pD1g+fOBdCdbnnC40gOn DH5Vz3u2kNZE46YCzzDv6JuXlMuskYU= X-Google-Smtp-Source: APXvYqyECEmpY3cZpBYMIPKe7wuNW4+OKpuLnDnfU1Uy3KuAlqf3PamG+Gmy45g0e/IdndO9p3lqLg== X-Received: by 2002:a92:cd02:: with SMTP id z2mr12029085iln.286.1575586761412; Thu, 05 Dec 2019 14:59:21 -0800 (PST) Received: from kiwi.bld.corp.google.com ([2620:15c:183:0:8223:87c:a681:66aa]) by smtp.gmail.com with ESMTPSA id s23sm3296115ild.48.2019.12.05.14.59.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Dec 2019 14:59:21 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 4/4] buildman: Add options to get the arch and toolchain info Date: Thu, 5 Dec 2019 15:59:14 -0700 Message-Id: <20191205225914.10090-4-sjg@chromium.org> X-Mailer: git-send-email 2.24.0.393.g34dc348eaf-goog In-Reply-To: <20191205225914.10090-1-sjg@chromium.org> References: <20191205225914.10090-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.26 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.101.4 at mail.denx.de X-Virus-Status: Clean 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 --- tools/buildman/README | 3 +++ tools/buildman/cmdline.py | 4 ++++ tools/buildman/control.py | 35 +++++++++++++++++++++++++++++++++++ tools/buildman/test.py | 18 ++++++++++++++++++ tools/buildman/toolchain.py | 26 ++++++++++++++++++++++++++ 5 files changed, 86 insertions(+) diff --git a/tools/buildman/README b/tools/buildman/README index e36619216d..c1ac0d0f58 100644 --- a/tools/buildman/README +++ b/tools/buildman/README @@ -1061,6 +1061,9 @@ Other options Buildman has various other command line options. Try --help to see them. +To find out what architecture or toolchain prefix buildman will use for a build, +see the -a and -A options. + When doing builds, Buildman's return code will reflect the overall result: 0 (success) No errors or warnings found diff --git a/tools/buildman/cmdline.py b/tools/buildman/cmdline.py index 832a5145d2..b41209373d 100644 --- a/tools/buildman/cmdline.py +++ b/tools/buildman/cmdline.py @@ -13,6 +13,10 @@ def ParseArgs(): args: command lin arguments """ parser = OptionParser() + parser.add_option('-a', '--print-arch', action='store_true', + help='Print the architecture for a board (ARCH=)') + parser.add_option('-A', '--print-prefix', action='store_true', + help='Print the tool-chain prefix for a board (CROSS_COMPILE=)') parser.add_option('-b', '--branch', type='string', help='Branch name to build, or range of commits to build') parser.add_option('-B', '--bloat', dest='show_bloat', diff --git a/tools/buildman/control.py b/tools/buildman/control.py index a9c5022e48..969d866547 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. diff --git a/tools/buildman/test.py b/tools/buildman/test.py index b4e28d6867..acd862b3b0 100644 --- a/tools/buildman/test.py +++ b/tools/buildman/test.py @@ -451,6 +451,24 @@ class TestBuild(unittest.TestCase): 'crosstool/files/bin/x86_64/.*/' 'x86_64-gcc-.*-nolibc_arm-.*linux-gnueabi.tar.xz') + def testGetEnvArgs(self): + """Test the GetEnvArgs() function""" + tc = self.toolchains.Select('arm') + self.assertEqual('arm-linux-', + tc.GetEnvArgs(toolchain.VAR_CROSS_COMPILE)) + self.assertEqual('', tc.GetEnvArgs(toolchain.VAR_PATH)) + self.assertEqual('arm', + tc.GetEnvArgs(toolchain.VAR_ARCH)) + self.assertEqual('', tc.GetEnvArgs(toolchain.VAR_MAKE_ARGS)) + + self.toolchains.Add('/path/to/x86_64-linux-gcc', test=False) + tc = self.toolchains.Select('x86') + self.assertEqual('/path/to', + tc.GetEnvArgs(toolchain.VAR_PATH)) + tc.override_toolchain = 'clang' + self.assertEqual('HOSTCC=clang CC=clang', + tc.GetEnvArgs(toolchain.VAR_MAKE_ARGS)) + if __name__ == "__main__": unittest.main() diff --git a/tools/buildman/toolchain.py b/tools/buildman/toolchain.py index cc26e2ede5..9289395601 100644 --- a/tools/buildman/toolchain.py +++ b/tools/buildman/toolchain.py @@ -18,6 +18,8 @@ import tools (PRIORITY_FULL_PREFIX, PRIORITY_PREFIX_GCC, PRIORITY_PREFIX_GCC_PATH, PRIORITY_CALC) = list(range(4)) +(VAR_CROSS_COMPILE, VAR_PATH, VAR_ARCH, VAR_MAKE_ARGS) = range(4) + # Simple class to collect links from a page class MyHTMLParser(HTMLParser): def __init__(self, arch): @@ -145,6 +147,30 @@ class Toolchain: return value + def GetEnvArgs(self, which): + """Get an environment variable/args value based on the the toolchain + + Args: + which: VAR_... value to get + + Returns: + Value of that environment variable or arguments + """ + wrapper = self.GetWrapper() + if which == VAR_CROSS_COMPILE: + return wrapper + os.path.join(self.path, self.cross) + elif which == VAR_PATH: + return self.path + elif which == VAR_ARCH: + return self.arch + elif which == VAR_MAKE_ARGS: + args = self.MakeArgs() + if args: + return ' '.join(args) + return '' + else: + raise ValueError('Unknown arg to GetEnvArgs (%d)' % which) + def MakeEnvironment(self, full_path): """Returns an environment for using the toolchain.