From patchwork Thu May 19 06:51:59 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 68098 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp3033189qge; Wed, 18 May 2016 23:54:27 -0700 (PDT) X-Received: by 10.28.234.130 with SMTP id g2mr12422357wmi.42.1463640867378; Wed, 18 May 2016 23:54:27 -0700 (PDT) Return-Path: Received: from theia.denx.de (theia.denx.de. [85.214.87.163]) by mx.google.com with ESMTP id vx5si15807898wjc.33.2016.05.18.23.54.27; Wed, 18 May 2016 23:54:27 -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 C0C72A769E; Thu, 19 May 2016 08:53: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 SIR7vg6aRNL5; Thu, 19 May 2016 08:53:31 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id A438BA76BE; Thu, 19 May 2016 08:52:35 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 0846BA7519 for ; Thu, 19 May 2016 08:52:01 +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 mODcV4i77RNv for ; Thu, 19 May 2016 08:52:00 +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 EEE30A75F5 for ; Thu, 19 May 2016 08:51:41 +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 u4J6p2Zo001067; Thu, 19 May 2016 15:51:11 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-12.nifty.com u4J6p2Zo001067 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1463640671; bh=mDUq/OIU2SHqr3/Us9Wa6dDNG+hfi63wSDYu57AsP9I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IF1silcXMUcgwg33wjMVm5tsrfffTm5c53rvh1jyzx/gRqGIj/XWPRNbhbsI5Aser UYolIlycEHsWcDF5JxPSSbKJd4bCkhlAQTl3vIKPYg7078ijvedVniNvw0MJiKfN9U l+XlweYS6LWhrhhJl1Mz3gQum75ny1optD4bKMH+KF2E1Rprj4/vVNm3soS1/EEtd7 27ifghzCjR4vZg2Jthtx3qnIWWwxbV7tovTKMbNkjj8XLvcihf/836xU0pCyR4NikG 829+DlhjgHWMyRRQwHqeKQKfPVcKlt9i6dJmwR1jJ635S18Dxg+UQs7sfHtgEqoHdl 2hWWsixT7jtMw== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: u-boot@lists.denx.de Date: Thu, 19 May 2016 15:51:59 +0900 Message-Id: <1463640729-25666-12-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 11/21] tools: moveconfig: add --undef option to move CONFIGs with default y 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" Since 96464badc794 ("moveconfig: Always run savedefconfig on the moved config"), this tool can not correctly move bool configs with the default value y. The reason is like follows: We are supposed to add the config entries in Kconfig for the options we are moving before running this tool. Otherwise, the moved options would all disappear during the "make savedefconfig" stage. Let's say we want to move CONFIG_FOO to Kconfig, making it an option with "default y". The first thing we need to do is to create an entry like follows: config FOO bool "foo" default y So, CONFIG_FOO=y will be set in the .config for every defconfig. Commit 7740f653e6b3 ("moveconfig: Ignore duplicate configs when moving") introduced KCONFIG_IGNORE_DUPLICATES to fix the false negative (= boards that should be converted to "=y" are misconverted to "not set") problem. With that commit, the CONFIGs in the .config are now duplicated to include/autoconf.mk unless they are defined to a different value or #undef'ed in the board header. It causes false positive problem this time; boards without #define/#undef CONFIG_FOO in their header should be converted to "not set", but misconverted to "=y" actually. This commit intends to handle such cases correctly. Anyway, we need to create a Kconfig entry beforehand to persevere savedefconfig. But, we do not want to propagate CONFIGs coming from "default y" to the include/autoconf.mk. To achieve it, the new option --undef is here! We can move bool option with default y in this way: 1. create an entry in Kconfig 2. run "tools/moveconfig.py --undef=CONFIG_FOO CONFIG_FOO" This option can appear multiple times in the command line, so that we can move multiple options at a time. Signed-off-by: Masahiro Yamada --- scripts/Makefile.autoconf | 3 ++- tools/moveconfig.py | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) -- 1.9.1 _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot diff --git a/scripts/Makefile.autoconf b/scripts/Makefile.autoconf index 01a739d..57c6e9f 100644 --- a/scripts/Makefile.autoconf +++ b/scripts/Makefile.autoconf @@ -39,7 +39,8 @@ UBOOTINCLUDE := \ -include $(srctree)/include/linux/kconfig.h c_flags := $(KBUILD_CFLAGS) $(KBUILD_CPPFLAGS) $(PLATFORM_CPPFLAGS) \ - $(UBOOTINCLUDE) $(NOSTDINC_FLAGS) + $(UBOOTINCLUDE) $(NOSTDINC_FLAGS) \ + $(KBUILD_MOVECONFIG_FLAGS) quiet_cmd_autoconf_dep = GEN $@ cmd_autoconf_dep = $(CC) -x c -DDO_DEPS_ONLY -M -MP $(c_flags) \ diff --git a/tools/moveconfig.py b/tools/moveconfig.py index 7ff6e71..b509f49 100755 --- a/tools/moveconfig.py +++ b/tools/moveconfig.py @@ -74,6 +74,27 @@ from the config headers (include/configs/*.h). 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 to move bool option with 'default y'? +----------------------------------------- + +Moving bool options with 'default y' is a bit tricky. In general use +of this tool, CONFIGs set in the .config are all duplicated to the +include/autoconf.mk, that is, CONFIGs with 'default y' Kconfig entry +will squelch the defines that came from the board header. In order to +know whether the board header defined those CONFIGs or not, you must +stop the target CONFIGs from being propagated to the include/autoconf.mk. +The option -U (--undef) can be used to do this. + +For example, if you want to move CONFIG_FOO and make it an option with +'default y', you need to do create an entry in Kconfig + + config FOO + bool "foo" + default y + +and then run + + $ tools/moveconfig.py -U CONFIG_FOO CONFIG_FOO How does it work? ----------------- @@ -134,6 +155,10 @@ Available options Specify the number of threads to run simultaneously. If not specified, the number of threads is the same as the number of CPU cores. + -U, --undef + Undefine the given CONFIG option when generating include/autoconf.mk. + This is generally useful to move a boolean option with "default y". + -v, --verbose Show any build errors as boards are built @@ -569,6 +594,13 @@ class Slot: self.state = STATE_IDLE self.failed_boards = [] + if options.undef: + undef_path = os.path.join(self.build_dir, 'undef.h') + with open(undef_path, 'w') as f: + for config in options.undef: + f.write('#undef %s\n' % config) + self.make_cmd += ("KBUILD_MOVECONFIG_FLAGS=-include %s" % undef_path, ) + def __del__(self): """Delete the working directory @@ -838,6 +870,9 @@ def main(): help='only cleanup the headers') parser.add_option('-j', '--jobs', type='int', default=cpu_count, help='the number of jobs to run simultaneously') + parser.add_option('-U', '--undef', action='append', default=[], + help='macro to undefine for autoconf processing' + \ + ' (can be given multiple times)') parser.add_option('-v', '--verbose', action='store_true', default=False, help='show any build errors as boards are built') parser.usage += ' CONFIG ...' @@ -852,6 +887,10 @@ def main(): configs = [ config if config.startswith('CONFIG_') else 'CONFIG_' + config for config in configs ] + # likewise for options.undef + options.undef = [ config if config.startswith('CONFIG_') + else 'CONFIG_' + config for config in options.undef ] + check_top_directory() check_clean_directory()