From mboxrd@z Thu Jan 1 00:00:00 1970 From: Joe Hershberger Date: Thu, 14 May 2015 13:03:44 -0500 Subject: [U-Boot] [PATCH v3 10/10] moveconfig: Add a switch to only cleanup headers In-Reply-To: References: <1431364998-2905-1-git-send-email-joe.hershberger@ni.com> <1431556137-8426-1-git-send-email-joe.hershberger@ni.com> <1431556137-8426-10-git-send-email-joe.hershberger@ni.com> Message-ID: List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hi Masahiro-san, On Thu, May 14, 2015 at 9:51 AM, Masahiro Yamada wrote: > 2015-05-14 7:28 GMT+09:00 Joe Hershberger : >> In some case you may want to only cleanup the headers. Make it possible >> without waiting for all boards to compile. >> >> Signed-off-by: Joe Hershberger >> >> --- >> >> Changes in v3: >> -New for version 3 >> >> Changes in v2: None >> >> tools/moveconfig.py | 83 ++++++++++++++++++++++++++++------------------------- >> 1 file changed, 44 insertions(+), 39 deletions(-) >> >> diff --git a/tools/moveconfig.py b/tools/moveconfig.py >> index bb087d4..d63f47f 100755 >> --- a/tools/moveconfig.py >> +++ b/tools/moveconfig.py >> @@ -412,48 +412,50 @@ class Slots: >> def move_config(config_attrs, options): >> check_top_directory() >> >> - for config_attr in config_attrs: >> - print 'Moving %s (type: %s, default: %s, no_spl: %s)' % ( >> - config_attr['config'], >> - config_attr['type'], >> - config_attr['default'], >> - config_attr['no_spl_support']) >> - print '%d jobs...' % options.jobs >> - >> - if options.defconfigs: >> - defconfigs = [line.strip() for line in open(options.defconfigs, 'r')] >> - else: >> - # All the defconfig files to be processed >> - defconfigs = [] >> - for (dirpath, dirnames, filenames) in os.walk('configs'): >> - dirpath = dirpath[len('configs') + 1:] >> - for filename in fnmatch.filter(filenames, '*_defconfig'): >> - if fnmatch.fnmatch(filename, '.*'): >> - continue >> - defconfigs.append(os.path.join(dirpath, filename)) >> - >> - """Clean up any previous log of failed moves""" >> - if os.path.exists('moveconfig.failed'): >> - os.remove('moveconfig.failed') >> - >> - slots = Slots(config_attrs, options) >> - >> - # Main loop to process defconfig files: >> - # Add a new subprocess into a vacant slot. >> - # Sleep if there is no available slot. >> - for i, defconfig in enumerate(defconfigs): >> - while not slots.add(defconfig, i, len(defconfigs)): >> - while not slots.available(): >> - # No available slot: sleep for a while >> - time.sleep(SLEEP_TIME) >> - >> - # wait until all the subprocesses finish >> - while not slots.empty(): >> - time.sleep(SLEEP_TIME) >> + if not options.clean_only: >> + for config_attr in config_attrs: >> + print 'Moving %s (type: %s, default: %s, no_spl: %s)' % ( >> + config_attr['config'], >> + config_attr['type'], >> + config_attr['default'], >> + config_attr['no_spl_support']) >> + print '%d jobs...' % options.jobs >> + >> + if options.defconfigs: >> + defconfigs = [line.strip() for line in >> + open(options.defconfigs, 'r')] >> + else: >> + # All the defconfig files to be processed >> + defconfigs = [] >> + for (dirpath, dirnames, filenames) in os.walk('configs'): >> + dirpath = dirpath[len('configs') + 1:] >> + for filename in fnmatch.filter(filenames, '*_defconfig'): >> + if fnmatch.fnmatch(filename, '.*'): >> + continue >> + defconfigs.append(os.path.join(dirpath, filename)) >> + >> + """Clean up any previous log of failed moves""" >> + if os.path.exists('moveconfig.failed'): >> + os.remove('moveconfig.failed') >> + >> + slots = Slots(config_attrs, options) >> + >> + # Main loop to process defconfig files: >> + # Add a new subprocess into a vacant slot. >> + # Sleep if there is no available slot. >> + for i, defconfig in enumerate(defconfigs): >> + while not slots.add(defconfig, i, len(defconfigs)): >> + while not slots.available(): >> + # No available slot: sleep for a while >> + time.sleep(SLEEP_TIME) >> + >> + # wait until all the subprocesses finish >> + while not slots.empty(): >> + time.sleep(SLEEP_TIME) >> >> cleanup_headers(config_attrs) >> >> - if os.path.exists('moveconfig.failed'): >> + if (not options.clean_only) & os.path.exists('moveconfig.failed'): >> print '!!! Some boards were not processed; move the config manually.' >> print '!!! The list of failed boards are saved in moveconfig.failed' >> print > > > I am OK with this feature, but this 'if' statement ranges over many code lines. > > Perhaps, moving the cleanup_headers to the main function is simpler? > > > def main(): > [snip] > > if not options.clean_only: > move_config(config_attrs, options) > > cleanup_headers(config_attrs) OK. -Joe