All of lore.kernel.org
 help / color / mirror / Atom feed
From: Joe Hershberger <joe.hershberger@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 3/5] tools: moveconfig: simplify source tree switching
Date: Mon, 20 Jun 2016 16:33:07 -0500	[thread overview]
Message-ID: <CANr=Z=bmiHcKDjFPkkx5u+VGVsdLiDOU6-OoCpWS9ocsfXXBTw@mail.gmail.com> (raw)
In-Reply-To: <1465968834-17361-4-git-send-email-yamada.masahiro@socionext.com>

On Wed, Jun 15, 2016 at 12:33 AM, Masahiro Yamada
<yamada.masahiro@socionext.com> wrote:
> 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 <reference_src_dir>" 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 <yamada.masahiro@socionext.com>
> ---
>
>  tools/moveconfig.py | 22 +++++++++-------------
>  1 file changed, 9 insertions(+), 13 deletions(-)
>
> 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

This seems less clear to read. There is no current source dir? I think
you need a different name.

>                  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)]
> --
> 1.9.1
>
> _______________________________________________
> U-Boot mailing list
> U-Boot at lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot

  reply	other threads:[~2016-06-20 21:33 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-15  5:33 [U-Boot] [PATCH 0/5] tools: moveconfig: some more fix, cleanups, improvement Masahiro Yamada
2016-06-15  5:33 ` [U-Boot] [PATCH 1/5] tools: moveconfig: fix needless move for config with default 1 Masahiro Yamada
2016-06-20 21:25   ` Joe Hershberger
2016-06-15  5:33 ` [U-Boot] [PATCH 2/5] tools: moveconfig: change class WorkDir to class ReferenceSource Masahiro Yamada
2016-06-20 21:28   ` Joe Hershberger
2016-06-15  5:33 ` [U-Boot] [PATCH 3/5] tools: moveconfig: simplify source tree switching Masahiro Yamada
2016-06-20 21:33   ` Joe Hershberger [this message]
2016-06-21  1:53     ` Masahiro Yamada
2016-06-21 16:25       ` Joe Hershberger
2016-06-21 21:13         ` Masahiro Yamada
2016-06-21 21:41           ` Joe Hershberger
2016-06-15  5:33 ` [U-Boot] [PATCH 4/5] tools: moveconfig: simplify show_failed_boards() and show more info Masahiro Yamada
2016-06-20 21:35   ` Joe Hershberger
2016-06-15  5:33 ` [U-Boot] [PATCH 5/5] tools: moveconfig: show suspicious boards with possible misconversion Masahiro Yamada
2016-06-20 21:37   ` Joe Hershberger
2016-06-22  0:25 ` [U-Boot] [PATCH 0/5] tools: moveconfig: some more fix, cleanups, improvement Masahiro Yamada

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CANr=Z=bmiHcKDjFPkkx5u+VGVsdLiDOU6-OoCpWS9ocsfXXBTw@mail.gmail.com' \
    --to=joe.hershberger@gmail.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.