check_rom_apis.sh 780 B

1234567891011121314151617181920212223
  1. #!/usr/bin/env bash
  2. set -uo pipefail
  3. # ESP-IDF should only use the ROM API that has a prefix "esp_rom_"
  4. cd ${IDF_PATH} # git ls-files operates on working directory only, make sure we're at the top directory
  5. deprecated_rom_apis=$(cat ${IDF_PATH}/components/esp_rom/esp32/ld/esp32.rom.api.ld | grep "esp_rom_" | cut -d "=" -f 2 | cut -d " " -f 2)
  6. files_to_search=$(git ls-files --full-name '*.c')
  7. count=0
  8. for api in $deprecated_rom_apis; do
  9. found_files=$(grep -E "\W+"$api"\W+" $files_to_search)
  10. if [ -n "$found_files" ]; then
  11. echo $found_files
  12. ((count++))
  13. fi
  14. done
  15. if [ $count -gt 0 ]; then
  16. echo "ROM APIs used in ESP-IDF should have an esp_rom_ prefix"
  17. echo "Please try to use the APIs listed in esp_rom/include/esp_rom_xxx.h"
  18. exit 1
  19. fi