79
79
PROJECT_DIR = env .subst ("$PROJECT_DIR" )
80
80
PROJECT_SRC_DIR = env .subst ("$PROJECT_SRC_DIR" )
81
81
CMAKE_API_REPLY_PATH = os .path .join (".cmake" , "api" , "v1" , "reply" )
82
+ SDKCONFIG_PATH = board .get (
83
+ "build.esp-idf.sdkconfig_path" ,
84
+ os .path .join (PROJECT_DIR , "sdkconfig.%s" % env .subst ("$PIOENV" )),
85
+ )
82
86
83
87
84
88
def get_project_lib_includes (env ):
@@ -105,7 +109,6 @@ def is_cmake_reconfigure_required(cmake_api_reply_dir):
105
109
os .path .join (PROJECT_SRC_DIR , "CMakeLists.txt" ),
106
110
]
107
111
cmake_preconf_dir = os .path .join (BUILD_DIR , "config" )
108
- sdkconfig = os .path .join (PROJECT_DIR , "sdkconfig" )
109
112
110
113
for d in (cmake_api_reply_dir , cmake_preconf_dir ):
111
114
if not os .path .isdir (d ) or not os .listdir (d ):
@@ -114,9 +117,9 @@ def is_cmake_reconfigure_required(cmake_api_reply_dir):
114
117
return True
115
118
if not os .path .isfile (os .path .join (BUILD_DIR , "build.ninja" )):
116
119
return True
117
- if os .path .isfile (sdkconfig ) and os . path . getmtime ( sdkconfig ) > os .path .getmtime (
118
- cmake_cache_file
119
- ):
120
+ if os .path .isfile (SDKCONFIG_PATH ) and os .path .getmtime (
121
+ SDKCONFIG_PATH
122
+ ) > os . path . getmtime ( cmake_cache_file ) :
120
123
return True
121
124
if any (
122
125
os .path .getmtime (f ) > os .path .getmtime (cmake_cache_file )
@@ -501,7 +504,7 @@ def generate_project_ld_script(sdk_config, ignore_targets=None):
501
504
502
505
args = {
503
506
"script" : os .path .join (FRAMEWORK_DIR , "tools" , "ldgen" , "ldgen.py" ),
504
- "config" : os . path . join ( PROJECT_DIR , "sdkconfig" ) ,
507
+ "config" : SDKCONFIG_PATH ,
505
508
"fragments" : " " .join (['"%s"' % f for f in project_files .get ("lf_files" )]),
506
509
"kconfig" : os .path .join (FRAMEWORK_DIR , "Kconfig" ),
507
510
"env_file" : os .path .join ("$BUILD_DIR" , "config.env" ),
@@ -699,7 +702,7 @@ def build_bootloader():
699
702
"-DPYTHON_DEPS_CHECKED=1" ,
700
703
"-DPYTHON=" + env .subst ("$PYTHONEXE" ),
701
704
"-DIDF_PATH=" + FRAMEWORK_DIR ,
702
- "-DSDKCONFIG=" + os . path . join ( PROJECT_DIR , "sdkconfig" ) ,
705
+ "-DSDKCONFIG=" + SDKCONFIG_PATH ,
703
706
"-DLEGACY_INCLUDE_COMMON_HEADERS=" ,
704
707
"-DEXTRA_COMPONENT_DIRS="
705
708
+ os .path .join (FRAMEWORK_DIR , "components" , "bootloader" ),
@@ -1147,10 +1150,16 @@ def _get_installed_pip_packages():
1147
1150
"-DPYTHON_DEPS_CHECKED=1" ,
1148
1151
"-DEXTRA_COMPONENT_DIRS:PATH=" + ";" .join (extra_components ),
1149
1152
"-DPYTHON=" + env .subst ("$PYTHONEXE" ),
1153
+ "-DSDKCONFIG=" + SDKCONFIG_PATH ,
1150
1154
]
1151
1155
+ click .parser .split_arg_string (board .get ("build.cmake_extra_args" , "" )),
1152
1156
)
1153
1157
1158
+ # At this point the sdkconfig file should be generated by the underlying build system
1159
+ assert os .path .isfile (SDKCONFIG_PATH ), (
1160
+ "Missing auto-generated SDK configuration file `%s`" % SDKCONFIG_PATH
1161
+ )
1162
+
1154
1163
if not project_codemodel :
1155
1164
sys .stderr .write ("Error: Couldn't find code model generated by CMake\n " )
1156
1165
env .Exit (1 )
0 commit comments