check-config.sh 1.5 KB

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