Simon Glass | 49e3aec | 2016-09-13 21:44:07 -0600 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # Copyright (c) 2016 Google, Inc |
| 3 | # Written by Simon Glass <sjg@chromium.org> |
| 4 | # |
| 5 | # Check that the u-boot.cfg file provided does not introduce any new |
| 6 | # ad-hoc CONFIG options |
| 7 | # |
Masahiro Yamada | 54c4495 | 2016-09-26 13:04:58 +0900 | [diff] [blame] | 8 | # Use scripts/build-whitelist.sh to generate the list of current ad-hoc |
| 9 | # CONFIG options (those which are not in Kconfig). |
Simon Glass | 49e3aec | 2016-09-13 21:44:07 -0600 | [diff] [blame] | 10 | |
| 11 | # Usage |
| 12 | # check-config.sh <path to u-boot.cfg> <path to whitelist file> <source dir> |
| 13 | # |
| 14 | # For example: |
| 15 | # scripts/check-config.sh b/chromebook_link/u-boot.cfg kconfig_whitelist.txt . |
| 16 | |
| 17 | path="$1" |
| 18 | whitelist="$2" |
| 19 | srctree="$3" |
| 20 | |
| 21 | # Temporary files |
| 22 | configs="${path}.configs" |
| 23 | suspects="${path}.suspects" |
| 24 | ok="${path}.ok" |
| 25 | new_adhoc="${path}.adhoc" |
| 26 | |
| 27 | export LC_ALL=C |
| 28 | export LC_COLLATE=C |
| 29 | |
| 30 | cat ${path} |sed -n 's/^#define \(CONFIG_[A-Za-z0-9_]*\).*/\1/p' |sort |uniq \ |
| 31 | >${configs} |
| 32 | |
| 33 | comm -23 ${configs} ${whitelist} > ${suspects} |
| 34 | |
| 35 | cat `find ${srctree} -name "Kconfig*"` |sed -n \ |
| 36 | -e 's/^config *\([A-Za-z0-9_]*\).*$/CONFIG_\1/p' \ |
| 37 | -e 's/^menuconfig \([A-Za-z0-9_]*\).*$/CONFIG_\1/p' |sort |uniq > ${ok} |
| 38 | comm -23 ${suspects} ${ok} >${new_adhoc} |
| 39 | if [ -s ${new_adhoc} ]; then |
Masahiro Yamada | cf698a8 | 2017-01-31 20:11:33 +0900 | [diff] [blame] | 40 | echo >&2 "Error: You must add new CONFIG options using Kconfig" |
| 41 | echo >&2 "The following new ad-hoc CONFIG options were detected:" |
| 42 | cat >&2 ${new_adhoc} |
| 43 | echo >&2 |
| 44 | echo >&2 "Please add these via Kconfig instead. Find a suitable Kconfig" |
| 45 | echo >&2 "file and add a 'config' or 'menuconfig' option." |
Simon Glass | 49e3aec | 2016-09-13 21:44:07 -0600 | [diff] [blame] | 46 | # Don't delete the temporary files in case they are useful |
| 47 | exit 1 |
| 48 | else |
| 49 | rm ${suspects} ${ok} ${new_adhoc} |
| 50 | fi |