check-config.sh 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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/^config *\([A-Za-z0-9_]*\).*$/CONFIG_\1/p' \
  30. -e 's/^menuconfig \([A-Za-z0-9_]*\).*$/CONFIG_\1/p' |sort |uniq > ${ok}
  31. comm -23 ${suspects} ${ok} >${new_adhoc}
  32. if [ -s ${new_adhoc} ]; then
  33. echo >&2 "Error: You must add new CONFIG options using Kconfig"
  34. echo >&2 "The following new ad-hoc CONFIG options were detected:"
  35. cat >&2 ${new_adhoc}
  36. echo >&2
  37. echo >&2 "Please add these via Kconfig instead. Find a suitable Kconfig"
  38. echo >&2 "file and add a 'config' or 'menuconfig' option."
  39. # Don't delete the temporary files in case they are useful
  40. exit 1
  41. else
  42. rm ${suspects} ${ok} ${new_adhoc}
  43. fi