diff options
author | Masahiro Yamada <yamada.m@jp.panasonic.com> | 2014-08-25 12:39:48 +0900 |
---|---|---|
committer | Tom Rini <trini@ti.com> | 2014-08-28 17:18:49 -0400 |
commit | 9a65cb7ffe434236e8cdcb57d3937cef2828f4d0 (patch) | |
tree | ab6470302d9e6c71124c1f0f4222887c52eaf08d /tools/genboardscfg.py | |
parent | d1bf4afda6d6833e428956ee0dbba9f34e644cca (diff) | |
download | u-boot-imx-9a65cb7ffe434236e8cdcb57d3937cef2828f4d0.zip u-boot-imx-9a65cb7ffe434236e8cdcb57d3937cef2828f4d0.tar.gz u-boot-imx-9a65cb7ffe434236e8cdcb57d3937cef2828f4d0.tar.bz2 |
tools/genboardscfg.py: improve performance
I guess some developers are already getting sick of this tool
because it generally takes a few minites to generate the boards.cfg
on a reasonable computer.
The idea popped up on my mind was to skip Makefiles and
to run script/kconfig/conf directly.
This tool should become about 4 times faster.
You might still not be satisfied, but better than doing nothing.
Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Acked-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'tools/genboardscfg.py')
-rwxr-xr-x | tools/genboardscfg.py | 39 |
1 files changed, 33 insertions, 6 deletions
diff --git a/tools/genboardscfg.py b/tools/genboardscfg.py index c0d7b94..13dbc63 100755 --- a/tools/genboardscfg.py +++ b/tools/genboardscfg.py @@ -30,7 +30,7 @@ CONFIG_DIR = 'configs' REFORMAT_CMD = [os.path.join('tools', 'reformat.py'), '-i', '-d', '-', '-s', '8'] SHOW_GNU_MAKE = 'scripts/show-gnu-make' -SLEEP_TIME=0.03 +SLEEP_TIME=0.003 COMMENT_BLOCK = '''# # List of boards @@ -312,13 +312,20 @@ class Slot: Arguments: output: File object which the result is written to maintainers_database: An instance of class MaintainersDatabase + devnull: file object of 'dev/null' + make_cmd: the command name of Make """ - self.occupied = False self.build_dir = tempfile.mkdtemp() self.devnull = devnull - self.make_cmd = make_cmd + self.ps = subprocess.Popen([make_cmd, 'O=' + self.build_dir, + 'allnoconfig'], stdout=devnull) + self.occupied = True self.parser = DotConfigParser(self.build_dir, output, maintainers_database) + self.env = os.environ.copy() + self.env['srctree'] = os.getcwd() + self.env['UBOOTVERSION'] = 'dummy' + self.env['KCONFIG_OBJDIR'] = '' def __del__(self): """Delete the working directory""" @@ -341,13 +348,31 @@ class Slot: """ if self.occupied: return False - o = 'O=' + self.build_dir - self.ps = subprocess.Popen([self.make_cmd, o, defconfig], - stdout=self.devnull) + + with open(os.path.join(self.build_dir, '.tmp_defconfig'), 'w') as f: + for line in open(os.path.join(CONFIG_DIR, defconfig)): + colon = line.find(':CONFIG_') + if colon == -1: + f.write(line) + else: + f.write(line[colon + 1:]) + + self.ps = subprocess.Popen([os.path.join('scripts', 'kconfig', 'conf'), + '--defconfig=.tmp_defconfig', 'Kconfig'], + stdout=self.devnull, + cwd=self.build_dir, + env=self.env) + self.defconfig = defconfig self.occupied = True return True + def wait(self): + """Wait until the current subprocess finishes.""" + while self.occupied and self.ps.poll() == None: + time.sleep(SLEEP_TIME) + self.occupied = False + def poll(self): """Check if the subprocess is running and invoke the .config parser if the subprocess is terminated. @@ -385,6 +410,8 @@ class Slots: for i in range(jobs): self.slots.append(Slot(output, maintainers_database, devnull, make_cmd)) + for slot in self.slots: + slot.wait() def add(self, defconfig): """Add a new subprocess if a vacant slot is available. |