Skip to content

Commit 46b0e61

Browse files
committed
Add env-specific suffix to distinguish "sdkconfig" files
Resolve platformio#539
1 parent b073ed8 commit 46b0e61

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

builder/frameworks/espidf.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@
7979
PROJECT_DIR = env.subst("$PROJECT_DIR")
8080
PROJECT_SRC_DIR = env.subst("$PROJECT_SRC_DIR")
8181
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+
)
8286

8387

8488
def get_project_lib_includes(env):
@@ -105,7 +109,6 @@ def is_cmake_reconfigure_required(cmake_api_reply_dir):
105109
os.path.join(PROJECT_SRC_DIR, "CMakeLists.txt"),
106110
]
107111
cmake_preconf_dir = os.path.join(BUILD_DIR, "config")
108-
sdkconfig = os.path.join(PROJECT_DIR, "sdkconfig")
109112

110113
for d in (cmake_api_reply_dir, cmake_preconf_dir):
111114
if not os.path.isdir(d) or not os.listdir(d):
@@ -114,9 +117,9 @@ def is_cmake_reconfigure_required(cmake_api_reply_dir):
114117
return True
115118
if not os.path.isfile(os.path.join(BUILD_DIR, "build.ninja")):
116119
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):
120123
return True
121124
if any(
122125
os.path.getmtime(f) > os.path.getmtime(cmake_cache_file)
@@ -501,7 +504,7 @@ def generate_project_ld_script(sdk_config, ignore_targets=None):
501504

502505
args = {
503506
"script": os.path.join(FRAMEWORK_DIR, "tools", "ldgen", "ldgen.py"),
504-
"config": os.path.join(PROJECT_DIR, "sdkconfig"),
507+
"config": SDKCONFIG_PATH,
505508
"fragments": " ".join(['"%s"' % f for f in project_files.get("lf_files")]),
506509
"kconfig": os.path.join(FRAMEWORK_DIR, "Kconfig"),
507510
"env_file": os.path.join("$BUILD_DIR", "config.env"),
@@ -699,7 +702,7 @@ def build_bootloader():
699702
"-DPYTHON_DEPS_CHECKED=1",
700703
"-DPYTHON=" + env.subst("$PYTHONEXE"),
701704
"-DIDF_PATH=" + FRAMEWORK_DIR,
702-
"-DSDKCONFIG=" + os.path.join(PROJECT_DIR, "sdkconfig"),
705+
"-DSDKCONFIG=" + SDKCONFIG_PATH,
703706
"-DLEGACY_INCLUDE_COMMON_HEADERS=",
704707
"-DEXTRA_COMPONENT_DIRS="
705708
+ os.path.join(FRAMEWORK_DIR, "components", "bootloader"),
@@ -1147,10 +1150,16 @@ def _get_installed_pip_packages():
11471150
"-DPYTHON_DEPS_CHECKED=1",
11481151
"-DEXTRA_COMPONENT_DIRS:PATH=" + ";".join(extra_components),
11491152
"-DPYTHON=" + env.subst("$PYTHONEXE"),
1153+
"-DSDKCONFIG=" + SDKCONFIG_PATH,
11501154
]
11511155
+ click.parser.split_arg_string(board.get("build.cmake_extra_args", "")),
11521156
)
11531157

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+
11541163
if not project_codemodel:
11551164
sys.stderr.write("Error: Couldn't find code model generated by CMake\n")
11561165
env.Exit(1)

0 commit comments

Comments
 (0)