2016-09-26 07:13:32 +00:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# Build all examples from the examples directory, out of tree to
|
|
|
|
# ensure they can run when copied to a new directory.
|
|
|
|
#
|
|
|
|
# Runs as part of CI process.
|
|
|
|
#
|
|
|
|
# Assumes CWD is an out-of-tree build directory, and will copy examples to individual subdirectories, one by one.
|
|
|
|
#
|
|
|
|
[ -z ${IDF_PATH} ] && echo "IDF_PATH is not set" && exit 1
|
|
|
|
|
|
|
|
EXAMPLE_NUM=1
|
|
|
|
RESULT=0
|
2016-12-30 05:13:07 +00:00
|
|
|
FAILED_EXAMPLES=""
|
2016-09-26 07:13:32 +00:00
|
|
|
|
2016-12-06 18:39:56 +00:00
|
|
|
RESULT_WARNINGS=22 # magic number result code for "warnings found"
|
|
|
|
|
2016-09-26 07:13:32 +00:00
|
|
|
for example in ${IDF_PATH}/examples/*; do
|
2016-11-14 04:29:27 +00:00
|
|
|
[ -f ${example}/Makefile ] || continue
|
|
|
|
echo "Building ${example} as ${EXAMPLE_NUM}..."
|
2016-12-06 18:39:56 +00:00
|
|
|
mkdir -p example_builds/${EXAMPLE_NUM}
|
|
|
|
cp -r ${example} example_builds/${EXAMPLE_NUM}
|
|
|
|
pushd example_builds/${EXAMPLE_NUM}/`basename ${example}`
|
2016-11-16 04:42:38 +00:00
|
|
|
|
|
|
|
# be stricter in the CI build than the default IDF settings
|
|
|
|
export EXTRA_CFLAGS="-Werror -Werror=deprecated-declarations"
|
|
|
|
export EXTRA_CXXFLAGS=${EXTRA_CFLAGS}
|
|
|
|
|
2016-12-06 18:39:56 +00:00
|
|
|
# build non-verbose first
|
|
|
|
BUILDLOG=$(mktemp -t examplebuild.XXXX.log)
|
|
|
|
(
|
2016-12-30 04:20:49 +00:00
|
|
|
set -o pipefail # so result of make all isn't lost when piping to tee
|
2016-12-06 18:39:56 +00:00
|
|
|
set -e
|
|
|
|
make clean defconfig
|
2016-12-30 04:20:49 +00:00
|
|
|
make $* all 2>&1 | tee $BUILDLOG
|
2016-12-30 05:13:07 +00:00
|
|
|
) || { RESULT=$?; FAILED_EXAMPLES+=" ${example}"; make V=1; } # only build verbose if there's an error
|
2016-11-14 04:29:27 +00:00
|
|
|
popd
|
|
|
|
EXAMPLE_NUM=$(( $EXAMPLE_NUM + 1 ))
|
2016-12-06 18:39:56 +00:00
|
|
|
|
2016-12-30 05:13:07 +00:00
|
|
|
if grep -q ": warning:" $BUILDLOG; then
|
|
|
|
[ $RESULT -eq 0 ] && RESULT=$RESULT_WARNINGS
|
|
|
|
FAILED_EXAMPLES+=" ${example} (warnings)"
|
2016-12-06 18:39:56 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
rm -f $BUILDLOG
|
2016-09-26 07:13:32 +00:00
|
|
|
done
|
|
|
|
|
2016-12-06 18:39:56 +00:00
|
|
|
if [ $RESULT -eq $RESULT_WARNINGS ]; then
|
|
|
|
echo "Build would have passed, except for warnings."
|
|
|
|
fi
|
|
|
|
|
2016-12-30 05:13:07 +00:00
|
|
|
[ $RESULT -eq 0 ] || echo "Failed examples: $FAILED_EXAMPLES"
|
|
|
|
|
2016-09-26 07:13:32 +00:00
|
|
|
exit $RESULT
|
|
|
|
|