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