Detect and reject new ad-hoc CONFIG options
v3 cover Detect and reject new ad-hoc CONFIG options
Despite the availability of Kconfig, the number of ad-hoc CONFIG options in U-Boot is still at over 8000.
In February 2015 (commit 741e58e0) there were around 8387 ad-hoc CONFIGs. As of this patch there are about 8336, only a little fewer.
One problem is that new ones are still being added, admittedly at a slower rate. This series adds a Makefile check to detect that and produce a build error. This provides immediate feedback that new CONFIG options should go in Kconfig.
Changes in v3:
- Update the whitelist with mainline
- Fix the match partern to exclude .py files, not anything containing "py"
- Handle Kconfig files with extensions (e.g. Kconfig.64)
- Handle CONFIG_SYS_EXTRA_OPTIONS containing lower case
- Include lower-case letters in the CONFIG match string
- Write error output to stderr so that buildman shows it
- Handle Kconfig files with extensions (e.g. Kconfig.64)
- Handle extra whitespace after 'config' / 'menuconfig'
Changes in v2:
- Rebase to mainline
- Fix scripts so that there are no errors
- Add the 'build-whitelist.sh' script to the tree
Simon Glass (2):
Kconfig: Add a whitelist of ad-hoc CONFIG options
Makefile: Give a build error if ad-hoc CONFIG options are added
Makefile | 10 +- scripts/build-whitelist.sh | 51 + scripts/check-config.sh | 55 + scripts/config_whitelist.txt | 8420 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 8535 insertions(+), 1 deletion(-) create mode 100755 scripts/build-whitelist.sh create mode 100755 scripts/check-config.sh create mode 100644 scripts/config_whitelist.txt
Signature · 1 line
2.8.0.rc3.226.g39d4020
PATCH v3 1/2 Kconfig: Add a whitelist of ad-hoc CONFIG options
Add a list of ad-hoc CONFIG options that don't use Kconfig. This can be used to check that new ones are not being added.
---
Changes in v3:
- Update the whitelist with mainline
- Fix the match partern to exclude .py files, not anything containing "py"
- Handle Kconfig files with extensions (e.g. Kconfig.64)
- Handle CONFIG_SYS_EXTRA_OPTIONS containing lower case
Changes in v2: None
scripts/build-whitelist.sh | 51 + scripts/config_whitelist.txt | 8420 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 8471 insertions(+) create mode 100755 scripts/build-whitelist.sh create mode 100644 scripts/config_whitelist.txt
scripts/build-whitelist.sh new file +51 -0
@@ -0,0 +1,51 @@ +#!/bin/sh +# Copyright (c) 2016 Google, Inc +# Written by Simon Glass <[email protected]> +# + +# This script creates the configuration whitelist file. This file contains +# all the config options which are allowed to be used outside Kconfig. +# Please do not add things to the whitelist. Instead, add your new option +# to Kconfig. +# +export LC_ALL=C LC_COLLATE=C + +# There are two independent greps. The first pulls out the component parts +# of CONFIG_SYS_EXTRA_OPTIONS. An example is: +# +# SUNXI_GMAC,AHCI,SATAPWR=SUNXI_GPB(8) +# +# We want this to produce: +# CONFIG_SUNXI_GMAC +# CONFIG_AHCI +# CONFIG_SATAPWR +# +# The second looks for the rest of the CONFIG options, but excludes those in +# Kconfig and defconfig files. +# +( +git grep CONFIG_SYS_EXTRA_OPTIONS |sed -n \ + 's/.*CONFIG_SYS_EXTRA_OPTIONS="\(.*\)"/\1/ p' \ + | tr , '\n' \ + | sed 's/ *\([A-Za-z0-9_]*\).*/CONFIG_\1/' + +git grep CONFIG_ | \ + egrep -vi "(Kconfig:|defconfig:|README|\.py|\.pl:)" \ + | tr ' \t' '\n\n' \ + | sed -n 's/^\(CONFIG_[A-Za-z0-9_]*\).*/\1/p' +) \ + |sort |uniq >scripts/config_whitelist.txt.tmp1; + +# Finally, we need a list of the valid Kconfig options to exclude these from +# the whitelist. +cat `find . -name "Kconfig*"` |sed -n \ + -e 's/^config *\([A-Za-z0-9_]*\).*$/CONFIG_\1/p' \ + -e 's/^menuconfig *\([A-Za-z0-9_]*\).*$/CONFIG_\1/p' \ + |sort |uniq >scripts/config_whitelist.txt.tmp2 + +# Use only the options that are present in the first file but not the second. +comm -23 scripts/config_whitelist.txt.tmp1 scripts/config_whitelist.txt.tmp2 \ + |sort |uniq >scripts/config_whitelist.txt +rm scripts/config_whitelist.txt.tmp1 scripts/config_whitelist.txt.tmp2 + +unset LC_ALL LC_COLLATE
scripts/config_whitelist.txt new file +8420 -0
2,949 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.8.0.rc3.226.g39d4020
Part of the diff is not shown here. View the raw message.
PATCH v3 1/2 Kconfig: Add a whitelist of ad-hoc CONFIG options
Quoted 4 lines · Simon Glass
Add a list of ad-hoc CONFIG options that don't use
Kconfig. This can be used to check that new ones are not being added.Signed-off-by Simon Glass <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160918/367f7c80/attachment.sig>
PATCH v3 2/2 Makefile: Give a build error if ad-hoc CONFIG options are added
In reply to Simon GlassNew CONFIG options should be added via Kconfig. To help prevent new ad-hoc CONFIGs from being added, give a build error when these are detected.
---
Changes in v3:
- Include lower-case letters in the CONFIG match string
- Write error output to stderr so that buildman shows it
- Handle Kconfig files with extensions (e.g. Kconfig.64)
- Handle extra whitespace after 'config' / 'menuconfig'
Changes in v2:
- Rebase to mainline
- Fix scripts so that there are no errors
- Add the 'build-whitelist.sh' script to the tree
Makefile | 10 ++++++++- scripts/check-config.sh | 55 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+), 1 deletion(-) create mode 100755 scripts/check-config.sh
Makefile +9 -1
@@ -740,7 +740,8 @@ DO_STATIC_RELA = endif # Always append ALL so that arch config.mk's can add custom ones -ALL-y += u-boot.srec u-boot.bin u-boot.sym System.map u-boot.cfg binary_size_check +ALL-y += u-boot.srec u-boot.bin u-boot.sym System.map u-boot.cfg \ + binary_size_check no_new_adhoc_configs_check ALL-$(CONFIG_ONENAND_U_BOOT) += u-boot-onenand.bin ifeq ($(CONFIG_SPL_FSL_PBL),y)
@@ -946,6 +947,13 @@ u-boot.dis: u-boot u-boot.cfg: include/config.h FORCE $(call if_changed,cpp_cfg) +# Check that this build does not use CONFIG options that we don't know about +# unless they are in Kconfig. All the existing CONFIG options are whitelisted, +# so new ones should not be added. +no_new_adhoc_configs_check: u-boot.cfg FORCE + $(srctree)/scripts/check-config.sh $< \ + $(srctree)/scripts/config_whitelist.txt ${srctree} 1>&2 + ifdef CONFIG_TPL SPL_PAYLOAD := tpl/u-boot-with-tpl.bin else
scripts/check-config.sh new file +55 -0
55 lines not on this page · raw message
Signature · 1 line
2.8.0.rc3.226.g39d4020
PATCH v3 2/2 Makefile: Give a build error if ad-hoc CONFIG options are added
Quoted 6 lines · Simon Glass
New CONFIG options should be added via
Kconfig. To help prevent new ad-hoc CONFIGs from being added, give a build error when these are detected.Signed-off-by Simon Glass <[email protected]>Acked-by Stephen Warren <[email protected]>Tested-by Stephen Warren <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160918/22725554/attachment.sig>
v3 cover Detect and reject new ad-hoc CONFIG options
In reply to Simon GlassHi Tom,
Quoted 39 lines · Simon Glass
Despite the availability of
Kconfig, the number of ad-hoc CONFIG options in U-Boot is still at over 8000.In February 2015 (commit
741e58e0) there were around 8387 ad-hoc CONFIGs. As of this patch there are about 8336, only a little fewer.One problem is that new ones are still being added, admittedly at a slower rate. This series adds a
Makefilecheck to detect that and produce a build error. This provides immediate feedback that new CONFIG options should go inKconfig.Changes in v3:
- Update the whitelist with mainline
- Fix the match partern to exclude .py files, not anything containing "py"
- HandleKconfigfiles with extensions (e.g.Kconfig.64)
- HandleCONFIG_SYS_EXTRA_OPTIONScontaining lower case
- Include lower-case letters in the CONFIG match string
- Write error output to stderr so that buildman shows it
- HandleKconfigfiles with extensions (e.g.Kconfig.64)
- Handle extra whitespace after 'config' / 'menuconfig'Changes in v2:
- Rebase to mainline
- Fix scripts so that there are no errors
- Add the 'build-whitelist.sh' script to the treeSimon Glass (2):
Kconfig: Add a whitelist of ad-hoc CONFIG options
Makefile: Give a build error if ad-hoc CONFIG options are addedMakefile | 10 +- scripts/build-whitelist.sh | 51 + scripts/check-config.sh | 55 + scripts/config_whitelist.txt | 8420 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 8535 insertions(+), 1 deletion(-) create mode 100755 scripts/build-whitelist.sh create mode 100755 scripts/check-config.sh create mode 100644 scripts/config_whitelist.txt
Quoted 3 lines
--
2.8.0.rc3.226.g39d4020
I build-tested this on top of the SPL series (see u-boot-dm/kconfig-working2):
buildman -b kc4 -fC --step 0 -s
boards.cfg is up to date. Nothing to do.
Summary of 2 commits for 1196 boards (32 threads, 1 job per thread) 01: buildman
blackfin: + cm-bf527 bf609-ezkit bf537-stamp
sparc: + grsim grsim_leon2 gr_cpci_ax2000 gr_xc3s_1500 gr_ep2s60
nios2: + 10m50 3c120
microblaze: + microblaze-generic
openrisc: + openrisc-generic48: Makefile: Give a build error if ad-hoc CONFIG options are added (kc4=74f3ab: -- asc asc2 asc3 b/ sandbox/ test/) u>
There were a number of tweaked needed to get the config checker to build all boards without error. My previous tested omitted the -C flag, meaning that it did not reconfigure all of the boards, so missing loads of problems.
Regards,
Simon
v3 cover Detect and reject new ad-hoc CONFIG options
Quoted 57 lines · Simon Glass
Hi Tom,
Quoted 39 lines · Simon Glass
Despite the availability of
Kconfig, the number of ad-hoc CONFIG options in U-Boot is still at over 8000.In February 2015 (commit
741e58e0) there were around 8387 ad-hoc CONFIGs. As of this patch there are about 8336, only a little fewer.One problem is that new ones are still being added, admittedly at a slower rate. This series adds a
Makefilecheck to detect that and produce a build error. This provides immediate feedback that new CONFIG options should go inKconfig.Changes in v3:
- Update the whitelist with mainline
- Fix the match partern to exclude .py files, not anything containing "py"
- HandleKconfigfiles with extensions (e.g.Kconfig.64)
- HandleCONFIG_SYS_EXTRA_OPTIONScontaining lower case
- Include lower-case letters in the CONFIG match string
- Write error output to stderr so that buildman shows it
- HandleKconfigfiles with extensions (e.g.Kconfig.64)
- Handle extra whitespace after 'config' / 'menuconfig'Changes in v2:
- Rebase to mainline
- Fix scripts so that there are no errors
- Add the 'build-whitelist.sh' script to the treeSimon Glass (2):
Kconfig: Add a whitelist of ad-hoc CONFIG options
Makefile: Give a build error if ad-hoc CONFIG options are addedMakefile | 10 +- scripts/build-whitelist.sh | 51 + scripts/check-config.sh | 55 + scripts/config_whitelist.txt | 8420 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 8535 insertions(+), 1 deletion(-) create mode 100755 scripts/build-whitelist.sh create mode 100755 scripts/check-config.sh create mode 100644 scripts/config_whitelist.txtQuoted 3 lines
--
2.8.0.rc3.226.g39d4020I build-tested this on top of the SPL series (see u-boot-dm/kconfig-working2):
buildman -b kc4 -fC --step 0 -s
boards.cfg is up to date. Nothing to do.
Summary of 2 commits for 1196 boards (32 threads, 1 job per thread) 01: buildmanblackfin: + cm-bf527 bf609-ezkit bf537-stamp sparc: + grsim grsim_leon2 gr_cpci_ax2000 gr_xc3s_1500 gr_ep2s60 nios2: + 10m50 3c120 microblaze: + microblaze-generic openrisc: + openrisc-generic
Quoted 7 lines
48:
Makefile: Give a build error if ad-hoc CONFIG options are added (kc4=74f3ab: -- asc asc2 asc3 b/ sandbox/ test/) u>There were a number of tweaked needed to get the config checker to build all boards without error. My previous tested omitted the -C flag, meaning that it did not reconfigure all of the boards, so missing loads of problems.
Great, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160914/c69230c9/attachment.sig>