]> granicus.if.org Git - esp-idf/commitdiff
ci: support building examples with external components
authorIvan Grokhotkov <ivan@espressif.com>
Fri, 26 Oct 2018 05:44:14 +0000 (13:44 +0800)
committerIvan Grokhotkov <ivan@espressif.com>
Mon, 19 Nov 2018 04:36:31 +0000 (12:36 +0800)
tools/ci/build_example_dirs.txt [new file with mode: 0644]
tools/ci/build_examples.sh

diff --git a/tools/ci/build_example_dirs.txt b/tools/ci/build_example_dirs.txt
new file mode 100644 (file)
index 0000000..09e2366
--- /dev/null
@@ -0,0 +1,5 @@
+# Each line specifies the location of project makefile, and the corresponding
+# directory which should be used as example root directory when copying the
+# example for building it out of tree.
+#
+examples/system/unit_test/test/Makefile        examples/system/unit_test
index 2210a4b45f6ce0812fdc1057af4c29e6219f674c..b17e5625e8a80053f2a5802808050acda4a26350 100755 (executable)
@@ -108,11 +108,24 @@ build_example () {
 
     local EXAMPLE_DIR=$(dirname "${MAKE_FILE}")
     local EXAMPLE_NAME=$(basename "${EXAMPLE_DIR}")
+    
+    # Check if the example needs a different base directory.
+    # Path of the Makefile relative to $IDF_PATH
+    local MAKE_FILE_REL=${MAKE_FILE#"${IDF_PATH}/"}
+    # Look for it in build_example_dirs.txt:
+    local COPY_ROOT_REL=$(sed -n -E "s|${MAKE_FILE_REL}[[:space:]]+(.*)|\1|p" < ${IDF_PATH}/tools/ci/build_example_dirs.txt)
+    if [[ -n "${COPY_ROOT_REL}" && -d "${IDF_PATH}/${COPY_ROOT_REL}/" ]]; then
+        local COPY_ROOT=${IDF_PATH}/${COPY_ROOT_REL}
+    else
+        local COPY_ROOT=${EXAMPLE_DIR}
+    fi
 
     echo "Building ${EXAMPLE_NAME} as ${ID}..."
     mkdir -p "example_builds/${ID}"
-    cp -r "${EXAMPLE_DIR}" "example_builds/${ID}"
-    pushd "example_builds/${ID}/${EXAMPLE_NAME}"
+    cp -r "${COPY_ROOT}" "example_builds/${ID}"
+    local COPY_ROOT_PARENT=$(dirname ${COPY_ROOT})
+    local EXAMPLE_DIR_REL=${EXAMPLE_DIR#"${COPY_ROOT_PARENT}"}
+    pushd "example_builds/${ID}/${EXAMPLE_DIR_REL}"
         # be stricter in the CI build than the default IDF settings
         export EXTRA_CFLAGS="-Werror -Werror=deprecated-declarations"
         export EXTRA_CXXFLAGS=${EXTRA_CFLAGS}
@@ -142,7 +155,7 @@ build_example () {
 
 EXAMPLE_NUM=0
 
-find ${IDF_PATH}/examples/ -type f -name Makefile | sort | \
+find ${IDF_PATH}/examples -type f -name Makefile | sort | \
 while read FN
 do
     if [[ $EXAMPLE_NUM -lt $START_NUM || $EXAMPLE_NUM -ge $END_NUM ]]