]>
Commit | Line | Data |
---|---|---|
eed921d9 SG |
1 | #!/bin/sh |
2 | # Copyright (c) 2016 Google, Inc | |
3 | # Written by Simon Glass <[email protected]> | |
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 | # | |
6ff005cf | 16 | # SUN7I_GMAC,AHCI,SATAPWR=SUNXI_GPB(8) |
eed921d9 SG |
17 | # |
18 | # We want this to produce: | |
6ff005cf | 19 | # CONFIG_SUN7I_GMAC |
eed921d9 SG |
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 \ | |
1f54a47c BM |
42 | -e 's/^\s*config *\([A-Za-z0-9_]*\).*$/CONFIG_\1/p' \ |
43 | -e 's/^\s*menuconfig *\([A-Za-z0-9_]*\).*$/CONFIG_\1/p' \ | |
eed921d9 SG |
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 \ | |
9608f43c MY |
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* | |
eed921d9 SG |
61 | |
62 | unset LC_ALL LC_COLLATE |