From patchwork Thu May 19 06:51:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 68083 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp3032158qge; Wed, 18 May 2016 23:51:35 -0700 (PDT) X-Received: by 10.194.133.135 with SMTP id pc7mr11639710wjb.49.1463640695826; Wed, 18 May 2016 23:51:35 -0700 (PDT) Return-Path: Received: from theia.denx.de (theia.denx.de. [85.214.87.163]) by mx.google.com with ESMTP id l14si16409742wmb.12.2016.05.18.23.51.35; Wed, 18 May 2016 23:51:35 -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 81D97A74E9; Thu, 19 May 2016 08:51:34 +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 qJfuTMztfczR; Thu, 19 May 2016 08:51:34 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 2697AA74DA; Thu, 19 May 2016 08:51:34 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 57806A7528 for ; Thu, 19 May 2016 08:51:30 +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 X5akYGAvtGJh for ; Thu, 19 May 2016 08:51:30 +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 960F7A74DA 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 u4J6p2Zn001067; Thu, 19 May 2016 15:51:10 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-12.nifty.com u4J6p2Zn001067 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1463640670; bh=vXZsCngWYu77vdI4Hz1/XDPKz3bd6mE4hIvp3nO7wV0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Io18YHQCHPlAvkATW/BMYNpdmASqk8SdlycaUQlaanTqBxHAgEPAbdeXIh5khI41H Ar6k32DvI6i5gRDybVY4nO+mzeHglvTdNryZVPLQWS2KhO38Jglo3ubOqHdILGOJcn GDDpoEHzLdR5NCxBQ/rmMUt2OV8oAzwmlbA3z5muI3akJ6mnzrVgXVxs2erOOxzPHa mQMK1LgCWguxLVfIA4I7sTunswsOZVN0WKRKP/8dLIv2gB63YT9X/58B+A7Zk3qSSh C5AR7pD34b4oc8FLe+QZk421P8rnscEQthS+nxTfVNkM9MRrMKZwZe3wFQKIzhPfaQ 7MxCjf1GScFxQ== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: u-boot@lists.denx.de Date: Thu, 19 May 2016 15:51:58 +0900 Message-Id: <1463640729-25666-11-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 10/21] tools: moveconfig: allow to give CONFIG names as argument directly 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" We still pass the input file with CONFIG name, type, default value in each line, but the last two fields are just ignored by the tool. So, let's deprecate the input file and allow users to give CONFIG names directly from the command line. The types and default values are automatically detected and handled nicely by the tool. Going forward, we can use this tool more easily like: tools/moveconfig.py CONFIG_FOO CONFIG_BAR Update the documentation and fix some typos I noticed while I was working on. Signed-off-by: Masahiro Yamada --- tools/moveconfig.py | 108 ++++++++++------------------------------------------ 1 file changed, 20 insertions(+), 88 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 c452c7a..7ff6e71 100755 --- a/tools/moveconfig.py +++ b/tools/moveconfig.py @@ -17,44 +17,16 @@ This tool intends to help this tremendous work. Usage ----- -This tool takes one input file. (let's say 'recipe' file here.) -The recipe describes the list of config options you want to move. -Each line takes the form: - -(the fields must be separated with whitespaces.) - - is the name of config option. - - is the type of the option. It must be one of bool, tristate, -string, int, and hex. - - is the default value of the option. It must be appropriate -value corresponding to the option type. It must be either y or n for -the bool type. Tristate options can also take m (although U-Boot has -not supported the module feature). - -You can add two or more lines in the recipe file, so you can move -multiple options at once. - -Let's say, for example, you want to move CONFIG_CMD_USB and -CONFIG_SYS_TEXT_BASE. - -The type should be bool, hex, respectively. So, the recipe file -should look like this: - - $ cat recipe - CONFIG_CMD_USB bool n - CONFIG_SYS_TEXT_BASE hex 0x00000000 - -Next you must edit the Kconfig to add the menu entries for the configs +First, you must edit the Kconfig to add the menu entries for the configs you are moving. -And then run this tool giving the file name of the recipe +And then run this tool giving CONFIG names you want to move. +For example, if you want to move CONFIG_CMD_USB and CONFIG_SYS_TEXT_BASE, +simply type as follows: - $ tools/moveconfig.py recipe + $ tools/moveconfig.py CONFIG_CMD_USB CONFIG_SYS_TEXT_BASE -The tool walks through all the defconfig files to move the config -options specified by the recipe file. +The tool walks through all the defconfig files and move the given CONFIGs. The log is also displayed on the terminal. @@ -103,19 +75,19 @@ It just uses the regex method, so you should not rely on it. Just in case, please do 'git diff' to see what happened. -How does it works? ------------------- +How does it work? +----------------- This tool runs configuration and builds include/autoconf.mk for every defconfig. The config options defined in Kconfig appear in the .config file (unless they are hidden because of unmet dependency.) On the other hand, the config options defined by board headers are seen in include/autoconf.mk. The tool looks for the specified options in both -of them to decide the appropriate action for the options. If the option -is found in the .config or the value is the same as the specified default, -the option does not need to be touched. If the option is found in -include/autoconf.mk, but not in the .config, and the value is different -from the default, the tools adds the option to the defconfig. +of them to decide the appropriate action for the options. If the given +config option is found in the .config, but its value does not match the +one from the board header, the config option in the .config is replaced +with the define in the board header. Then, the .config is synced by +"make savedefconfig" and the defconfig is updated with it. For faster processing, this tool handles multi-threading. It creates separate build directories where the out-of-tree build is run. The @@ -148,7 +120,7 @@ Available options Specify a file containing a list of defconfigs to move -n, --dry-run - Peform a trial run that does not make any changes. It is useful to + Perform a trial run that does not make any changes. It is useful to see what is going to happen before one actually runs it. -e, --exit-on-error @@ -844,42 +816,6 @@ def move_config(configs, options): print '' slots.show_failed_boards() -def bad_recipe(filename, linenum, msg): - """Print error message with the file name and the line number and exit.""" - sys.exit("%s: line %d: error : " % (filename, linenum) + msg) - -def parse_recipe(filename): - """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. - - Arguments: - filename: path to file to be parsed. - Returns: - A list of CONFIGs to move. - """ - configs = [] - linenum = 1 - - for line in open(filename): - tokens = line.split() - if len(tokens) != 3: - bad_recipe(filename, linenum, - "%d fields in this line. Each line must contain 3 fields" - % len(tokens)) - - (config, type, default) = tokens - - # prefix the option name with CONFIG_ if missing - if not config.startswith('CONFIG_'): - config = 'CONFIG_' + config - - configs.append(config) - linenum += 1 - - return configs - def main(): try: cpu_count = multiprocessing.cpu_count() @@ -904,21 +840,17 @@ def main(): help='the number of jobs to run simultaneously') parser.add_option('-v', '--verbose', action='store_true', default=False, help='show any build errors as boards are built') - parser.usage += ' recipe_file\n\n' + \ - 'The recipe_file should describe config options you want to move.\n' + \ - 'Each line should contain config_name, type, default_value\n\n' + \ - 'Example:\n' + \ - 'CONFIG_FOO bool n\n' + \ - 'CONFIG_BAR int 100\n' + \ - 'CONFIG_BAZ string "hello"\n' + parser.usage += ' CONFIG ...' - (options, args) = parser.parse_args() + (options, configs) = parser.parse_args() - if len(args) != 1: + if len(configs) == 0: parser.print_usage() sys.exit(1) - configs = parse_recipe(args[0]) + # prefix the option name with CONFIG_ if missing + configs = [ config if config.startswith('CONFIG_') else 'CONFIG_' + config + for config in configs ] check_top_directory()