Simon Glass | 428975e | 2016-09-13 21:44:06 -0600 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # Copyright (c) 2016 Google, Inc |
| 3 | # Written by Simon Glass <sjg@chromium.org> |
| 4 | # |
| 5 | |
| 6 | # This script creates the configuration whitelist file. This file contains |
| 7 | # all the config options which are allowed to be used outside Kconfig. |
| 8 | # Please do not add things to the whitelist. Instead, add your new option |
| 9 | # to Kconfig. |
| 10 | # |
| 11 | export LC_ALL=C LC_COLLATE=C |
| 12 | |
Tom Rini | 215ec5c | 2022-03-24 17:18:06 -0400 | [diff] [blame^] | 13 | # Looks for the rest of the CONFIG options, but exclude those in Kconfig and |
| 14 | # defconfig files. |
Simon Glass | 428975e | 2016-09-13 21:44:06 -0600 | [diff] [blame] | 15 | # |
Simon Glass | 428975e | 2016-09-13 21:44:06 -0600 | [diff] [blame] | 16 | git grep CONFIG_ | \ |
| 17 | egrep -vi "(Kconfig:|defconfig:|README|\.py|\.pl:)" \ |
| 18 | | tr ' \t' '\n\n' \ |
Tom Rini | 215ec5c | 2022-03-24 17:18:06 -0400 | [diff] [blame^] | 19 | | sed -n 's/^\(CONFIG_[A-Za-z0-9_]*\).*/\1/p' \ |
Simon Glass | 428975e | 2016-09-13 21:44:06 -0600 | [diff] [blame] | 20 | |sort |uniq >scripts/config_whitelist.txt.tmp1; |
| 21 | |
| 22 | # Finally, we need a list of the valid Kconfig options to exclude these from |
| 23 | # the whitelist. |
| 24 | cat `find . -name "Kconfig*"` |sed -n \ |
Bin Meng | 6a75b58 | 2017-06-29 11:36:25 +0800 | [diff] [blame] | 25 | -e 's/^\s*config *\([A-Za-z0-9_]*\).*$/CONFIG_\1/p' \ |
| 26 | -e 's/^\s*menuconfig *\([A-Za-z0-9_]*\).*$/CONFIG_\1/p' \ |
Simon Glass | 428975e | 2016-09-13 21:44:06 -0600 | [diff] [blame] | 27 | |sort |uniq >scripts/config_whitelist.txt.tmp2 |
| 28 | |
| 29 | # Use only the options that are present in the first file but not the second. |
| 30 | comm -23 scripts/config_whitelist.txt.tmp1 scripts/config_whitelist.txt.tmp2 \ |
Masahiro Yamada | 4952387 | 2016-09-26 11:52:28 +0900 | [diff] [blame] | 31 | |sort |uniq >scripts/config_whitelist.txt.tmp3 |
| 32 | |
| 33 | # If scripts/config_whitelist.txt already exists, take the intersection of the |
| 34 | # current list and the new one. We do not want to increase whitelist options. |
| 35 | if [ -r scripts/config_whitelist.txt ]; then |
| 36 | comm -12 scripts/config_whitelist.txt.tmp3 scripts/config_whitelist.txt \ |
| 37 | > scripts/config_whitelist.txt.tmp4 |
| 38 | mv scripts/config_whitelist.txt.tmp4 scripts/config_whitelist.txt |
| 39 | else |
| 40 | mv scripts/config_whitelist.txt.tmp3 scripts/config_whitelist.txt |
| 41 | fi |
| 42 | |
| 43 | rm scripts/config_whitelist.txt.tmp* |
Simon Glass | 428975e | 2016-09-13 21:44:06 -0600 | [diff] [blame] | 44 | |
| 45 | unset LC_ALL LC_COLLATE |