From patchwork Thu May 19 06:51:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 68085 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp3032262qge; Wed, 18 May 2016 23:51:53 -0700 (PDT) X-Received: by 10.28.9.137 with SMTP id 131mr11566664wmj.13.1463640713602; Wed, 18 May 2016 23:51:53 -0700 (PDT) Return-Path: Received: from theia.denx.de (theia.denx.de. [85.214.87.163]) by mx.google.com with ESMTP id 79si38633440wmi.27.2016.05.18.23.51.53; Wed, 18 May 2016 23:51:53 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 85.214.87.163 as permitted sender) client-ip=85.214.87.163; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@nifty.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 85.214.87.163 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id BE0E9A7519; Thu, 19 May 2016 08:51:48 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id SCDkh0yd4O1S; Thu, 19 May 2016 08:51:48 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id A6488A75C5; Thu, 19 May 2016 08:51:38 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id B5470A7498 for ; Thu, 19 May 2016 08:51:30 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id oHYpnW0ttHWB for ; Thu, 19 May 2016 08:51:30 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from conuserg-12.nifty.com (conuserg-12.nifty.com [210.131.2.79]) by theia.denx.de (Postfix) with ESMTPS id A3893A74E0 for ; Thu, 19 May 2016 08:51:26 +0200 (CEST) Received: from beagle.diag.org (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-12.nifty.com with ESMTP id u4J6p2Zi001067; Thu, 19 May 2016 15:51:06 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-12.nifty.com u4J6p2Zi001067 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1463640666; bh=56CMu4t5FSFC3QLXQuj9U19LxAQD6ZsKlT8bpByIWOg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OgB56J9b72Aw0RORGhoaLe7DkUlijx+AhfBO7ACxG92x1l8uvHSyzpwphuhNDplnE d6fXCSAIbGNEVOIb+S0Q74xoT+GYF5b5POfeOmYG0Csio+eYzO5LLWauGPkTN6voJy 7CRu50WD7m8p0sczK7+Sgo6Aj6y/4pBpBQ/mjpDzjCLQaan5K0fYVno/2DPJTUWJCE sGRjwCaAKeF9R/ZzbSsxQ2FWCKuEDAGDEEhyuPlGAWNusPn+LYTeqbLBUiIc3WJXTX YNhRMxcqsVNIcQswDmBHPI3kYqgHrJLwDG0z2yG5MF3GmkjcsrVA3MLmqex90TK6A3 ENVALxmHShQfQ== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: u-boot@lists.denx.de Date: Thu, 19 May 2016 15:51:53 +0900 Message-Id: <1463640729-25666-6-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1463640729-25666-1-git-send-email-yamada.masahiro@socionext.com> References: <1463640729-25666-1-git-send-email-yamada.masahiro@socionext.com> Cc: Joe Hershberger Subject: [U-Boot] [PATCH 05/21] tools: moveconfig: check compilers before starting defconfig walk X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Since commit 25400090b1e2 ("moveconfig: Print a message for missing compiler"), this tool parses error messages generated by "make include/config/auto.conf" every time an error occurs in order to detect missing compiler. Instead of that, we can look for compilers in the PATH environment only once before starting the defconfig walk. If specified compilers are missing, "make include/config/auto.conf" will apparently fail for corresponding architectures. So, the tool can just report "Compiler is missing." and skip those boards. Signed-off-by: Masahiro Yamada --- tools/moveconfig.py | 71 ++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 48 insertions(+), 23 deletions(-) -- 1.9.1 _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot diff --git a/tools/moveconfig.py b/tools/moveconfig.py index ce8245a..7e916c2 100755 --- a/tools/moveconfig.py +++ b/tools/moveconfig.py @@ -82,7 +82,12 @@ It looks like one of the followings: This config option was not found in the config header. Nothing to do. - - Failed to process. Skip. + - Compiler is missing. Do nothing. + The compiler specified for this architecture was not found + in your PATH environment. + (If -e option is passed, the tool exits immediately.) + + - Failed to process. An error occurred during processing this defconfig. Skipped. (If -e option is passed, the tool exits immediately on error.) @@ -272,7 +277,7 @@ def log_msg(color_enabled, color, defconfig, msg): return defconfig[:-len('_defconfig')].ljust(37) + ': ' + \ color_text(color_enabled, color, msg) + '\n' -def update_cross_compile(): +def update_cross_compile(color_enabled): """Update per-arch CROSS_COMPILE via environment variables The default CROSS_COMPILE values are available @@ -286,6 +291,9 @@ def update_cross_compile(): export CROSS_COMPILE_ARM=... export CROSS_COMPILE_POWERPC=... + + Then, this function checks if specified compilers really exist in your + PATH environment. """ archs = [] @@ -299,8 +307,20 @@ def update_cross_compile(): for arch in archs: env = 'CROSS_COMPILE_' + arch.upper() cross_compile = os.environ.get(env) - if cross_compile: - CROSS_COMPILE[arch] = cross_compile + if not cross_compile: + cross_compile = CROSS_COMPILE.get(arch, '') + + for path in os.environ["PATH"].split(os.pathsep): + gcc_path = os.path.join(path, cross_compile + 'gcc') + if os.path.isfile(gcc_path) and os.access(gcc_path, os.X_OK): + break + else: + print >> sys.stderr, color_text(color_enabled, COLOR_YELLOW, + 'warning: %sgcc: not found in PATH. %s architecture boards will be skipped' + % (cross_compile, arch)) + cross_compile = None + + CROSS_COMPILE[arch] = cross_compile def cleanup_one_header(header_path, patterns, dry_run): """Clean regex-matched lines away from a file. @@ -387,6 +407,10 @@ class KconfigParser: Returns: A string storing the compiler prefix for the architecture. + Return a NULL string for architectures that do not require + compiler prefix (Sandbox and native build is the case). + Return None if the specified compiler is missing in your PATH. + Caller should distinguish '' and None. """ arch = '' cpu = '' @@ -400,13 +424,14 @@ class KconfigParser: if m: cpu = m.group(1) - assert arch, 'Error: arch is not defined in %s' % defconfig + if not arch: + return None # fix-up for aarch64 if arch == 'arm' and cpu == 'armv8': arch = 'aarch64' - return CROSS_COMPILE.get(arch, '') + return CROSS_COMPILE.get(arch, None) def parse_one_config(self, config_attr, defconfig_lines, autoconf_lines): """Parse .config, defconfig, include/autoconf.mk for one config. @@ -606,21 +631,12 @@ class Slot: return False if self.ps.poll() != 0: - errmsg = 'Failed to process.' - errout = self.ps.stderr.read() - if errout.find('gcc: command not found') != -1: - errmsg = 'Compiler not found (' - errmsg += color_text(self.options.color, COLOR_YELLOW, - self.cross_compile) - errmsg += color_text(self.options.color, COLOR_LIGHT_RED, - ')') - print >> sys.stderr, log_msg(self.options.color, - COLOR_LIGHT_RED, - self.defconfig, - errmsg), + print >> sys.stderr, log_msg(self.options.color, COLOR_LIGHT_RED, + self.defconfig, "Failed to process."), if self.options.verbose: print >> sys.stderr, color_text(self.options.color, - COLOR_LIGHT_CYAN, errout) + COLOR_LIGHT_CYAN, + self.ps.stderr.read()) if self.options.exit_on_error: sys.exit("Exit on error.") # If --exit-on-error flag is not set, skip this board and continue. @@ -651,15 +667,24 @@ class Slot: return True self.cross_compile = self.parser.get_cross_compile() + if self.cross_compile is None: + print >> sys.stderr, log_msg(self.options.color, COLOR_YELLOW, + self.defconfig, + "Compiler is missing. Do nothing."), + if self.options.exit_on_error: + sys.exit("Exit on error.") + # If --exit-on-error flag is not set, skip this board and continue. + # Record the failed board. + self.failed_boards.append(self.defconfig) + self.state = STATE_IDLE + return True + cmd = list(self.make_cmd) if self.cross_compile: cmd.append('CROSS_COMPILE=%s' % self.cross_compile) cmd.append('KCONFIG_IGNORE_DUPLICATES=1') cmd.append('include/config/auto.conf') - """This will be screen-scraped, so be sure the expected text will be - returned consistently on every machine by setting LANG=C""" self.ps = subprocess.Popen(cmd, stdout=self.devnull, - env=dict(os.environ, LANG='C'), stderr=subprocess.PIPE) self.state = STATE_AUTOCONF return False @@ -907,7 +932,7 @@ def main(): check_top_directory() - update_cross_compile() + update_cross_compile(options.color) if not options.cleanup_headers_only: move_config(config_attrs, options)