]> granicus.if.org Git - esp-idf/commitdiff
esptool_py: use component property to simplify arg file generation
authorRenz Christian Bagaporo <renz@espressif.com>
Fri, 21 Jun 2019 04:18:29 +0000 (12:18 +0800)
committerRenz Christian Bagaporo <renz@espressif.com>
Fri, 28 Jun 2019 10:14:25 +0000 (18:14 +0800)
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.

components/esptool_py/CMakeLists.txt
components/esptool_py/flash_project_args.in
components/esptool_py/flasher_args.json.in
components/esptool_py/project_include.cmake

index c83cd52861e2b1ee5f740d8c8c028624f5a74c74..d30210531f43226fab91a4f8de2ce9e872441409 100644 (file)
@@ -10,6 +10,15 @@ if(NOT BOOTLOADER_BUILD)
         set(ESPTOOLPY_FLASH_PROJECT_OPTIONS "")
     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
     # 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.
index 640626af17c8be2211cd5a1459b80c6ae1d94e04..b6e3f8f9ee562f9a597a13bcee92f852db45328b 100644 (file)
@@ -1,3 +1,3 @@
 ${ESPTOOLPY_FLASH_PROJECT_OPTIONS}
-$<JOIN:$<TARGET_PROPERTY:flash_project_args_target,FLASH_PROJECT_ARGS>,
+$<JOIN:${FLASH_PROJECT_ARGS},
 >
\ No newline at end of file
index aa3aad2ccbaef56a3382835fba598354b0cc8edb..ca8693cc75b9974486abd29a88e7a9475104426a 100644 (file)
@@ -8,10 +8,10 @@
         "flash_freq": "${ESPFLASHFREQ}"
     },
     "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" : {
         "after"  : "${ESPTOOLPY_AFTER}",
index d4f8c3f936cf1cbefc4b1a99326639e1081acb3f..78dc03cbb0ee5ea36a3668095733dae1a4ce7361 100644 (file)
@@ -149,9 +149,6 @@ if(CONFIG_SECURE_FLASH_ENCRYPTION_MODE_DEVELOPMENT)
     esptool_py_custom_target(encrypted-app-flash encrypted_app "app")
 endif()
 
-
-add_custom_target(flash_project_args_target)
-
 # esptool_py_flash_project_args
 #
 # 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
     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)
         message(FATAL_ERROR "entry '${entry}' has already been added to flash project entries")
     endif()
 
-    list(APPEND flash_project_entries "${entry}")
-    set_property(TARGET flash_project_args_target PROPERTY FLASH_PROJECT_ENTRIES "${flash_project_entries}")
+    idf_component_set_property(esptool_py FLASH_PROJECT_ENTRIES "${entry}" APPEND)
 
-    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
     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})
 
     # Generate standalone entries in the flasher args json file
-    get_property(flash_project_args_entry_json TARGET
-                flash_project_args_target PROPERTY FLASH_PROJECT_ARGS_ENTRY_JSON)
-    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}")
+    idf_component_set_property(esptool_py FLASH_PROJECT_ARGS_ENTRY_JSON
+                "\"${entry}\" : { \"offset\" : \"${offset}\", \"file\" : \"${image}\" }" APPEND)
 
     # Generate entries in the flasher args json file
     if(__FLASH_IN_PROJECT)
-        get_property(flash_project_args TARGET flash_project_args_target PROPERTY FLASH_PROJECT_ARGS)
-        list(APPEND flash_project_args "${offset} ${image}")
-        set_property(TARGET flash_project_args_target PROPERTY FLASH_PROJECT_ARGS "${flash_project_args}")
+        idf_component_set_property(esptool_py FLASH_PROJECT_ARGS
+                                "${offset} ${image}" APPEND)
 
-        get_property(flash_project_args_json TARGET flash_project_args_target PROPERTY FLASH_PROJECT_ARGS_JSON)
-        list(APPEND flash_project_args_json "\"${offset}\" : \"${image}\"")
-        set_property(TARGET flash_project_args_target PROPERTY FLASH_PROJECT_ARGS_JSON "${flash_project_args_json}")
+        idf_component_set_property(esptool_py FLASH_PROJECT_ARGS_JSON
+                                "\"${offset}\" : \"${image}\"" APPEND)
     endif()
 endfunction()