tools: Fix the build examples script to run locally

This commit is contained in:
Anton Maklakov 2019-07-30 21:26:43 +07:00
parent 75c0066f93
commit 12403e39b4
2 changed files with 15 additions and 8 deletions

View File

@ -62,9 +62,12 @@ SDKCONFIG_DEFAULTS_CI=sdkconfig.ci
EXAMPLE_PATHS=$( find ${IDF_PATH}/examples/ -type f -name Makefile | grep -v "/build_system/cmake/" | sort )
if [ -z {CI_NODE_TOTAL} ]
if [ -z "${CI_NODE_TOTAL:-}" ]
then
START_NUM=0
if [ "${1:-}" ]; then
START_NUM=$1
fi
END_NUM=999
else
JOB_NUM=${CI_NODE_INDEX}

View File

@ -52,7 +52,7 @@ set -o nounset # Exit if variable not set.
echo "build_examples running in ${PWD} for target $IDF_TARGET"
# only 0 or 1 arguments
[ $# -le 1 ] || die "Have to run as $(basename $0) [<JOB_NAME>]"
[ $# -le 1 ] || die "Have to run as $(basename $0) [<START_EXAMPLE_NUMBER>]"
export BATCH_BUILD=1
export V=0 # only build verbose if there's an error
@ -67,22 +67,26 @@ touch ${LOG_SUSPECTED}
SDKCONFIG_DEFAULTS_CI=sdkconfig.ci
EXAMPLE_PATHS=$( get_supported_examples.sh $IDF_TARGET | sed "s#^#${IDF_PATH}\/examples\/#g" | awk '{print $0"/CmakeLists.txt"}' )
NUM_OF_EXAMPLES=$( echo "${EXAMPLE_PATHS}" | wc -l )
# just a plausibility check
[ ${NUM_OF_EXAMPLES} -lt 100 ] && die "NUM_OF_EXAMPLES is bad"
echo "All examples found for target $IDF_TARGET:"
echo $EXAMPLE_PATHS
echo "Number of examples: $NUM_OF_EXAMPLES"
if [ -z {CI_NODE_TOTAL} ]
if [ -z "${CI_NODE_TOTAL:-}" ]
then
START_NUM=0
END_NUM=999
if [ "${1:-}" ]; then
START_NUM=$1
fi
END_NUM=${NUM_OF_EXAMPLES}
else
JOB_NUM=${CI_NODE_INDEX}
# count number of the jobs
NUM_OF_JOBS=${CI_NODE_TOTAL}
# count number of examples
NUM_OF_EXAMPLES=$( echo "${EXAMPLE_PATHS}" | wc -l )
[ ${NUM_OF_EXAMPLES} -lt 100 ] && die "NUM_OF_EXAMPLES is bad"
# separate intervals
#57 / 5 == 12
NUM_OF_EX_PER_JOB=$(( (${NUM_OF_EXAMPLES} + ${NUM_OF_JOBS} - 1) / ${NUM_OF_JOBS} ))