check_examples_cmake_make.sh 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #!/usr/bin/env bash
  2. # While we support GNU Make & CMake together, check the same examples are present for both. But only for ESP32
  3. echo "- Getting paths of CMakeLists and Makefiles"
  4. IFS=
  5. CMAKELISTS=$( find ${IDF_PATH}/examples/ -type f -name CMakeLists.txt | grep -v "/components/" | grep -v "/common_components/" | grep -v "/cxx/experimental/experimental_cpp_component/" | grep -v "/main/" | grep -v "/build_system/cmake/" | grep -v "/mb_example_common/" | sort -n)
  6. MAKEFILES=$( find ${IDF_PATH}/examples/ -type f -name Makefile | grep -v "/build_system/cmake/" | sort -n)
  7. echo " [DONE]"
  8. echo "- Building the ignore list"
  9. IGNORE_LIST=
  10. while read line
  11. do
  12. STL=$(grep "set[(]SUPPORTED_TARGETS" $line)
  13. if test -n $STL # if specified SUPPORTED_TARGETS
  14. then
  15. WO_ESP32=$(grep -v -w "esp32" <<< $STL)
  16. if test -n "$WO_ESP32" # if not specified esp32 at SUPPORTED_TARGETS
  17. then # then consider that the example should not have a Makefile
  18. PATH2IGNORE=$(/usr/bin/dirname $line)
  19. echo " Adding to ignore $PATH2IGNORE"
  20. IGNORE_LIST="$IGNORE_LIST$PATH2IGNORE
  21. "
  22. fi
  23. fi
  24. done <<< $CMAKELISTS
  25. IGNORE_LIST=$(grep -v -e '^$' <<< $IGNORE_LIST) # remove empty lines
  26. echo -e " [DONE] - Ignore list:\n$IGNORE_LIST\n"
  27. echo "- Applying the Ignore list"
  28. while read line
  29. do
  30. echo $line
  31. CMAKELISTS=$(echo $CMAKELISTS | grep -v $line)
  32. MAKEFILES=$(echo $MAKEFILES | grep -v $line)
  33. done <<< $IGNORE_LIST
  34. echo " [DONE]"
  35. echo "- Getting paths of examples"
  36. while read line
  37. do
  38. new_path="$(/usr/bin/dirname $line)"
  39. CMAKE_EXAMPLE_PATHS="$CMAKE_EXAMPLE_PATHS$new_path
  40. "
  41. done <<< $CMAKELISTS
  42. CMAKE_EXAMPLE_PATHS=$(grep -v -e '^$' <<< $CMAKE_EXAMPLE_PATHS) # remove empty lines
  43. while read line
  44. do
  45. new_path="$(/usr/bin/dirname $line)"
  46. MAKE_EXAMPLE_PATHS="$MAKE_EXAMPLE_PATHS$new_path
  47. "
  48. done <<< $MAKEFILES
  49. MAKE_EXAMPLE_PATHS=$(grep -v -e '^$' <<< $MAKE_EXAMPLE_PATHS) # remove empty lines
  50. echo " [DONE]"
  51. echo "- Analysing matches"
  52. MISMATCH=$(comm -3 <(echo "$MAKE_EXAMPLE_PATHS") <(echo "$CMAKE_EXAMPLE_PATHS"))
  53. if [ -n "$MISMATCH" ]; then
  54. echo " [ERROR] Some examples are not in both CMake and GNU Make:"
  55. echo "$MISMATCH"
  56. exit 1
  57. fi
  58. echo " [DONE] Example lists match"
  59. exit 0