mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-02 11:10:54 +03:00
fix(cmakev2/build): extend idf_build_generate_metadata to also accept executable
Currently, idf_build_generate_metadata only accepts binary targets for which it generates metadata (project_description.json). On Linux targets, binary images are not generated, but we still need to generate project_description.json. Extend the current function to accept both executable and binary targets and ensure project_description.json is generated when a Linux target is used. Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
This commit is contained in:
+34
-21
@@ -715,35 +715,55 @@ endfunction()
|
|||||||
|
|
||||||
.. code-block:: cmake
|
.. code-block:: cmake
|
||||||
|
|
||||||
idf_build_generate_metadata(<binary>
|
idf_build_generate_metadata([BINARY <binary>]
|
||||||
|
[EXECUTABLE <executable>]
|
||||||
[OUTPUT_FILE <file>])
|
[OUTPUT_FILE <file>])
|
||||||
|
|
||||||
*binary[in]*
|
*BINARY[in,opt]*
|
||||||
|
|
||||||
Binary target for which to generate a metadata file.
|
Binary target for which to generate a metadata file.
|
||||||
|
|
||||||
|
*EXECUTABLE[in,opt]*
|
||||||
|
|
||||||
|
Executable target for which to generate a metadata file.
|
||||||
|
|
||||||
*OUTPUT_FILE[in,opt]*
|
*OUTPUT_FILE[in,opt]*
|
||||||
|
|
||||||
Optional output file path for storing the metadata. If not provided,
|
Optional output file path for storing the metadata. If not provided,
|
||||||
the default path ``<build>/project_description.json`` is used.
|
the default path ``<build>/project_description.json`` is used.
|
||||||
|
|
||||||
Generate metadata for the specified ``binary`` and store it in the
|
Generate metadata for the specified ``binary`` or ``executable`` target and
|
||||||
specified ``OUTPUT_FILE``. If no ``OUTPUT_FILE`` is provided, the default
|
store it in the specified ``OUTPUT_FILE``. If no ``OUTPUT_FILE`` is
|
||||||
location ``<build>/project_description.json`` will be used.
|
provided, the default location ``<build>/project_description.json`` will be
|
||||||
|
used.
|
||||||
#]]
|
#]]
|
||||||
function(idf_build_generate_metadata binary)
|
function(idf_build_generate_metadata)
|
||||||
set(options)
|
set(options)
|
||||||
set(one_value OUTPUT_FILE)
|
set(one_value OUTPUT_FILE BINARY EXECUTABLE)
|
||||||
set(multi_value)
|
set(multi_value)
|
||||||
cmake_parse_arguments(ARG "${options}" "${one_value}" "${multi_value}" ${ARGN})
|
cmake_parse_arguments(ARG "${options}" "${one_value}" "${multi_value}" ${ARGN})
|
||||||
|
|
||||||
# The EXECUTABLE_TARGET property is set by the idf_build_binary or
|
if(NOT DEFINED ARG_BINARY AND NOT DEFINED ARG_EXECUTABLE)
|
||||||
# the idf_sign_binary function.
|
idf_die("BINARY or EXECUTABLE option is required")
|
||||||
get_target_property(executable "${binary}" EXECUTABLE_TARGET)
|
|
||||||
if(NOT executable)
|
|
||||||
idf_die("Binary target '${binary}' is missing 'EXECUTABLE_TARGET' property.")
|
|
||||||
endif()
|
endif()
|
||||||
__get_executable_library_or_die(TARGET "${executable}" OUTPUT library)
|
|
||||||
|
if(DEFINED ARG_BINARY)
|
||||||
|
# The EXECUTABLE_TARGET property is set by the idf_build_binary or
|
||||||
|
# the idf_sign_binary function.
|
||||||
|
get_target_property(ARG_EXECUTABLE "${ARG_BINARY}" EXECUTABLE_TARGET)
|
||||||
|
if(NOT ARG_EXECUTABLE)
|
||||||
|
idf_die("Binary target '${ARG_BINARY}' is missing 'EXECUTABLE_TARGET' property.")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# The BINARY_PATH property is set by the idf_build_binary or
|
||||||
|
# the idf_sign_binary function.
|
||||||
|
get_target_property(binary_path ${ARG_BINARY} BINARY_PATH)
|
||||||
|
if(NOT binary_path)
|
||||||
|
idf_die("Binary target '${ARG_BINARY}' is missing 'BINARY_PATH' property.")
|
||||||
|
endif()
|
||||||
|
get_filename_component(PROJECT_BIN "${binary_path}" NAME)
|
||||||
|
endif()
|
||||||
|
__get_executable_library_or_die(TARGET "${ARG_EXECUTABLE}" OUTPUT library)
|
||||||
|
|
||||||
idf_build_get_property(PROJECT_NAME PROJECT_NAME)
|
idf_build_get_property(PROJECT_NAME PROJECT_NAME)
|
||||||
idf_build_get_property(PROJECT_VER PROJECT_VER)
|
idf_build_get_property(PROJECT_VER PROJECT_VER)
|
||||||
@@ -752,14 +772,7 @@ function(idf_build_generate_metadata binary)
|
|||||||
idf_build_get_property(BUILD_DIR BUILD_DIR)
|
idf_build_get_property(BUILD_DIR BUILD_DIR)
|
||||||
idf_build_get_property(SDKCONFIG SDKCONFIG)
|
idf_build_get_property(SDKCONFIG SDKCONFIG)
|
||||||
idf_build_get_property(SDKCONFIG_DEFAULTS SDKCONFIG_DEFAULTS)
|
idf_build_get_property(SDKCONFIG_DEFAULTS SDKCONFIG_DEFAULTS)
|
||||||
set(PROJECT_EXECUTABLE "$<TARGET_FILE_NAME:${executable}>")
|
set(PROJECT_EXECUTABLE "$<TARGET_FILE_NAME:${ARG_EXECUTABLE}>")
|
||||||
# The BINARY_PATH property is set by the idf_build_binary or
|
|
||||||
# the idf_sign_binary function.
|
|
||||||
get_target_property(binary_path ${binary} BINARY_PATH)
|
|
||||||
if(NOT binary_path)
|
|
||||||
idf_die("Binary target '${binary}' is missing 'BINARY_PATH' property.")
|
|
||||||
endif()
|
|
||||||
get_filename_component(PROJECT_BIN "${binary_path}" NAME)
|
|
||||||
if(NOT PROJECT_BIN)
|
if(NOT PROJECT_BIN)
|
||||||
set(PROJECT_BIN "")
|
set(PROJECT_BIN "")
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
@@ -731,7 +731,7 @@ function(__project_default)
|
|||||||
TARGET app-flash
|
TARGET app-flash
|
||||||
NAME "app"
|
NAME "app"
|
||||||
FLASH)
|
FLASH)
|
||||||
idf_build_generate_metadata("${executable}_binary_signed")
|
idf_build_generate_metadata(BINARY "${executable}_binary_signed")
|
||||||
else()
|
else()
|
||||||
idf_build_binary("${executable}"
|
idf_build_binary("${executable}"
|
||||||
OUTPUT_FILE "${build_dir}/${executable}.bin"
|
OUTPUT_FILE "${build_dir}/${executable}.bin"
|
||||||
@@ -748,10 +748,12 @@ function(__project_default)
|
|||||||
|
|
||||||
idf_create_dfu("${executable}_binary"
|
idf_create_dfu("${executable}_binary"
|
||||||
TARGET dfu)
|
TARGET dfu)
|
||||||
idf_build_generate_metadata("${executable}_binary")
|
idf_build_generate_metadata(BINARY "${executable}_binary")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
idf_build_generate_flasher_args()
|
idf_build_generate_flasher_args()
|
||||||
|
else()
|
||||||
|
idf_build_generate_metadata(EXECUTABLE "${executable}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
idf_create_menuconfig("${executable}"
|
idf_create_menuconfig("${executable}"
|
||||||
|
|||||||
@@ -232,7 +232,7 @@ function(test_executable)
|
|||||||
NAME fatfs_example)
|
NAME fatfs_example)
|
||||||
idf_create_menuconfig(fatfs_example
|
idf_create_menuconfig(fatfs_example
|
||||||
TARGET menuconfig-fatfs)
|
TARGET menuconfig-fatfs)
|
||||||
idf_build_generate_metadata(fatfs_example_bin
|
idf_build_generate_metadata(BINARY fatfs_example_bin
|
||||||
OUTPUT_FILE project_description_fatfs.json)
|
OUTPUT_FILE project_description_fatfs.json)
|
||||||
idf_build_generate_depgraph(fatfs_example
|
idf_build_generate_depgraph(fatfs_example
|
||||||
OUTPUT_FILE component_deps_fatfs.dot)
|
OUTPUT_FILE component_deps_fatfs.dot)
|
||||||
@@ -257,7 +257,7 @@ function(test_executable)
|
|||||||
NAME hello_world_example)
|
NAME hello_world_example)
|
||||||
idf_create_menuconfig(hello_world_example
|
idf_create_menuconfig(hello_world_example
|
||||||
TARGET menuconfig-hello_world)
|
TARGET menuconfig-hello_world)
|
||||||
idf_build_generate_metadata(hello_world_example_bin
|
idf_build_generate_metadata(BINARY hello_world_example_bin
|
||||||
OUTPUT_FILE project_description_hello_world.json)
|
OUTPUT_FILE project_description_hello_world.json)
|
||||||
idf_build_generate_depgraph(hello_world_example
|
idf_build_generate_depgraph(hello_world_example
|
||||||
OUTPUT_FILE component_deps_hello_world.dot)
|
OUTPUT_FILE component_deps_hello_world.dot)
|
||||||
|
|||||||
Reference in New Issue
Block a user