esptool_py: use component property to simplify arg file generation
esptool_py used to create its own custom target to attach properties to. This commit uses component properties instead, and the APIs used to set and retrieve those properties in order to simplify generation of argument files to esptool.py.
This commit is contained in:
parent
265d7dc4e5
commit
4848dfa710
4 changed files with 21 additions and 24 deletions
|
@ -10,6 +10,15 @@ if(NOT BOOTLOADER_BUILD)
|
||||||
set(ESPTOOLPY_FLASH_PROJECT_OPTIONS "")
|
set(ESPTOOLPY_FLASH_PROJECT_OPTIONS "")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# FLASH_PROJECT_ARGS, FLASH_PROJECT_ARGS_JSON, FLASH_PROJECT_ARGS_ENTRY_JSON
|
||||||
|
# are used in the flasher args input files (flash_project_args.in, flasher_args.json.in)
|
||||||
|
idf_component_get_property(FLASH_PROJECT_ARGS ${COMPONENT_NAME}
|
||||||
|
FLASH_PROJECT_ARGS GENERATOR_EXPRESSION)
|
||||||
|
idf_component_get_property(FLASH_PROJECT_ARGS_JSON ${COMPONENT_NAME}
|
||||||
|
FLASH_PROJECT_ARGS_JSON GENERATOR_EXPRESSION)
|
||||||
|
idf_component_get_property(FLASH_PROJECT_ARGS_ENTRY_JSON ${COMPONENT_NAME}
|
||||||
|
FLASH_PROJECT_ARGS_ENTRY_JSON GENERATOR_EXPRESSION)
|
||||||
|
|
||||||
# Generate the flash project args and the flasher args json file using the accumulated values
|
# Generate the flash project args and the flasher args json file using the accumulated values
|
||||||
# from esptool_py_flash_project_args calls. The file is first configured using configure_file() for all variable values,
|
# from esptool_py_flash_project_args calls. The file is first configured using configure_file() for all variable values,
|
||||||
# and then generated using file(GENERATE... for generator expressions.
|
# and then generated using file(GENERATE... for generator expressions.
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
${ESPTOOLPY_FLASH_PROJECT_OPTIONS}
|
${ESPTOOLPY_FLASH_PROJECT_OPTIONS}
|
||||||
$<JOIN:$<TARGET_PROPERTY:flash_project_args_target,FLASH_PROJECT_ARGS>,
|
$<JOIN:${FLASH_PROJECT_ARGS},
|
||||||
>
|
>
|
|
@ -8,10 +8,10 @@
|
||||||
"flash_freq": "${ESPFLASHFREQ}"
|
"flash_freq": "${ESPFLASHFREQ}"
|
||||||
},
|
},
|
||||||
"flash_files" : {
|
"flash_files" : {
|
||||||
$<JOIN:$<TARGET_PROPERTY:flash_project_args_target,FLASH_PROJECT_ARGS_JSON>,,
|
$<JOIN:${FLASH_PROJECT_ARGS_JSON},,
|
||||||
>
|
>
|
||||||
},
|
},
|
||||||
$<JOIN:$<TARGET_PROPERTY:flash_project_args_target,FLASH_PROJECT_ARGS_ENTRY_JSON>,,
|
$<JOIN:${FLASH_PROJECT_ARGS_ENTRY_JSON},,
|
||||||
>,
|
>,
|
||||||
"extra_esptool_args" : {
|
"extra_esptool_args" : {
|
||||||
"after" : "${ESPTOOLPY_AFTER}",
|
"after" : "${ESPTOOLPY_AFTER}",
|
||||||
|
|
|
@ -149,9 +149,6 @@ if(CONFIG_SECURE_FLASH_ENCRYPTION_MODE_DEVELOPMENT)
|
||||||
esptool_py_custom_target(encrypted-app-flash encrypted_app "app")
|
esptool_py_custom_target(encrypted-app-flash encrypted_app "app")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
add_custom_target(flash_project_args_target)
|
|
||||||
|
|
||||||
# esptool_py_flash_project_args
|
# esptool_py_flash_project_args
|
||||||
#
|
#
|
||||||
# Add file to the flasher args list, to be flashed at a particular offset.
|
# Add file to the flasher args list, to be flashed at a particular offset.
|
||||||
|
@ -164,17 +161,14 @@ function(esptool_py_flash_project_args entry offset image)
|
||||||
# flash the image individually using esptool
|
# flash the image individually using esptool
|
||||||
cmake_parse_arguments(_ "${options}" "${single_value}" "" "${ARGN}")
|
cmake_parse_arguments(_ "${options}" "${single_value}" "" "${ARGN}")
|
||||||
|
|
||||||
idf_build_get_property(build_dir BUILD_DIR)
|
|
||||||
get_property(flash_project_entries TARGET flash_project_args_target PROPERTY FLASH_PROJECT_ENTRIES)
|
|
||||||
|
|
||||||
if(${entry} IN_LIST flash_project_entries)
|
if(${entry} IN_LIST flash_project_entries)
|
||||||
message(FATAL_ERROR "entry '${entry}' has already been added to flash project entries")
|
message(FATAL_ERROR "entry '${entry}' has already been added to flash project entries")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
list(APPEND flash_project_entries "${entry}")
|
idf_component_set_property(esptool_py FLASH_PROJECT_ENTRIES "${entry}" APPEND)
|
||||||
set_property(TARGET flash_project_args_target PROPERTY FLASH_PROJECT_ENTRIES "${flash_project_entries}")
|
|
||||||
|
|
||||||
file(RELATIVE_PATH image ${CMAKE_BINARY_DIR} ${image})
|
idf_build_get_property(build_dir BUILD_DIR)
|
||||||
|
file(RELATIVE_PATH image ${build_dir} ${image})
|
||||||
|
|
||||||
# Generate the standalone flash file to flash the image individually using esptool
|
# Generate the standalone flash file to flash the image individually using esptool
|
||||||
set(entry_flash_args ${build_dir}/flash_${entry}_args)
|
set(entry_flash_args ${build_dir}/flash_${entry}_args)
|
||||||
|
@ -201,21 +195,15 @@ function(esptool_py_flash_project_args entry offset image)
|
||||||
APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES ${entry_flash_args})
|
APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES ${entry_flash_args})
|
||||||
|
|
||||||
# Generate standalone entries in the flasher args json file
|
# Generate standalone entries in the flasher args json file
|
||||||
get_property(flash_project_args_entry_json TARGET
|
idf_component_set_property(esptool_py FLASH_PROJECT_ARGS_ENTRY_JSON
|
||||||
flash_project_args_target PROPERTY FLASH_PROJECT_ARGS_ENTRY_JSON)
|
"\"${entry}\" : { \"offset\" : \"${offset}\", \"file\" : \"${image}\" }" APPEND)
|
||||||
list(APPEND flash_project_args_entry_json
|
|
||||||
"\"${entry}\" : { \"offset\" : \"${offset}\", \"file\" : \"${image}\" }")
|
|
||||||
set_property(TARGET flash_project_args_target
|
|
||||||
PROPERTY FLASH_PROJECT_ARGS_ENTRY_JSON "${flash_project_args_entry_json}")
|
|
||||||
|
|
||||||
# Generate entries in the flasher args json file
|
# Generate entries in the flasher args json file
|
||||||
if(__FLASH_IN_PROJECT)
|
if(__FLASH_IN_PROJECT)
|
||||||
get_property(flash_project_args TARGET flash_project_args_target PROPERTY FLASH_PROJECT_ARGS)
|
idf_component_set_property(esptool_py FLASH_PROJECT_ARGS
|
||||||
list(APPEND flash_project_args "${offset} ${image}")
|
"${offset} ${image}" APPEND)
|
||||||
set_property(TARGET flash_project_args_target PROPERTY FLASH_PROJECT_ARGS "${flash_project_args}")
|
|
||||||
|
|
||||||
get_property(flash_project_args_json TARGET flash_project_args_target PROPERTY FLASH_PROJECT_ARGS_JSON)
|
idf_component_set_property(esptool_py FLASH_PROJECT_ARGS_JSON
|
||||||
list(APPEND flash_project_args_json "\"${offset}\" : \"${image}\"")
|
"\"${offset}\" : \"${image}\"" APPEND)
|
||||||
set_property(TARGET flash_project_args_target PROPERTY FLASH_PROJECT_ARGS_JSON "${flash_project_args_json}")
|
|
||||||
endif()
|
endif()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
Loading…
Reference in a new issue