From 6c0bc07605059f95e6a430d3a9d7d547a53fcdde Mon Sep 17 00:00:00 2001 From: Valeriy Koval Date: Fri, 19 May 2017 19:58:10 +0300 Subject: [PATCH] Handle situation when sdkconfig,h is missing --- builder/frameworks/espidf.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/builder/frameworks/espidf.py b/builder/frameworks/espidf.py index d693b35..a4200a4 100644 --- a/builder/frameworks/espidf.py +++ b/builder/frameworks/espidf.py @@ -20,9 +20,12 @@ Espressif IoT Development Framework for ESP32 MCU https://github.com/espressif/esp-idf """ +from glob import glob from os import listdir, walk from os.path import basename, isdir, isfile, join +from shutil import copy +import sys from SCons.Script import DefaultEnvironment @@ -267,6 +270,28 @@ env.Append( ] ) + +# +# Handle missing sdkconfig.h +# + +if not isfile(join(env.subst("$PROJECTSRC_DIR"), "sdkconfig.h")): + search_path = join( + env.subst("$PIOHOME_DIR"), "platforms", + env.subst("$PIOPLATFORM"), "examples", "*", "src", "sdkconfig.h" + ) + + files = glob(search_path) + if not files: + sys.stderr.write( + "Error: \"sdkconfig.h\" file is required for esp-idf framework!\n") + env.Exit(1) + + print("Warning! Cannot find \"sdk_config.h\" file. " + "Default \"sdk_config.h\" will be added to your project!") + copy(files[0], join(env.subst("$PROJECTSRC_DIR"), "sdkconfig.h")) + + # # Generate partition table #