1#!/usr/bin/env bash 2set -o errexit 3set -o pipefail 4set -o nounset 5 6DEBUG_SHELL=${DEBUG_SHELL:-"0"} 7[ "${DEBUG_SHELL}" = "1" ] && set -x 8 9if [[ $# < 1 ]]; then 10 echo "no target specified!" >&2 11 exit -1 12fi 13 14cd $IDF_PATH/examples 15ALL_EXAMPLES=$( find . -type f -name CMakeLists.txt | grep -v "/components/" | grep -v "/common_components/" | grep -v "/main/" | grep -v "/idf_as_lib/stubs/" | sed "s/\/CMakeLists.txt//g" | sort ) 16EXAMPLE_LIST=$( realpath --relative-to=. $ALL_EXAMPLES ) 17 18for EXAMPLE in $EXAMPLE_LIST 19do 20 SEARCHED=$( grep -E "SUPPORTED_TARGETS" $EXAMPLE/CMakeLists.txt | sed "s/set\s*(\s*SUPPORTED_TARGETS//g" | sed "s/)//g" ) || true 21 if [[ $SEARCHED == "" ]]; then 22 #when SUPPORTED_TARGETS not set, allow all targets implicitly 23 echo "$EXAMPLE" 24 else 25 for TARGET in $SEARCHED 26 do 27 if [[ $TARGET == $1 ]]; then 28 echo "$EXAMPLE" 29 break 30 fi 31 done 32 fi 33done 34