blob: 37630c0271cdb10c991883baf7d9f36f0437fe5c [file] [log] [blame]
Simon Glasseed921d92016-09-13 21:44:06 -06001#!/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#
11export LC_ALL=C LC_COLLATE=C
12
Simon Glass5579ce72022-07-11 19:04:07 -060013# Looks for the rest of the CONFIG options, but exclude those in Kconfig and
14# defconfig files.
Simon Glasseed921d92016-09-13 21:44:06 -060015#
Simon Glasseed921d92016-09-13 21:44:06 -060016git grep CONFIG_ | \
17 egrep -vi "(Kconfig:|defconfig:|README|\.py|\.pl:)" \
18 | tr ' \t' '\n\n' \
Simon Glass5579ce72022-07-11 19:04:07 -060019 | sed -n 's/^\(CONFIG_[A-Za-z0-9_]*\).*/\1/p' \
Simon Glasseed921d92016-09-13 21:44:06 -060020 |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.
24cat `find . -name "Kconfig*"` |sed -n \
Bin Meng1f54a472017-06-29 11:36:25 +080025 -e 's/^\s*config *\([A-Za-z0-9_]*\).*$/CONFIG_\1/p' \
26 -e 's/^\s*menuconfig *\([A-Za-z0-9_]*\).*$/CONFIG_\1/p' \
Simon Glasseed921d92016-09-13 21:44:06 -060027 |sort |uniq >scripts/config_whitelist.txt.tmp2
28
29# Use only the options that are present in the first file but not the second.
30comm -23 scripts/config_whitelist.txt.tmp1 scripts/config_whitelist.txt.tmp2 \
Masahiro Yamada9608f432016-09-26 11:52:28 +090031 |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.
35if [ -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
39else
40 mv scripts/config_whitelist.txt.tmp3 scripts/config_whitelist.txt
41fi
42
43rm scripts/config_whitelist.txt.tmp*
Simon Glasseed921d92016-09-13 21:44:06 -060044
45unset LC_ALL LC_COLLATE