From patchwork Wed Jun 15 05:33:52 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 70085 Delivered-To: patch@linaro.org Received: by 10.140.106.246 with SMTP id e109csp2398793qgf; Tue, 14 Jun 2016 22:51:39 -0700 (PDT) X-Received: by 10.28.178.135 with SMTP id b129mr7803818wmf.60.1465969899699; Tue, 14 Jun 2016 22:51:39 -0700 (PDT) Return-Path: Received: from theia.denx.de (theia.denx.de. [85.214.87.163]) by mx.google.com with ESMTP id r185si3014689wmb.65.2016.06.14.22.51.39; Tue, 14 Jun 2016 22:51:39 -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 CDCD9A7640; Wed, 15 Jun 2016 07:49:39 +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 tln_OrPG7KHz; Wed, 15 Jun 2016 07:49:39 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 5DE77B3813; Wed, 15 Jun 2016 07:48:40 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id D6348A7517 for ; Wed, 15 Jun 2016 07:34:03 +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 JYEhweGkuosh for ; Wed, 15 Jun 2016 07:34:03 +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-08.nifty.com (conuserg-08.nifty.com [210.131.2.75]) by theia.denx.de (Postfix) with ESMTPS id 06D50A74F9 for ; Wed, 15 Jun 2016 07:33:01 +0200 (CEST) Received: from beagle.diag.org (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-08.nifty.com with ESMTP id u5F5WZeE021857; Wed, 15 Jun 2016 14:32:38 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-08.nifty.com u5F5WZeE021857 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1465968758; bh=eSiXp9udPWNLC7bu5LRv4S6MD0XWyxsDKDkJTO0ZGI8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YKZhPSpuy9lwiNZ0wzZtMFJQtUB8RC8utAYStfq2gBY+N2l2SnQcuT606a++Fii2b xz4VS6KFbXA3IDtCq566hpTMIg/GYuMff7miTQ5HB+o4JADLK6sKixm35ed3UGnkFD PP59+dCbqgnvNzzhei87V1rjr1lwiTYjFeuHZowDUFFuj1Tc80sJDfZfe8MoNDc1xI NSgoXq39SWUg2zU91+gds2WznVXgghM7qTcYL4KDij2io0+o2TiU/RoPKFjEze4xEV 7EuyGzmbFWXoDy4XEP+5hFZ5et2rNV9YIljtVisfZVqoowB8eyv3mysvHj+M8ZcaaG SGgJuYcwz/wEw== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: u-boot@lists.denx.de Date: Wed, 15 Jun 2016 14:33:52 +0900 Message-Id: <1465968834-17361-4-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1465968834-17361-1-git-send-email-yamada.masahiro@socionext.com> References: <1465968834-17361-1-git-send-email-yamada.masahiro@socionext.com> Cc: Joe Hershberger Subject: [U-Boot] [PATCH 3/5] tools: moveconfig: simplify source tree switching 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" The subprocess.Popen() does not change the child process's working directory if cwd=None is given. Let's exploit this fact to refactor the source directory handling. We no longer have to pass "-C " to the sub-process because self.current_src_dir tracks the source tree against which we want to run defconfig/autoconf. The flag self.use_git_ref is not necessary either because we can know the current state by checking whether the self.current_src_dir is a valid string or None. Signed-off-by: Masahiro Yamada --- tools/moveconfig.py | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 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 f4e2580..0e03751 100755 --- a/tools/moveconfig.py +++ b/tools/moveconfig.py @@ -645,7 +645,7 @@ class Slot: self.defconfig = defconfig self.log = '' - self.use_git_ref = True if self.options.git_ref else False + self.current_src_dir = self.reference_src_dir self.do_defconfig() return True @@ -674,13 +674,13 @@ class Slot: if self.ps.poll() != 0: self.handle_error() elif self.state == STATE_DEFCONFIG: - if self.options.git_ref and not self.use_git_ref: + if self.reference_src_dir and not self.current_src_dir: self.do_savedefconfig() else: self.do_autoconf() elif self.state == STATE_AUTOCONF: - if self.use_git_ref: - self.use_git_ref = False + if self.current_src_dir: + self.current_src_dir = None self.do_defconfig() else: self.do_savedefconfig() @@ -706,11 +706,9 @@ class Slot: cmd = list(self.make_cmd) cmd.append(self.defconfig) - if self.use_git_ref: - cmd.append('-C') - cmd.append(self.reference_src_dir) self.ps = subprocess.Popen(cmd, stdout=self.devnull, - stderr=subprocess.PIPE) + stderr=subprocess.PIPE, + cwd=self.current_src_dir) self.state = STATE_DEFCONFIG def do_autoconf(self): @@ -728,11 +726,9 @@ class Slot: cmd.append('CROSS_COMPILE=%s' % self.cross_compile) cmd.append('KCONFIG_IGNORE_DUPLICATES=1') cmd.append('include/config/auto.conf') - if self.use_git_ref: - cmd.append('-C') - cmd.append(self.reference_src_dir) self.ps = subprocess.Popen(cmd, stdout=self.devnull, - stderr=subprocess.PIPE) + stderr=subprocess.PIPE, + cwd=self.current_src_dir) self.state = STATE_AUTOCONF def do_savedefconfig(self): @@ -934,7 +930,7 @@ def move_config(configs, options): reference_src = ReferenceSource(options.git_ref) reference_src_dir = reference_src.get_dir() else: - reference_src_dir = '' + reference_src_dir = None if options.defconfigs: defconfigs = [line.strip() for line in open(options.defconfigs)]