[U-Boot] [PATCH 11/21] tools: moveconfig: add --undef option to move CONFIGs with default y
Masahiro Yamada
yamada.masahiro at socionext.com
Thu May 19 08:51:59 CEST 2016
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 <yamada.masahiro at socionext.com>
---
scripts/Makefile.autoconf | 3 ++-
tools/moveconfig.py | 39 +++++++++++++++++++++++++++++++++++++++
2 files changed, 41 insertions(+), 1 deletion(-)
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()
--
1.9.1
More information about the U-Boot
mailing list