build-whitelist.sh 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #!/bin/sh
  2. # Copyright (c) 2016 Google, Inc
  3. # Written by Simon Glass <sjg@chromium.org>
  4. #
  5. # This script creates the configuration whitelist file. This file contains
  6. # all the config options which are allowed to be used outside Kconfig.
  7. # Please do not add things to the whitelist. Instead, add your new option
  8. # to Kconfig.
  9. #
  10. export LC_ALL=C LC_COLLATE=C
  11. # There are two independent greps. The first pulls out the component parts
  12. # of CONFIG_SYS_EXTRA_OPTIONS. An example is:
  13. #
  14. # SUN7I_GMAC,AHCI,SATAPWR=SUNXI_GPB(8)
  15. #
  16. # We want this to produce:
  17. # CONFIG_SUN7I_GMAC
  18. # CONFIG_AHCI
  19. # CONFIG_SATAPWR
  20. #
  21. # The second looks for the rest of the CONFIG options, but excludes those in
  22. # Kconfig and defconfig files.
  23. #
  24. (
  25. git grep CONFIG_SYS_EXTRA_OPTIONS |sed -n \
  26. 's/.*CONFIG_SYS_EXTRA_OPTIONS="\(.*\)"/\1/ p' \
  27. | tr , '\n' \
  28. | sed 's/ *\([A-Za-z0-9_]*\).*/CONFIG_\1/'
  29. git grep CONFIG_ | \
  30. egrep -vi "(Kconfig:|defconfig:|README|\.py|\.pl:)" \
  31. | tr ' \t' '\n\n' \
  32. | sed -n 's/^\(CONFIG_[A-Za-z0-9_]*\).*/\1/p'
  33. ) \
  34. |sort |uniq >scripts/config_whitelist.txt.tmp1;
  35. # Finally, we need a list of the valid Kconfig options to exclude these from
  36. # the whitelist.
  37. cat `find . -name "Kconfig*"` |sed -n \
  38. -e 's/^\s*config *\([A-Za-z0-9_]*\).*$/CONFIG_\1/p' \
  39. -e 's/^\s*menuconfig *\([A-Za-z0-9_]*\).*$/CONFIG_\1/p' \
  40. |sort |uniq >scripts/config_whitelist.txt.tmp2
  41. # Use only the options that are present in the first file but not the second.
  42. comm -23 scripts/config_whitelist.txt.tmp1 scripts/config_whitelist.txt.tmp2 \
  43. |sort |uniq >scripts/config_whitelist.txt.tmp3
  44. # If scripts/config_whitelist.txt already exists, take the intersection of the
  45. # current list and the new one. We do not want to increase whitelist options.
  46. if [ -r scripts/config_whitelist.txt ]; then
  47. comm -12 scripts/config_whitelist.txt.tmp3 scripts/config_whitelist.txt \
  48. > scripts/config_whitelist.txt.tmp4
  49. mv scripts/config_whitelist.txt.tmp4 scripts/config_whitelist.txt
  50. else
  51. mv scripts/config_whitelist.txt.tmp3 scripts/config_whitelist.txt
  52. fi
  53. rm scripts/config_whitelist.txt.tmp*
  54. unset LC_ALL LC_COLLATE