From patchwork Mon Jul 25 10:15:29 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 72705 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp1064330qga; Mon, 25 Jul 2016 03:14:54 -0700 (PDT) X-Received: by 10.194.235.229 with SMTP id up5mr15801011wjc.69.1469441694001; Mon, 25 Jul 2016 03:14:54 -0700 (PDT) Return-Path: Received: from theia.denx.de (theia.denx.de. [85.214.87.163]) by mx.google.com with ESMTP id hq7si14151522wjb.234.2016.07.25.03.14.53; Mon, 25 Jul 2016 03:14:53 -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 6A22AA778C; Mon, 25 Jul 2016 12:14:43 +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 7YD57fasm9nb; Mon, 25 Jul 2016 12:14:43 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 37002A7795; Mon, 25 Jul 2016 12:14:42 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 384D8A77A2 for ; Mon, 25 Jul 2016 12:14:23 +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 U5IwpS3mhuAV for ; Mon, 25 Jul 2016 12:14:23 +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-11.nifty.com (conuserg-11.nifty.com [210.131.2.78]) by theia.denx.de (Postfix) with ESMTPS id 47A88A778F for ; Mon, 25 Jul 2016 12:14:17 +0200 (CEST) Received: from beagle.diag.org (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-11.nifty.com with ESMTP id u6PADhxK021296; Mon, 25 Jul 2016 19:13:48 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-11.nifty.com u6PADhxK021296 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1469441628; bh=x/rVbz5IeSnbFOYeM7KyBzbDX/3XgsvYO0ci6DBraPo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FVXD7AMPOmjEyGXEd8Zn3fZ5mBoDqHjn2gDrpdGgNnq1yb836mcNbIzYciHy8cthW VEcqiomFyQ/nbX7nwp9coSFlAgdXPsfVV2o8pGYHGlBykUi1obry/W+SSw9EAHmviq gswzwkzQP6ftkPWVT3CeuUAY6fv+XJWQe+mUJCMOaWj5ZS0maqYN2dnef2CSdnThJJ idrJvaVZGR5o08yd2ia+QTHymHotDmpxCfWnS4FG9waavdALRK+g7ZUzjG2DKEQiAN stZ4Tgy/rKpL8aUhvRof2F4whXpLVtwV2ciO/FsTZk1ZgsQ91y8++ssmyoJhKIKGDl vamH7UAZCyvQA== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: u-boot@lists.denx.de Date: Mon, 25 Jul 2016 19:15:29 +0900 Message-Id: <1469441729-5817-9-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1469441729-5817-1-git-send-email-yamada.masahiro@socionext.com> References: <1469441729-5817-1-git-send-email-yamada.masahiro@socionext.com> Cc: Tom Rini , Joe Hershberger Subject: [U-Boot] [PATCH v2 8/8] tools: moveconfig: support CONFIG_SYS_EXTRA_OPTIONS cleaning 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 mostly move config options from board header files to Kconfig, but sometimes config defines come from CONFIG_SYS_EXTRA_OPTIONS. Historically, CONFIG_SYS_EXTRA_OPTIONS originates in boards.cfg, which was used as a central database of configuration prior to the Kconfig conversion. Now, we want to migrate to primary entries in Kconfig rather than option list in CONFIG_SYS_EXTRA_OPTIONS, so it should be helpful to have the tool to cleanup CONFIG_SYS_EXTRA_OPTIONS automatically. Signed-off-by: Masahiro Yamada --- Changes in v2: - Make diffing into a helper function tools/moveconfig.py | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) -- 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 3b7499b..e7b245c 100755 --- a/tools/moveconfig.py +++ b/tools/moveconfig.py @@ -494,6 +494,79 @@ def cleanup_headers(configs, options): cleanup_one_header(os.path.join(dirpath, filename), patterns, options) +def cleanup_one_extra_option(defconfig_path, configs, options): + """Delete config defines in CONFIG_SYS_EXTRA_OPTIONS in one defconfig file. + + Arguments: + defconfig_path: path to the cleaned defconfig file. + configs: A list of CONFIGs to remove. + options: option flags. + """ + + start = 'CONFIG_SYS_EXTRA_OPTIONS="' + end = '"\n' + + with open(defconfig_path) as f: + lines = f.readlines() + + for i, line in enumerate(lines): + if line.startswith(start) and line.endswith(end): + break + else: + # CONFIG_SYS_EXTRA_OPTIONS was not found in this defconfig + return + + old_tokens = line[len(start):-len(end)].split(',') + new_tokens = [] + + for token in old_tokens: + pos = token.find('=') + if not (token[:pos] if pos >= 0 else token) in configs: + new_tokens.append(token) + + if new_tokens == old_tokens: + return + + tolines = copy.copy(lines) + + if new_tokens: + tolines[i] = start + ','.join(new_tokens) + end + else: + tolines.pop(i) + + show_diff(lines, tolines, defconfig_path, options.color) + + if options.dry_run: + return + + with open(defconfig_path, 'w') as f: + for line in tolines: + f.write(line) + +def cleanup_extra_options(configs, options): + """Delete config defines in CONFIG_SYS_EXTRA_OPTIONS in defconfig files. + + Arguments: + configs: A list of CONFIGs to remove. + options: option flags. + """ + while True: + choice = raw_input('Clean up CONFIG_SYS_EXTRA_OPTIONS? [y/n]: ').lower() + print choice + if choice == 'y' or choice == 'n': + break + + if choice == 'n': + return + + configs = [ config[len('CONFIG_'):] for config in configs ] + + defconfigs = get_all_defconfigs() + + for defconfig in defconfigs: + cleanup_one_extra_option(os.path.join('configs', defconfig), configs, + options) + ### classes ### class Progress: @@ -1160,6 +1233,7 @@ def main(): if configs: cleanup_headers(configs, options) + cleanup_extra_options(configs, options) if __name__ == '__main__': main()