From 181fd70a9afac1f63eb71d421ae07b71ff2eaa66 Mon Sep 17 00:00:00 2001 From: "Michael (XIAO Xufeng)" Date: Thu, 27 Jun 2019 19:11:15 +0800 Subject: [PATCH] ci: multichip build support for examples --- tools/ci/build_examples_cmake.sh | 16 ++++++++------- tools/ci/config/build.yml | 19 ++++++++++------- tools/ci/config/target-test.yml | 2 +- tools/ci/executable-list.txt | 1 + tools/ci/get_supported_examples.sh | 33 ++++++++++++++++++++++++++++++ 5 files changed, 56 insertions(+), 15 deletions(-) create mode 100755 tools/ci/get_supported_examples.sh diff --git a/tools/ci/build_examples_cmake.sh b/tools/ci/build_examples_cmake.sh index 3e76271d4..6ec906b0d 100755 --- a/tools/ci/build_examples_cmake.sh +++ b/tools/ci/build_examples_cmake.sh @@ -34,7 +34,7 @@ set -o pipefail # Exit if pipe failed. # Remove the initial space and instead use '\n'. IFS=$'\n\t' -export PATH="$IDF_PATH/tools:$PATH" # for idf.py +export PATH="$IDF_PATH/tools/ci:$IDF_PATH/tools:$PATH" # ----------------------------------------------------------------------------- @@ -49,7 +49,7 @@ die() { set -o nounset # Exit if variable not set. -echo "build_examples running in ${PWD}" +echo "build_examples running in ${PWD} for target $IDF_TARGET" # only 0 or 1 arguments [ $# -le 1 ] || die "Have to run as $(basename $0) []" @@ -66,7 +66,9 @@ LOG_SUSPECTED=${LOG_PATH}/common_log.txt touch ${LOG_SUSPECTED} SDKCONFIG_DEFAULTS_CI=sdkconfig.ci -EXAMPLE_PATHS=$( find ${IDF_PATH}/examples/ -type f -name CMakeLists.txt | grep -v "/components/" | grep -v "/common_components/" | grep -v "/main/" | grep -v "/idf_as_lib/stubs/" | sort ) +EXAMPLE_PATHS=$( get_supported_examples.sh $IDF_TARGET | sed "s#^#${IDF_PATH}\/examples\/#g" | awk '{print $0"/CmakeLists.txt"}' ) +echo "All examples found for target $IDF_TARGET:" +echo $EXAMPLE_PATHS if [ -z {CI_NODE_TOTAL} ] then @@ -103,10 +105,10 @@ build_example () { local EXAMPLE_DIR=$(dirname "${CMAKELISTS}") local EXAMPLE_NAME=$(basename "${EXAMPLE_DIR}") - echo "Building ${EXAMPLE_NAME} as ${ID}..." - mkdir -p "example_builds/${ID}" - cp -r "${EXAMPLE_DIR}" "example_builds/${ID}" - pushd "example_builds/${ID}/${EXAMPLE_NAME}" + echo "Building ${EXAMPLE_NAME} for ${IDF_TARGET} as ${ID}..." + mkdir -p "example_builds/${IDF_TARGET}/${ID}" + cp -r "${EXAMPLE_DIR}" "example_builds/${IDF_TARGET}/${ID}" + pushd "example_builds/${IDF_TARGET}/${ID}/${EXAMPLE_NAME}" # be stricter in the CI build than the default IDF settings export EXTRA_CFLAGS=${PEDANTIC_CFLAGS} export EXTRA_CXXFLAGS=${EXTRA_CFLAGS} diff --git a/tools/ci/config/build.yml b/tools/ci/config/build.yml index 1eb151c05..907492a52 100644 --- a/tools/ci/config/build.yml +++ b/tools/ci/config/build.yml @@ -144,18 +144,18 @@ build_examples_make: - ${IDF_PATH}/tools/ci/build_examples.sh # same as above, but for CMake -build_examples_cmake: +.build_examples_cmake: &build_examples_cmake extends: .build_template parallel: 5 artifacts: when: always paths: - - build_examples_cmake/*/*/*/build/*.bin - - build_examples_cmake/*/*/*/sdkconfig - - build_examples_cmake/*/*/*/build/*.elf - - build_examples_cmake/*/*/*/build/*.map - - build_examples_cmake/*/*/*/build/flasher_args.json - - build_examples_cmake/*/*/*/build/bootloader/*.bin + - build_examples_cmake/*/*/*/*/build/*.bin + - build_examples_cmake/*/*/*/*/sdkconfig + - build_examples_cmake/*/*/*/*/build/*.elf + - build_examples_cmake/*/*/*/*/build/*.map + - build_examples_cmake/*/*/*/*/build/flasher_args.json + - build_examples_cmake/*/*/*/*/build/bootloader/*.bin - $LOG_PATH expire_in: 3 days variables: @@ -177,6 +177,11 @@ build_examples_cmake: - mkdir -p ${LOG_PATH} - ${IDF_PATH}/tools/ci/build_examples_cmake.sh +build_examples_cmake_esp32: + extends: .build_examples_cmake + variables: + IDF_TARGET: esp32 + # If you want to add new build example jobs, please add it into dependencies of `.example_test_template` build_docs: diff --git a/tools/ci/config/target-test.yml b/tools/ci/config/target-test.yml index 069a32889..c8c12a321 100644 --- a/tools/ci/config/target-test.yml +++ b/tools/ci/config/target-test.yml @@ -22,7 +22,7 @@ dependencies: - assign_test - build_examples_make - - build_examples_cmake + - build_examples_cmake_esp32 artifacts: when: always paths: diff --git a/tools/ci/executable-list.txt b/tools/ci/executable-list.txt index e7b971519..bad335f8a 100644 --- a/tools/ci/executable-list.txt +++ b/tools/ci/executable-list.txt @@ -40,6 +40,7 @@ tools/ci/check_ut_cmake_make.sh tools/ci/checkout_project_ref.py tools/ci/envsubst.py tools/ci/get-full-sources.sh +tools/ci/get_supported_examples.sh tools/ci/mirror-submodule-update.sh tools/ci/multirun_with_pyenv.sh tools/ci/push_to_github.sh diff --git a/tools/ci/get_supported_examples.sh b/tools/ci/get_supported_examples.sh new file mode 100755 index 000000000..1cae80b56 --- /dev/null +++ b/tools/ci/get_supported_examples.sh @@ -0,0 +1,33 @@ +#!/bin/bash +set -o errexit +set -o pipefail +set -o nounset + +DEBUG_SHELL=${DEBUG_SHELL:-"0"} +[ "${DEBUG_SHELL}" = "1" ] && set -x + +if [[ $# < 1 ]]; then + echo "no target specified!" >&2 + exit -1 +fi + +cd $IDF_PATH/examples +ALL_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 ) +EXAMPLE_LIST=$( realpath --relative-to=. $ALL_EXAMPLES ) + +for EXAMPLE in $EXAMPLE_LIST +do + SEARCHED=$( grep -E "SUPPORTED_TARGETS" $EXAMPLE/CMakeLists.txt | sed "s/set\s*(\s*SUPPORTED_TARGETS//g" | sed "s/)//g" ) || true + if [[ $SEARCHED == "" ]]; then + #when SUPPORTED_TARGETS not set, allow all targets implicitly + echo "$EXAMPLE" + else + for TARGET in $SEARCHED + do + if [[ $TARGET == $1 ]]; then + echo "$EXAMPLE" + break + fi + done + fi +done