From patchwork Thu May 19 06:51:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 68095 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp3032976qge; Wed, 18 May 2016 23:53:44 -0700 (PDT) X-Received: by 10.28.20.144 with SMTP id 138mr11823188wmu.103.1463640824280; Wed, 18 May 2016 23:53:44 -0700 (PDT) Return-Path: Received: from theia.denx.de (theia.denx.de. [85.214.87.163]) by mx.google.com with ESMTP id gb9si15786036wjb.57.2016.05.18.23.53.44; Wed, 18 May 2016 23:53:44 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 85.214.87.163 as permitted sender) client-ip=85.214.87.163; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@nifty.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 85.214.87.163 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 926B3A761A; Thu, 19 May 2016 08:53:10 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id SBFi70SL23M2; Thu, 19 May 2016 08:53:10 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 0DE2CA7694; Thu, 19 May 2016 08:52:26 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 9CBB0A74FB for ; Thu, 19 May 2016 08:51:31 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 2eaRN2Y6mWxc for ; Thu, 19 May 2016 08:51:31 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from conuserg-12.nifty.com (conuserg-12.nifty.com [210.131.2.79]) by theia.denx.de (Postfix) with ESMTPS id 5F34FA7530 for ; Thu, 19 May 2016 08:51:26 +0200 (CEST) Received: from beagle.diag.org (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-12.nifty.com with ESMTP id u4J6p2Zm001067; Thu, 19 May 2016 15:51:09 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-12.nifty.com u4J6p2Zm001067 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1463640669; bh=ksNf28Mj8rF30MeG4exOpvKTR0Pq7yfDRqCtiLjv5zc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PHbocmnoVD7nYiDrGisN+xIpUvuSnN7M4DCNSiEWzPIztWbtdMu5FKnbmYY80dmXk /xutMiVHkvUubXSjcS3keVepsz+XnpyCGl/kPTu5wY9Fl9mFrN6V7dLpoJnm8izOC2 MArwQicTZ8M5RMcBk1PvL/Y70eCI8lzGQ4gu9u0G+1hYmwlm/ntCy/ihW/G8opqY81 ow5P6cU1JasyS0gfUEZ9uuPB7ZALSIDwRjTDnRoV/44zGLy10s2jLoMz3cnoauuUmx UX6v0XJvwmKXvXEPhGIvb0V599ExeO7IFwDOpPf66L1b7yZYdgMbx7FRHMjpM3VjZy knr6M8fvNTMQg== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: u-boot@lists.denx.de Date: Thu, 19 May 2016 15:51:57 +0900 Message-Id: <1463640729-25666-10-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1463640729-25666-1-git-send-email-yamada.masahiro@socionext.com> References: <1463640729-25666-1-git-send-email-yamada.masahiro@socionext.com> Cc: Joe Hershberger Subject: [U-Boot] [PATCH 09/21] tools: moveconfig: drop code for handling type and default value X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Now types and defalut values given by the input file are just ignored. Delete unnecessary code. Signed-off-by: Masahiro Yamada --- tools/moveconfig.py | 105 +++++++++++++++------------------------------------- 1 file changed, 29 insertions(+), 76 deletions(-) -- 1.9.1 _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot diff --git a/tools/moveconfig.py b/tools/moveconfig.py index ee0afbd..c452c7a 100755 --- a/tools/moveconfig.py +++ b/tools/moveconfig.py @@ -360,12 +360,11 @@ def cleanup_one_header(header_path, patterns, dry_run): if not i in matched: f.write(line) -def cleanup_headers(config_attrs, dry_run): +def cleanup_headers(configs, dry_run): """Delete config defines from board headers. Arguments: - config_attrs: A list of dictionaris, each of them includes the name, - the type, and the default value of the target config. + configs: A list of CONFIGs to remove. dry_run: make no changes, but still display log. """ while True: @@ -378,8 +377,7 @@ def cleanup_headers(config_attrs, dry_run): return patterns = [] - for config_attr in config_attrs: - config = config_attr['config'] + for config in configs: patterns.append(re.compile(r'#\s*define\s+%s\W' % config)) patterns.append(re.compile(r'#\s*undef\s+%s\W' % config)) @@ -421,17 +419,16 @@ class KconfigParser: re_arch = re.compile(r'CONFIG_SYS_ARCH="(.*)"') re_cpu = re.compile(r'CONFIG_SYS_CPU="(.*)"') - def __init__(self, config_attrs, options, progress, build_dir): + def __init__(self, configs, options, progress, build_dir): """Create a new parser. Arguments: - config_attrs: A list of dictionaris, each of them includes the name, - the type, and the default value of the target config. + configs: A list of CONFIGs to move. options: option flags. progress: A progress indicator build_dir: Build directory. """ - self.config_attrs = config_attrs + self.configs = configs self.options = options self.progress = progress self.build_dir = build_dir @@ -467,7 +464,7 @@ class KconfigParser: return CROSS_COMPILE.get(arch, None) - def parse_one_config(self, config_attr, dotconfig_lines, autoconf_lines): + def parse_one_config(self, config, dotconfig_lines, autoconf_lines): """Parse .config, defconfig, include/autoconf.mk for one config. This function looks for the config options in the lines from @@ -475,8 +472,7 @@ class KconfigParser: which action should be taken for this defconfig. Arguments: - config_attr: A dictionary including the name, the type, - and the default value of the target config. + config: CONFIG name to parse. dotconfig_lines: lines from the .config file. autoconf_lines: lines from the include/autoconf.mk file. @@ -484,7 +480,6 @@ class KconfigParser: A tupple of the action for this defconfig and the line matched for the config. """ - config = config_attr['config'] not_set = '# %s is not set' % config for line in dotconfig_lines: @@ -538,8 +533,8 @@ class KconfigParser: with open(autoconf_path) as f: autoconf_lines = f.readlines() - for config_attr in self.config_attrs: - result = self.parse_one_config(config_attr, dotconfig_lines, + for config in self.configs: + result = self.parse_one_config(config, dotconfig_lines, autoconf_lines) results.append(result) @@ -583,12 +578,11 @@ class Slot: for faster processing. """ - def __init__(self, config_attrs, options, progress, devnull, make_cmd): + def __init__(self, configs, options, progress, devnull, make_cmd): """Create a new process slot. Arguments: - config_attrs: A list of dictionaris, each of them includes the name, - the type, and the default value of the target config. + configs: A list of CONFIGs to move. options: option flags. progress: A progress indicator. devnull: A file object of '/dev/null'. @@ -599,8 +593,7 @@ class Slot: self.build_dir = tempfile.mkdtemp() self.devnull = devnull self.make_cmd = (make_cmd, 'O=' + self.build_dir) - self.parser = KconfigParser(config_attrs, options, progress, - self.build_dir) + self.parser = KconfigParser(configs, options, progress, self.build_dir) self.state = STATE_IDLE self.failed_boards = [] @@ -731,12 +724,11 @@ class Slots: """Controller of the array of subprocess slots.""" - def __init__(self, config_attrs, options, progress): + def __init__(self, configs, options, progress): """Create a new slots controller. Arguments: - config_attrs: A list of dictionaris containing the name, the type, - and the default value of the target CONFIG. + configs: A list of CONFIGs to move. options: option flags. progress: A progress indicator. """ @@ -745,7 +737,7 @@ class Slots: devnull = get_devnull() make_cmd = get_make_cmd() for i in range(options.jobs): - self.slots.append(Slot(config_attrs, options, progress, devnull, + self.slots.append(Slot(configs, options, progress, devnull, make_cmd)) def add(self, defconfig): @@ -803,23 +795,18 @@ class Slots: for board in failed_boards: f.write(board + '\n') -def move_config(config_attrs, options): +def move_config(configs, options): """Move config options to defconfig files. Arguments: - config_attrs: A list of dictionaris, each of them includes the name, - the type, and the default value of the target config. + configs: A list of CONFIGs to move. options: option flags """ - if len(config_attrs) == 0: + if len(configs) == 0: print 'Nothing to do. exit.' sys.exit(0) - print 'Move the following CONFIG options (jobs: %d)' % options.jobs - for config_attr in config_attrs: - print ' %s (type: %s, default: %s)' % (config_attr['config'], - config_attr['type'], - config_attr['default']) + print 'Move %s (jobs: %d)' % (', '.join(configs), options.jobs) if options.defconfigs: defconfigs = [line.strip() for line in open(options.defconfigs)] @@ -838,7 +825,7 @@ def move_config(config_attrs, options): defconfigs.append(os.path.join(dirpath, filename)) progress = Progress(len(defconfigs)) - slots = Slots(config_attrs, options, progress) + slots = Slots(configs, options, progress) # Main loop to process defconfig files: # Add a new subprocess into a vacant slot. @@ -862,7 +849,7 @@ def bad_recipe(filename, linenum, msg): sys.exit("%s: line %d: error : " % (filename, linenum) + msg) def parse_recipe(filename): - """Parse the recipe file and retrieve the config attributes. + """Parse the recipe file and retrieve CONFIGs to move. This function parses the given recipe file and gets the name, the type, and the default value of the target config options. @@ -870,10 +857,9 @@ def parse_recipe(filename): Arguments: filename: path to file to be parsed. Returns: - A list of dictionaris, each of them includes the name, - the type, and the default value of the target config. + A list of CONFIGs to move. """ - config_attrs = [] + configs = [] linenum = 1 for line in open(filename): @@ -889,43 +875,10 @@ def parse_recipe(filename): if not config.startswith('CONFIG_'): config = 'CONFIG_' + config - # sanity check of default values - if type == 'bool': - if not default in ('y', 'n'): - bad_recipe(filename, linenum, - "default for bool type must be either y or n") - elif type == 'tristate': - if not default in ('y', 'm', 'n'): - bad_recipe(filename, linenum, - "default for tristate type must be y, m, or n") - elif type == 'string': - if default[0] != '"' or default[-1] != '"': - bad_recipe(filename, linenum, - "default for string type must be surrounded by double-quotations") - elif type == 'int': - try: - int(default) - except: - bad_recipe(filename, linenum, - "type is int, but default value is not decimal") - elif type == 'hex': - if len(default) < 2 or default[:2] != '0x': - bad_recipe(filename, linenum, - "default for hex type must be prefixed with 0x") - try: - int(default, 16) - except: - bad_recipe(filename, linenum, - "type is hex, but default value is not hexadecimal") - else: - bad_recipe(filename, linenum, - "unsupported type '%s'. type must be one of bool, tristate, string, int, hex" - % type) - - config_attrs.append({'config': config, 'type': type, 'default': default}) + configs.append(config) linenum += 1 - return config_attrs + return configs def main(): try: @@ -965,7 +918,7 @@ def main(): parser.print_usage() sys.exit(1) - config_attrs = parse_recipe(args[0]) + configs = parse_recipe(args[0]) check_top_directory() @@ -974,9 +927,9 @@ def main(): update_cross_compile(options.color) if not options.cleanup_headers_only: - move_config(config_attrs, options) + move_config(configs, options) - cleanup_headers(config_attrs, options.dry_run) + cleanup_headers(configs, options.dry_run) if __name__ == '__main__': main()