
Make the processing of a slot more linear code compared to how it executes.
Signed-off-by: Joe Hershberger joe.hershberger@ni.com
---
Changes in v2: - New for v2
tools/moveconfig.py | 59 +++++++++++++++++++++++++++++++---------------------- 1 file changed, 35 insertions(+), 24 deletions(-)
diff --git a/tools/moveconfig.py b/tools/moveconfig.py index 2d29e1b..01350ce 100755 --- a/tools/moveconfig.py +++ b/tools/moveconfig.py @@ -197,9 +197,10 @@ CROSS_COMPILE = { }
STATE_IDLE = 0 -STATE_DEFCONFIG = 1 -STATE_AUTOCONF = 2 -STATE_SAVEDEFCONFIG = 3 +STATE_INIT = 1 +STATE_DEFCONFIG = 2 +STATE_AUTOCONF = 3 +STATE_SAVEDEFCONFIG = 4
ACTION_MOVE = 0 ACTION_NO_ENTRY = 1 @@ -633,12 +634,9 @@ class Slot: """ if self.state != STATE_IDLE: return False - cmd = list(self.make_cmd) - cmd.append(defconfig) - self.ps = subprocess.Popen(cmd, stdout=self.devnull, - stderr=subprocess.PIPE) + self.ps = None self.defconfig = defconfig - self.state = STATE_DEFCONFIG + self.state = STATE_INIT self.log = '' return True
@@ -661,6 +659,14 @@ class Slot: if self.state == STATE_IDLE: return True
+ if self.state == STATE_INIT: + cmd = list(self.make_cmd) + cmd.append(self.defconfig) + self.ps = subprocess.Popen(cmd, stdout=self.devnull, + stderr=subprocess.PIPE) + self.state = STATE_DEFCONFIG + return False + if self.ps.poll() == None: return False
@@ -673,6 +679,24 @@ class Slot: self.finish(False) return True
+ if self.state == STATE_DEFCONFIG: + self.cross_compile = self.parser.get_cross_compile() + if self.cross_compile is None: + self.log += color_text(self.options.color, COLOR_YELLOW, + "Compiler is missing. Do nothing.\n") + self.finish(False) + 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') + self.ps = subprocess.Popen(cmd, stdout=self.devnull, + stderr=subprocess.PIPE) + self.state = STATE_AUTOCONF + return False + if self.state == STATE_AUTOCONF: (updated, log) = self.parser.update_dotconfig() self.log += log @@ -708,22 +732,9 @@ class Slot: self.finish(True) return True
- self.cross_compile = self.parser.get_cross_compile() - if self.cross_compile is None: - self.log += color_text(self.options.color, COLOR_YELLOW, - "Compiler is missing. Do nothing.\n") - self.finish(False) - 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') - self.ps = subprocess.Popen(cmd, stdout=self.devnull, - stderr=subprocess.PIPE) - self.state = STATE_AUTOCONF - return False + # Undefined state! + self.finish(False) + return True
def finish(self, success): """Display log along with progress and go to the idle state.