system-hardware/efuse: fixed efuse summary description containing ; breaking efuse-summary

If the efuse description from esptool contained semi-colons it would be interpretted as
a list delimiter in CMake. Summary is now passed as in quotes to escape this behavior.
pull/11584/head
Marius Vikhammer 2023-05-30 10:55:27 +08:00
rodzic 94ebc9ba4e
commit 93ba9d1cfe
2 zmienionych plików z 10 dodań i 10 usunięć

Wyświetl plik

@ -12,22 +12,22 @@ function(espefuse_cmd cmd output_log)
set(log ${SERIAL_TOOL_OUTPUT_LOG})
set(prefix_str " command ===")
string(FIND ${log} ${prefix_str} pos)
string(FIND "${log}" ${prefix_str} pos)
if(${pos} GREATER -1)
string(LENGTH ${prefix_str} 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()
set(final_log ${log})
set(final_log "${log}")
endif()
set(${output_log} ${final_log} PARENT_SCOPE)
set(${output_log} "${final_log}" PARENT_SCOPE)
endfunction()
# Reads efuses "espefuse.py summary" and returns JSON string
function(espefuse_get_json_summary json_str)
espefuse_cmd("summary;--format;json" output_log)
set(${json_str} ${output_log} PARENT_SCOPE)
set(${json_str} "${output_log}" PARENT_SCOPE)
endfunction()
# 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
function(espefuse_get_efuse result efuse_json efuse_name efuse_property)
if(${CMAKE_VERSION} VERSION_LESS "3.19.0")
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_name}\":[ \t\n\r]*\{[^\}]*\}" cur_efuse "${efuse_json}")
string(REGEX MATCH "\"${efuse_property}\":[ \t\n\r]*\"?([^,\"]*)\"?," ret_value "${cur_efuse}")
set(${result} ${CMAKE_MATCH_1} PARENT_SCOPE)
else()
# The JSON feature has been supported by Cmake since 3.19.0
string(JSON cur_efuse GET ${efuse_json} ${efuse_name})
string(JSON ret_value GET ${cur_efuse} ${efuse_property})
string(JSON cur_efuse GET "${efuse_json}" ${efuse_name})
string(JSON ret_value GET "${cur_efuse}" ${efuse_property})
set(${result} ${ret_value} PARENT_SCOPE)
endif()
endfunction()

Wyświetl plik

@ -3,6 +3,6 @@ cmake_minimum_required(VERSION 3.16)
include(${esptool_py_dir}/espefuse.cmake)
espefuse_get_json_summary(efuse_json)
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}")
endforeach()