mirror of
https://github.com/espressif/esp-idf.git
synced 2026-04-27 19:13:21 +00:00
fix(cmake): Fall back to version from components when git describe fails
When version.txt does not exist and git describe fails (e.g. in release archives or environments without git), IDF_VER was set to the raw git_describe output which resolves to "-128-NOTFOUND", causing esp_get_idf_version() to return a garbled string. Add a fallback that constructs the version string from the IDF_VERSION_MAJOR, IDF_VERSION_MINOR and IDF_VERSION_PATCH variables when git describe is not available. Closes https://github.com/espressif/esp-idf/issues/18240 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
This commit is contained in:
@@ -147,8 +147,10 @@ function(__build_get_idf_git_revision)
|
||||
if(EXISTS "${idf_path}/version.txt")
|
||||
file(STRINGS "${idf_path}/version.txt" idf_ver_t)
|
||||
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${idf_path}/version.txt")
|
||||
else()
|
||||
elseif(idf_ver_git)
|
||||
set(idf_ver_t ${idf_ver_git})
|
||||
else()
|
||||
set(idf_ver_t "v${IDF_VERSION_MAJOR}.${IDF_VERSION_MINOR}.${IDF_VERSION_PATCH}")
|
||||
endif()
|
||||
# cut IDF_VER to required 32 characters.
|
||||
string(SUBSTRING "${idf_ver_t}" 0 31 idf_ver)
|
||||
|
||||
Reference in New Issue
Block a user