build-whitelist.sh 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. # SUNXI_GMAC,AHCI,SATAPWR=SUNXI_GPB(8)
  15. #
  16. # We want this to produce:
  17. # CONFIG_SUNXI_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/^config *\([A-Za-z0-9_]*\).*$/CONFIG_\1/p' \
  39. -e '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
  44. rm scripts/config_whitelist.txt.tmp1 scripts/config_whitelist.txt.tmp2
  45. unset LC_ALL LC_COLLATE