Merge branch 'bugfix/efuse_summary_v5.1' into 'release/v5.1'

system-hardware/efuse: fixed efuse summary description containing ; breaking efuse-summary (v5.1)

See merge request espressif/esp-idf!23979
This commit is contained in:
Aditya Patwardhan 2023-05-31 22:57:37 +08:00
commit 7b09d12c89
2 changed files with 10 additions and 10 deletions

View File

@ -12,22 +12,22 @@ function(espefuse_cmd cmd output_log)
set(log ${SERIAL_TOOL_OUTPUT_LOG}) set(log ${SERIAL_TOOL_OUTPUT_LOG})
set(prefix_str " command ===") set(prefix_str " command ===")
string(FIND ${log} ${prefix_str} pos) string(FIND "${log}" ${prefix_str} pos)
if(${pos} GREATER -1) if(${pos} GREATER -1)
string(LENGTH ${prefix_str} len_of_prefix_str) string(LENGTH ${prefix_str} len_of_prefix_str)
math(EXPR pos "${pos} + ${len_of_prefix_str}") math(EXPR pos "${pos} + ${len_of_prefix_str}")
string(SUBSTRING ${log} ${pos} -1 final_log) string(SUBSTRING "${log}" ${pos} -1 final_log)
else() else()
set(final_log ${log}) set(final_log "${log}")
endif() endif()
set(${output_log} ${final_log} PARENT_SCOPE) set(${output_log} "${final_log}" PARENT_SCOPE)
endfunction() endfunction()
# Reads efuses "espefuse.py summary" and returns JSON string # Reads efuses "espefuse.py summary" and returns JSON string
function(espefuse_get_json_summary json_str) function(espefuse_get_json_summary json_str)
espefuse_cmd("summary;--format;json" output_log) espefuse_cmd("summary;--format;json" output_log)
set(${json_str} ${output_log} PARENT_SCOPE) set(${json_str} "${output_log}" PARENT_SCOPE)
endfunction() endfunction()
# See the esp-idf/docs/en/api-reference/system/efuse.rst "Get eFuses During Build". # See the esp-idf/docs/en/api-reference/system/efuse.rst "Get eFuses During Build".
@ -35,13 +35,13 @@ endfunction()
# It takes the efuse json string and returns a value of property for a given efuse name # It takes the efuse json string and returns a value of property for a given efuse name
function(espefuse_get_efuse result efuse_json efuse_name efuse_property) function(espefuse_get_efuse result efuse_json efuse_name efuse_property)
if(${CMAKE_VERSION} VERSION_LESS "3.19.0") if(${CMAKE_VERSION} VERSION_LESS "3.19.0")
string(REGEX MATCH "\"${efuse_name}\":[ \t\n\r]*\{[^\}]*\}" cur_efuse ${efuse_json}) string(REGEX MATCH "\"${efuse_name}\":[ \t\n\r]*\{[^\}]*\}" cur_efuse "${efuse_json}")
string(REGEX MATCH "\"${efuse_property}\":[ \t\n\r]*\"?([^,\"]*)\"?," ret_value ${cur_efuse}) string(REGEX MATCH "\"${efuse_property}\":[ \t\n\r]*\"?([^,\"]*)\"?," ret_value "${cur_efuse}")
set(${result} ${CMAKE_MATCH_1} PARENT_SCOPE) set(${result} ${CMAKE_MATCH_1} PARENT_SCOPE)
else() else()
# The JSON feature has been supported by Cmake since 3.19.0 # The JSON feature has been supported by Cmake since 3.19.0
string(JSON cur_efuse GET ${efuse_json} ${efuse_name}) string(JSON cur_efuse GET "${efuse_json}" ${efuse_name})
string(JSON ret_value GET ${cur_efuse} ${efuse_property}) string(JSON ret_value GET "${cur_efuse}" ${efuse_property})
set(${result} ${ret_value} PARENT_SCOPE) set(${result} ${ret_value} PARENT_SCOPE)
endif() endif()
endfunction() endfunction()

View File

@ -3,6 +3,6 @@ cmake_minimum_required(VERSION 3.16)
include(${esptool_py_dir}/espefuse.cmake) include(${esptool_py_dir}/espefuse.cmake)
espefuse_get_json_summary(efuse_json) espefuse_get_json_summary(efuse_json)
foreach(name ${efuse_names}) foreach(name ${efuse_names})
espefuse_get_efuse(ret_data ${efuse_json} ${name} "value") espefuse_get_efuse(ret_data "${efuse_json}" ${name} "value")
message(STATUS "FROM_CMAKE: ${name}: ${ret_data}") message(STATUS "FROM_CMAKE: ${name}: ${ret_data}")
endforeach() endforeach()