check-debug-flags.sh 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #!/usr/bin/env bash
  2. set -eo pipefail
  3. script_path=$(cd -P -- "$(dirname -- "$0")" && pwd -P)
  4. cd "${script_path}/.."
  5. MISSING_FLAGS=n
  6. while IFS= read -r FLAG; do
  7. # Ignore ELF_DEBUG because it's not a debug flag.
  8. if [ "$FLAG" = "ELF_DEBUG" ]; then
  9. continue
  10. fi
  11. # We simply search whether the CMakeLists.txt *ever* sets the flag.
  12. # There are (basically) no false positives, but there might be false negatives,
  13. # for example we intentionally don't check for commented-out lines here.
  14. if ! grep -qF "set(${FLAG}" Meta/CMake/all_the_debug_macros.cmake ; then
  15. echo "'all_the_debug_macros.cmake' is missing ${FLAG}"
  16. MISSING_FLAGS=y
  17. fi
  18. done < <(
  19. git ls-files -- \
  20. '*.cpp' \
  21. '*.h' \
  22. '*.in' \
  23. ':!:Kernel/FileSystem/ext2_fs.h' \
  24. | xargs grep -E '(_DEBUG|DEBUG_)' \
  25. | sed -re 's,^.*[^a-zA-Z0-9_]([a-zA-Z0-9_]*DEBUG[a-zA-Z0-9_]*).*$,\1,' \
  26. | sort \
  27. | uniq
  28. )
  29. if [ "n" != "${MISSING_FLAGS}" ] ; then
  30. echo "Some flags are missing for the ALL_THE_DEBUG_MACROS feature."
  31. echo "If you just added a new SOMETHING_DEBUG flag, that's great!"
  32. echo "We want to enable all of these in automated builds, so that the code doesn't rot."
  33. echo "Please add it to Meta/CMake/all_the_debug_macros.cmake"
  34. exit 1
  35. fi