blob: 267758498b3d435d1708e2ac4e10e85b69b2f067 [file] [log] [blame]
Simon Glass49e3aec2016-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 Yamada54c44952016-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 Glass49e3aec2016-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
17path="$1"
18whitelist="$2"
19srctree="$3"
20
21# Temporary files
22configs="${path}.configs"
23suspects="${path}.suspects"
24ok="${path}.ok"
25new_adhoc="${path}.adhoc"
26
27export LC_ALL=C
28export LC_COLLATE=C
29
30cat ${path} |sed -n 's/^#define \(CONFIG_[A-Za-z0-9_]*\).*/\1/p' |sort |uniq \
31 >${configs}
32
33comm -23 ${configs} ${whitelist} > ${suspects}
34
35cat `find ${srctree} -name "Kconfig*"` |sed -n \
Bin Meng6a75b582017-06-29 11:36:25 +080036 -e 's/^\s*config *\([A-Za-z0-9_]*\).*$/CONFIG_\1/p' \
37 -e 's/^\s*menuconfig \([A-Za-z0-9_]*\).*$/CONFIG_\1/p' \
38 |sort |uniq > ${ok}
Simon Glass49e3aec2016-09-13 21:44:07 -060039comm -23 ${suspects} ${ok} >${new_adhoc}
40if [ -s ${new_adhoc} ]; then
Masahiro Yamadacf698a82017-01-31 20:11:33 +090041 echo >&2 "Error: You must add new CONFIG options using Kconfig"
42 echo >&2 "The following new ad-hoc CONFIG options were detected:"
43 cat >&2 ${new_adhoc}
44 echo >&2
45 echo >&2 "Please add these via Kconfig instead. Find a suitable Kconfig"
46 echo >&2 "file and add a 'config' or 'menuconfig' option."
Simon Glass49e3aec2016-09-13 21:44:07 -060047 # Don't delete the temporary files in case they are useful
48 exit 1
49else
50 rm ${suspects} ${ok} ${new_adhoc}
51fi