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