check-config.sh 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #!/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. #
  8. # Use scripts/build-whitelist.sh to generate the list of current ad-hoc
  9. # CONFIG options (those which are not in Kconfig).
  10. # Usage
  11. # check-config.sh <path to u-boot.cfg> <path to whitelist file> <source dir>
  12. #
  13. # For example:
  14. # scripts/check-config.sh b/chromebook_link/u-boot.cfg kconfig_whitelist.txt .
  15. set -e
  16. set -u
  17. path="$1"
  18. whitelist="$2"
  19. srctree="$3"
  20. # Temporary files
  21. configs="${path}.configs"
  22. suspects="${path}.suspects"
  23. ok="${path}.ok"
  24. new_adhoc="${path}.adhoc"
  25. export LC_ALL=C
  26. export LC_COLLATE=C
  27. cat ${path} |sed -n 's/^#define \(CONFIG_[A-Za-z0-9_]*\).*/\1/p' |sort |uniq \
  28. >${configs}
  29. comm -23 ${configs} ${whitelist} > ${suspects}
  30. cat `find ${srctree} -name "Kconfig*"` |sed -n \
  31. -e 's/^\s*config *\([A-Za-z0-9_]*\).*$/CONFIG_\1/p' \
  32. -e 's/^\s*menuconfig \([A-Za-z0-9_]*\).*$/CONFIG_\1/p' \
  33. |sort |uniq > ${ok}
  34. comm -23 ${suspects} ${ok} >${new_adhoc}
  35. if [ -s ${new_adhoc} ]; then
  36. echo >&2 "Error: You must add new CONFIG options using Kconfig"
  37. echo >&2 "The following new ad-hoc CONFIG options were detected:"
  38. cat >&2 ${new_adhoc}
  39. echo >&2
  40. echo >&2 "Please add these via Kconfig instead. Find a suitable Kconfig"
  41. echo >&2 "file and add a 'config' or 'menuconfig' option."
  42. # Don't delete the temporary files in case they are useful
  43. exit 1
  44. else
  45. rm ${suspects} ${ok} ${new_adhoc}
  46. fi