From bb4218285b03dd7d209bc0e97e93c617719426df Mon Sep 17 00:00:00 2001 From: Marius Vikhammer Date: Tue, 30 May 2023 10:55:27 +0800 Subject: [PATCH] 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. --- components/esptool_py/espefuse.cmake | 18 +++++++++--------- examples/system/efuse/get_efuse_summary.cmake | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/components/esptool_py/espefuse.cmake b/components/esptool_py/espefuse.cmake index d8c7d04256..8911f51942 100644 --- a/components/esptool_py/espefuse.cmake +++ b/components/esptool_py/espefuse.cmake @@ -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() diff --git a/examples/system/efuse/get_efuse_summary.cmake b/examples/system/efuse/get_efuse_summary.cmake index ecb0d2133c..26f090a880 100644 --- a/examples/system/efuse/get_efuse_summary.cmake +++ b/examples/system/efuse/get_efuse_summary.cmake @@ -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()