[core] Deleting CMakeCache.txt for fast recompilation with ESP-IDF (#8750)

This commit is contained in:
Aleksey Zinchenko 2025-07-02 10:37:31 +03:00 committed by GitHub
parent eba2c82fec
commit f6f0e52d5e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -107,6 +107,11 @@ def storage_should_clean(old: StorageJSON, new: StorageJSON) -> bool:
return True return True
if old.build_path != new.build_path: if old.build_path != new.build_path:
return True return True
return False
def storage_should_update_cmake_cache(old: StorageJSON, new: StorageJSON) -> bool:
if ( if (
old.loaded_integrations != new.loaded_integrations old.loaded_integrations != new.loaded_integrations
or old.loaded_platforms != new.loaded_platforms or old.loaded_platforms != new.loaded_platforms
@ -126,10 +131,11 @@ def update_storage_json():
return return
if storage_should_clean(old, new): if storage_should_clean(old, new):
_LOGGER.info( _LOGGER.info("Core config, version changed, cleaning build files...")
"Core config, version or integrations changed, cleaning build files..."
)
clean_build() clean_build()
elif storage_should_update_cmake_cache(old, new):
_LOGGER.info("Integrations changed, cleaning cmake cache...")
clean_cmake_cache()
new.save(path) new.save(path)
@ -353,6 +359,15 @@ def write_cpp(code_s):
write_file_if_changed(path, full_file) write_file_if_changed(path, full_file)
def clean_cmake_cache():
pioenvs = CORE.relative_pioenvs_path()
if os.path.isdir(pioenvs):
pioenvs_cmake_path = CORE.relative_pioenvs_path(CORE.name, "CMakeCache.txt")
if os.path.isfile(pioenvs_cmake_path):
_LOGGER.info("Deleting %s", pioenvs_cmake_path)
os.remove(pioenvs_cmake_path)
def clean_build(): def clean_build():
import shutil import shutil