]> granicus.if.org Git - esp-idf/commitdiff
ci, examples: use sdkconfig.ci as an extra defaults file, if present
authorIvan Grokhotkov <ivan@espressif.com>
Mon, 10 Dec 2018 05:26:40 +0000 (13:26 +0800)
committerIvan Grokhotkov <ivan@espressif.com>
Mon, 10 Dec 2018 08:29:24 +0000 (16:29 +0800)
- Allows placing CI-specific settings into sdkconfig.ci file
- Allows substituting environment variables in sdkconfig.ci

examples/protocols/mqtt/tcp/sdkconfig [deleted file]
examples/protocols/mqtt/tcp/sdkconfig.ci [new file with mode: 0644]
examples/protocols/mqtt/tcp/sdkconfig.defaults [deleted file]
tools/ci/build_examples.sh
tools/ci/build_examples_cmake.sh
tools/ci/envsubst.py [new file with mode: 0755]
tools/ci/executable-list.txt
tools/cmake/kconfig.cmake

diff --git a/examples/protocols/mqtt/tcp/sdkconfig b/examples/protocols/mqtt/tcp/sdkconfig
deleted file mode 100644 (file)
index 8b13789..0000000
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/examples/protocols/mqtt/tcp/sdkconfig.ci b/examples/protocols/mqtt/tcp/sdkconfig.ci
new file mode 100644 (file)
index 0000000..09ca8f3
--- /dev/null
@@ -0,0 +1,2 @@
+CONFIG_LOG_DEFAULT_LEVEL_DEBUG=y
+CONFIG_BROKER_URL="FROM_STDIN"
diff --git a/examples/protocols/mqtt/tcp/sdkconfig.defaults b/examples/protocols/mqtt/tcp/sdkconfig.defaults
deleted file mode 100644 (file)
index 51c8139..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-CONFIG_BROKER_URL="FROM_STDIN"
-CONFIG_LOG_DEFAULT_LEVEL_NONE=
-CONFIG_LOG_DEFAULT_LEVEL_ERROR=
-CONFIG_LOG_DEFAULT_LEVEL_WARN=
-CONFIG_LOG_DEFAULT_LEVEL_INFO=
-CONFIG_LOG_DEFAULT_LEVEL_DEBUG=y
-CONFIG_LOG_DEFAULT_LEVEL_VERBOSE=
index eb8a5993ae90968648c68c0c3734a15b79f6fe46..ab2b3213aea0eb269976a716c9945701626089f2 100755 (executable)
@@ -61,6 +61,7 @@ FAILED_EXAMPLES=""
 RESULT_ISSUES=22  # magic number result code for issues found
 LOG_SUSPECTED=${LOG_PATH}/common_log.txt
 touch ${LOG_SUSPECTED}
+SDKCONFIG_DEFAULTS_CI=sdkconfig.ci
 
 EXAMPLE_PATHS=$( find ${IDF_PATH}/examples/ -type f -name Makefile | grep -v "/build_system/cmake/" | sort )
 
@@ -132,6 +133,16 @@ build_example () {
         export EXTRA_CFLAGS=${PEDANTIC_CFLAGS}
         export EXTRA_CXXFLAGS=${EXTRA_CFLAGS}
 
+        # sdkconfig files are normally not checked into git, but may be present when
+        # a developer runs this script locally
+        rm -f sdkconfig
+
+        # If sdkconfig.ci file is present, append it to sdkconfig.defaults,
+        # replacing environment variables
+        if [[ -f "$SDKCONFIG_DEFAULTS_CI" ]]; then
+            cat $SDKCONFIG_DEFAULTS_CI | $IDF_PATH/tools/ci/envsubst.py >> sdkconfig.defaults
+        fi
+
         # build non-verbose first
         local BUILDLOG=${LOG_PATH}/ex_${ID}_log.txt
         touch ${BUILDLOG}
index 009cc220595518af2ac44bc50f32369abedfdfbf..b0039f9a9297188e0a5eeaa7466b7832f22db08d 100755 (executable)
@@ -64,6 +64,7 @@ FAILED_EXAMPLES=""
 RESULT_ISSUES=22  # magic number result code for issues found
 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 "/main/" | sort )
 
@@ -122,6 +123,16 @@ build_example () {
         export EXTRA_CFLAGS=${PEDANTIC_CFLAGS}
         export EXTRA_CXXFLAGS=${EXTRA_CFLAGS}
 
+        # sdkconfig files are normally not checked into git, but may be present when
+        # a developer runs this script locally
+        rm -f sdkconfig
+
+        # If sdkconfig.ci file is present, append it to sdkconfig.defaults,
+        # replacing environment variables
+        if [[ -f "$SDKCONFIG_DEFAULTS_CI" ]]; then
+            cat $SDKCONFIG_DEFAULTS_CI | $IDF_PATH/tools/ci/envsubst.py >> sdkconfig.defaults
+        fi
+
         # build non-verbose first
         local BUILDLOG=${LOG_PATH}/ex_${ID}_log.txt
         touch ${BUILDLOG}
@@ -130,7 +141,7 @@ build_example () {
             idf.py fullclean >>${BUILDLOG} 2>&1 &&
             idf.py build >>${BUILDLOG} 2>&1
         else
-            rm -rf build sdkconfig &&
+            rm -rf build &&
             ./build.sh >>${BUILDLOG} 2>&1
         fi &&
         cp build/flash_project_args build/download.config || # backwards compatible download.config filename
diff --git a/tools/ci/envsubst.py b/tools/ci/envsubst.py
new file mode 100755 (executable)
index 0000000..9d410f9
--- /dev/null
@@ -0,0 +1,27 @@
+#!/usr/bin/env python
+#
+# A script similar to GNU envsubst, but filters out
+# some CI related variables.
+
+import os
+import sys
+
+
+def main():
+    # Sanitize environment variables
+    vars_to_remove = []
+    for var_name in os.environ.iterkeys():
+        if var_name.startswith('CI_'):
+            vars_to_remove.append(var_name)
+    for var_name in vars_to_remove:
+        del os.environ[var_name]
+
+    for line in sys.stdin:
+        if not line:
+            break
+        sys.stdout.write(os.path.expandvars(line))
+    sys.stdout.flush()
+
+
+if __name__ == '__main__':
+    main()
index d021f0107828d631616b97ff7e258f0730de205a..47a533758b2d8d75f327223e022fb11b239a2865 100644 (file)
@@ -21,6 +21,7 @@ tools/ci/build_examples_cmake.sh
 tools/ci/check-executable.sh
 tools/ci/check-line-endings.sh
 tools/ci/checkout_project_ref.py
+tools/ci/envsubst.py
 tools/ci/get-full-sources.sh
 tools/ci/mirror-submodule-update.sh
 tools/ci/mirror-synchronize.sh
index 05976aca66bd9b9efda1de7002186b16f5c12c5b..84ac26fb673766535f64e821cf4a8d4f3d1a5c1f 100644 (file)
@@ -96,8 +96,8 @@ function(kconfig_process_config)
         set(defaults_arg --defaults "${IDF_SDKCONFIG_DEFAULTS}")
     endif()
 
-    if(EXISTS "${SDKCONFIG_DEFAULTS}.${IDF_TARGET}")
-        list(APPEND defaults_arg --defaults "${SDKCONFIG_DEFAULTS}.${IDF_TARGET}")
+    if(EXISTS "${IDF_SDKCONFIG_DEFAULTS}.${IDF_TARGET}")
+        list(APPEND defaults_arg --defaults "${IDF_SDKCONFIG_DEFAULTS}.${IDF_TARGET}")
     endif()
 
     # Set these in the parent scope, so that they can be written to project_description.json