diff mbox

[U-Boot,12/21] tools: moveconfig: compute file paths just once

Message ID 1463640729-25666-13-git-send-email-yamada.masahiro@socionext.com
State Accepted
Commit 1f16992ee93595fa840aff55bdb722185cc31ca5
Delegated to: Masahiro Yamada
Headers show

Commit Message

Masahiro Yamada May 19, 2016, 6:52 a.m. UTC
The paths to .config, include/autoconf.mk, include/config/auto.conf
are not changed during the defconfig walk.  Compute them only once
when a new class instance is created.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---

 tools/moveconfig.py | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

Comments

Joe Hershberger May 24, 2016, 2:54 p.m. UTC | #1
On Thu, May 19, 2016 at 1:52 AM, Masahiro Yamada
<yamada.masahiro@socionext.com> wrote:
> The paths to .config, include/autoconf.mk, include/config/auto.conf
> are not changed during the defconfig walk.  Compute them only once
> when a new class instance is created.
>
> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>

Reviewed-by: Joe Hershberger <joe.hershberger@ni.com>
diff mbox

Patch

diff --git a/tools/moveconfig.py b/tools/moveconfig.py
index b509f49..9f38a08 100755
--- a/tools/moveconfig.py
+++ b/tools/moveconfig.py
@@ -428,7 +428,10 @@  class KconfigParser:
         self.configs = configs
         self.options = options
         self.progress = progress
-        self.build_dir = build_dir
+        self.dotconfig = os.path.join(build_dir, '.config')
+        self.autoconf = os.path.join(build_dir, 'include', 'autoconf.mk')
+        self.config_autoconf = os.path.join(build_dir, 'include', 'config',
+                                            'auto.conf')
 
     def get_cross_compile(self):
         """Parse .config file and return CROSS_COMPILE.
@@ -442,8 +445,7 @@  class KconfigParser:
         """
         arch = ''
         cpu = ''
-        dotconfig = os.path.join(self.build_dir, '.config')
-        for line in open(dotconfig):
+        for line in open(self.dotconfig):
             m = self.re_arch.match(line)
             if m:
                 arch = m.group(1)
@@ -520,14 +522,12 @@  class KconfigParser:
           defconfig: defconfig name.
         """
 
-        dotconfig_path = os.path.join(self.build_dir, '.config')
-        autoconf_path = os.path.join(self.build_dir, 'include', 'autoconf.mk')
         results = []
 
-        with open(dotconfig_path) as f:
+        with open(self.dotconfig) as f:
             dotconfig_lines = f.readlines()
 
-        with open(autoconf_path) as f:
+        with open(self.autoconf) as f:
             autoconf_lines = f.readlines()
 
         for config in self.configs:
@@ -558,13 +558,13 @@  class KconfigParser:
         print log,
         self.progress.show()
 
-        with open(dotconfig_path, 'a') as f:
+        with open(self.dotconfig, 'a') as f:
             for (action, value) in results:
                 if action == ACTION_MOVE:
                     f.write(value + '\n')
 
-        os.remove(os.path.join(self.build_dir, 'include', 'config', 'auto.conf'))
-        os.remove(autoconf_path)
+        os.remove(self.config_autoconf)
+        os.remove(self.autoconf)
 
 class Slot: