From de7654622792724be7f34bb45bef946f77a4be7a Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Mon, 26 Sep 2016 17:13:32 +1000 Subject: [PATCH] Build examples out-of-tree as part of CI process --- .gitlab-ci.yml | 17 +++++++++++++++++ examples/04_ble_adv/Makefile | 1 + make/build_examples.sh | 31 +++++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+) create mode 100755 make/build_examples.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 42f24cd033..6d788a65ce 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -69,6 +69,23 @@ build_ssc: - chmod +x gen_misc_ng.sh - ./gen_misc_ng.sh +build_examples: + <<: *build_template + artifacts: + paths: + - build_examples/*/*/build/*.bin + - build_examples/*/*/build/*.elf + - build_examples/*/*/build/*.map + - build_examples/*/*/build/bootloader/*.bin + expire_in: 6 mos + + script: + # it's not possible to build 100% out-of-tree and have the "artifacts" + # mechanism work, but this is the next best thing + - mkdir build_examples + - cd build_examples + - ${IDF_PATH}/make/build_examples.sh + test_nvs_on_host: stage: test image: espressif/esp32-ci-env diff --git a/examples/04_ble_adv/Makefile b/examples/04_ble_adv/Makefile index 9f91869a8b..3a913b817b 100644 --- a/examples/04_ble_adv/Makefile +++ b/examples/04_ble_adv/Makefile @@ -13,3 +13,4 @@ sdkconfig: sdkconfig.defaults $(Q) cp $< $@ menuconfig: sdkconfig +defconfig: sdkconfig diff --git a/make/build_examples.sh b/make/build_examples.sh new file mode 100755 index 0000000000..d264862874 --- /dev/null +++ b/make/build_examples.sh @@ -0,0 +1,31 @@ +#!/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 + +set -e + +for example in ${IDF_PATH}/examples/*; do + [ -f ${example}/Makefile ] || continue + echo "Building ${example} as ${EXAMPLE_NUM}..." + mkdir ${EXAMPLE_NUM} + cp -r ${example} ${EXAMPLE_NUM} + pushd ${EXAMPLE_NUM}/`basename ${example}` + # can't do "make defconfig all" as this will trip menuconfig + # sometimes + make defconfig && make || RESULT=$? + popd + EXAMPLE_NUM=$(( $EXAMPLE_NUM + 1 )) +done + +exit $RESULT +