blob: 4848ca6e25a59f6b6602166d6f3d329ec9b2b4d6 [file] [log] [blame]
Simon Glass371244c2016-09-13 21:44:07 -06001#!/bin/sh
2# Copyright (c) 2016 Google, Inc
3# Written by Simon Glass <sjg@chromium.org>
4#
5# Check that the u-boot.cfg file provided does not introduce any new
6# ad-hoc CONFIG options
7#
Masahiro Yamada7b76daa2016-09-26 13:04:58 +09008# Use scripts/build-whitelist.sh to generate the list of current ad-hoc
9# CONFIG options (those which are not in Kconfig).
Simon Glass371244c2016-09-13 21:44:07 -060010
11# Usage
12# check-config.sh <path to u-boot.cfg> <path to whitelist file> <source dir>
13#
14# For example:
15# scripts/check-config.sh b/chromebook_link/u-boot.cfg kconfig_whitelist.txt .
16
Luca Ceresolif69dce52018-03-15 11:08:56 +010017set -e
18set -u
19
Simon Glass371244c2016-09-13 21:44:07 -060020path="$1"
21whitelist="$2"
22srctree="$3"
23
24# Temporary files
25configs="${path}.configs"
26suspects="${path}.suspects"
27ok="${path}.ok"
28new_adhoc="${path}.adhoc"
29
30export LC_ALL=C
31export LC_COLLATE=C
32
33cat ${path} |sed -n 's/^#define \(CONFIG_[A-Za-z0-9_]*\).*/\1/p' |sort |uniq \
34 >${configs}
35
36comm -23 ${configs} ${whitelist} > ${suspects}
37
38cat `find ${srctree} -name "Kconfig*"` |sed -n \
Bin Meng1f54a472017-06-29 11:36:25 +080039 -e 's/^\s*config *\([A-Za-z0-9_]*\).*$/CONFIG_\1/p' \
40 -e 's/^\s*menuconfig \([A-Za-z0-9_]*\).*$/CONFIG_\1/p' \
41 |sort |uniq > ${ok}
Simon Glass371244c2016-09-13 21:44:07 -060042comm -23 ${suspects} ${ok} >${new_adhoc}
43if [ -s ${new_adhoc} ]; then
Masahiro Yamada1bdd9422017-01-31 20:11:33 +090044 echo >&2 "Error: You must add new CONFIG options using Kconfig"
45 echo >&2 "The following new ad-hoc CONFIG options were detected:"
46 cat >&2 ${new_adhoc}
47 echo >&2
48 echo >&2 "Please add these via Kconfig instead. Find a suitable Kconfig"
49 echo >&2 "file and add a 'config' or 'menuconfig' option."
Simon Glass371244c2016-09-13 21:44:07 -060050 # Don't delete the temporary files in case they are useful
51 exit 1
52else
53 rm ${suspects} ${ok} ${new_adhoc}
54fi