check_examples_extra_component_dirs.sh 784 B

12345678910111213141516171819202122232425
  1. #!/usr/bin/env bash
  2. set -uo pipefail
  3. # Examples shouldn't use EXTRA_COMPONENT_DIRS, instead the dependencies should be specified in idf_component.yml files
  4. output=$(find ${IDF_PATH}/examples -name "CMakeLists.txt" -not -path "**/managed_components/**" -not -path "**/build/**")
  5. files=$(egrep "set\(EXTRA_COMPONENT_DIRS" ${output} | cut -d ":" -f 1)
  6. found_issues=0
  7. for file in ${files}
  8. do
  9. if [ "$file" == "${IDF_PATH}/examples/system/unit_test/test/CMakeLists.txt" ]; then
  10. # this specific one is okay
  11. continue
  12. fi
  13. echo "${file} uses EXTRA_COMPONENT_DIRS. Change it to reference the component using idf_component.yml file."
  14. ((found_issues++))
  15. done
  16. if [ $found_issues -eq 0 ]; then
  17. echo "No examples use EXTRA_COMPONENT_DIRS"
  18. exit 0
  19. fi
  20. exit 1