1*4882a593Smuzhiyun#!/bin/sh 2*4882a593Smuzhiyun# Copyright (c) 2016 Google, Inc 3*4882a593Smuzhiyun# Written by Simon Glass <sjg@chromium.org> 4*4882a593Smuzhiyun# 5*4882a593Smuzhiyun# Check that the u-boot.cfg file provided does not introduce any new 6*4882a593Smuzhiyun# ad-hoc CONFIG options 7*4882a593Smuzhiyun# 8*4882a593Smuzhiyun# Use scripts/build-whitelist.sh to generate the list of current ad-hoc 9*4882a593Smuzhiyun# CONFIG options (those which are not in Kconfig). 10*4882a593Smuzhiyun 11*4882a593Smuzhiyun# Usage 12*4882a593Smuzhiyun# check-config.sh <path to u-boot.cfg> <path to whitelist file> <source dir> 13*4882a593Smuzhiyun# 14*4882a593Smuzhiyun# For example: 15*4882a593Smuzhiyun# scripts/check-config.sh b/chromebook_link/u-boot.cfg kconfig_whitelist.txt . 16*4882a593Smuzhiyun 17*4882a593Smuzhiyunpath="$1" 18*4882a593Smuzhiyunwhitelist="$2" 19*4882a593Smuzhiyunsrctree="$3" 20*4882a593Smuzhiyun 21*4882a593Smuzhiyun# Temporary files 22*4882a593Smuzhiyunconfigs="${path}.configs" 23*4882a593Smuzhiyunsuspects="${path}.suspects" 24*4882a593Smuzhiyunok="${path}.ok" 25*4882a593Smuzhiyunnew_adhoc="${path}.adhoc" 26*4882a593Smuzhiyun 27*4882a593Smuzhiyunexport LC_ALL=C 28*4882a593Smuzhiyunexport LC_COLLATE=C 29*4882a593Smuzhiyun 30*4882a593Smuzhiyuncat ${path} |sed -n 's/^#define \(CONFIG_[A-Za-z0-9_]*\).*/\1/p' |sort |uniq \ 31*4882a593Smuzhiyun >${configs} 32*4882a593Smuzhiyun 33*4882a593Smuzhiyuncomm -23 ${configs} ${whitelist} > ${suspects} 34*4882a593Smuzhiyun 35*4882a593Smuzhiyuncat `find ${srctree} -name "Kconfig*"` |sed -n \ 36*4882a593Smuzhiyun -e 's/^\s*config *\([A-Za-z0-9_]*\).*$/CONFIG_\1/p' \ 37*4882a593Smuzhiyun -e 's/^\s*menuconfig \([A-Za-z0-9_]*\).*$/CONFIG_\1/p' \ 38*4882a593Smuzhiyun |sort |uniq > ${ok} 39*4882a593Smuzhiyuncomm -23 ${suspects} ${ok} >${new_adhoc} 40*4882a593Smuzhiyunif [ -s ${new_adhoc} ]; then 41*4882a593Smuzhiyun echo >&2 "Error: You must add new CONFIG options using Kconfig" 42*4882a593Smuzhiyun echo >&2 "The following new ad-hoc CONFIG options were detected:" 43*4882a593Smuzhiyun cat >&2 ${new_adhoc} 44*4882a593Smuzhiyun echo >&2 45*4882a593Smuzhiyun echo >&2 "Please add these via Kconfig instead. Find a suitable Kconfig" 46*4882a593Smuzhiyun echo >&2 "file and add a 'config' or 'menuconfig' option." 47*4882a593Smuzhiyun # Don't delete the temporary files in case they are useful 48*4882a593Smuzhiyun exit 1 49*4882a593Smuzhiyunelse 50*4882a593Smuzhiyun rm ${suspects} ${ok} ${new_adhoc} 51*4882a593Smuzhiyunfi 52