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 | |
| 13 | # There are two independent greps. The first pulls out the component parts |
| 14 | # of CONFIG_SYS_EXTRA_OPTIONS. An example is: |
| 15 | # |
Dave Prue | dc1436c | 2017-08-31 19:21:01 +0200 | [diff] [blame] | 16 | # SUN7I_GMAC,AHCI,SATAPWR=SUNXI_GPB(8) |
Simon Glass | 428975e | 2016-09-13 21:44:06 -0600 | [diff] [blame] | 17 | # |
| 18 | # We want this to produce: |
Dave Prue | dc1436c | 2017-08-31 19:21:01 +0200 | [diff] [blame] | 19 | # CONFIG_SUN7I_GMAC |
Simon Glass | 428975e | 2016-09-13 21:44:06 -0600 | [diff] [blame] | 20 | # CONFIG_AHCI |
| 21 | # CONFIG_SATAPWR |
| 22 | # |
| 23 | # The second looks for the rest of the CONFIG options, but excludes those in |
| 24 | # Kconfig and defconfig files. |
| 25 | # |
| 26 | ( |
| 27 | git grep CONFIG_SYS_EXTRA_OPTIONS |sed -n \ |
| 28 | 's/.*CONFIG_SYS_EXTRA_OPTIONS="\(.*\)"/\1/ p' \ |
| 29 | | tr , '\n' \ |
| 30 | | sed 's/ *\([A-Za-z0-9_]*\).*/CONFIG_\1/' |
| 31 | |
| 32 | git grep CONFIG_ | \ |
| 33 | egrep -vi "(Kconfig:|defconfig:|README|\.py|\.pl:)" \ |
| 34 | | tr ' \t' '\n\n' \ |
| 35 | | sed -n 's/^\(CONFIG_[A-Za-z0-9_]*\).*/\1/p' |
| 36 | ) \ |
| 37 | |sort |uniq >scripts/config_whitelist.txt.tmp1; |
| 38 | |
| 39 | # Finally, we need a list of the valid Kconfig options to exclude these from |
| 40 | # the whitelist. |
| 41 | cat `find . -name "Kconfig*"` |sed -n \ |
Bin Meng | 6a75b58 | 2017-06-29 11:36:25 +0800 | [diff] [blame] | 42 | -e 's/^\s*config *\([A-Za-z0-9_]*\).*$/CONFIG_\1/p' \ |
| 43 | -e 's/^\s*menuconfig *\([A-Za-z0-9_]*\).*$/CONFIG_\1/p' \ |
Simon Glass | 428975e | 2016-09-13 21:44:06 -0600 | [diff] [blame] | 44 | |sort |uniq >scripts/config_whitelist.txt.tmp2 |
| 45 | |
| 46 | # Use only the options that are present in the first file but not the second. |
| 47 | comm -23 scripts/config_whitelist.txt.tmp1 scripts/config_whitelist.txt.tmp2 \ |
Masahiro Yamada | 4952387 | 2016-09-26 11:52:28 +0900 | [diff] [blame] | 48 | |sort |uniq >scripts/config_whitelist.txt.tmp3 |
| 49 | |
| 50 | # If scripts/config_whitelist.txt already exists, take the intersection of the |
| 51 | # current list and the new one. We do not want to increase whitelist options. |
| 52 | if [ -r scripts/config_whitelist.txt ]; then |
| 53 | comm -12 scripts/config_whitelist.txt.tmp3 scripts/config_whitelist.txt \ |
| 54 | > scripts/config_whitelist.txt.tmp4 |
| 55 | mv scripts/config_whitelist.txt.tmp4 scripts/config_whitelist.txt |
| 56 | else |
| 57 | mv scripts/config_whitelist.txt.tmp3 scripts/config_whitelist.txt |
| 58 | fi |
| 59 | |
| 60 | rm scripts/config_whitelist.txt.tmp* |
Simon Glass | 428975e | 2016-09-13 21:44:06 -0600 | [diff] [blame] | 61 | |
| 62 | unset LC_ALL LC_COLLATE |