cmake: bintools abstraction, support <command>_flag_final property
This command add support for `<command>_flag_final` to all bintools commands. This allows users that has special use-cases to use a CMake script for bintool command execution, and thereby have full control of command invocation and argument processing. Example of how to specify the property for such use: Calling a custom script for elfconvert command: set_property(TARGET bintools PROPERTY elfconvert_command ${CMAKE_COMMAND}) set_property(TARGET bintools PROPERTY elfconvert_flag "") set_property(TARGET bintools PROPERTY elfconvert_flag_final -P elfconvert.cmake) set_property(TARGET bintools PROPERTY elfconvert_flag_strip_all "-DSTRIP_ALL=True") set_property(TARGET bintools PROPERTY elfconvert_flag_infile "-DINFILE=") set_property(TARGET bintools PROPERTY elfconvert_flag_outfile "-DOUT_FILE=") Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
This commit is contained in:
parent
e0758c317c
commit
f160dee935
|
@ -726,6 +726,7 @@ if(CONFIG_GEN_ISR_TABLES)
|
|||
$<TARGET_PROPERTY:bintools,elfconvert_flag_section_only>.intList
|
||||
$<TARGET_PROPERTY:bintools,elfconvert_flag_infile>$<TARGET_FILE:${ZEPHYR_PREBUILT_EXECUTABLE}>
|
||||
$<TARGET_PROPERTY:bintools,elfconvert_flag_outfile>isrList.bin
|
||||
$<TARGET_PROPERTY:bintools,elfconvert_flag_final>
|
||||
COMMAND ${PYTHON_EXECUTABLE}
|
||||
${ZEPHYR_BASE}/arch/common/gen_isr_tables.py
|
||||
--output-source isr_tables.c
|
||||
|
@ -864,6 +865,7 @@ if(CONFIG_USERSPACE)
|
|||
$<TARGET_PROPERTY:bintools,elfconvert_flag_section_rename>.rodata=.kobject_data.rodata
|
||||
$<TARGET_PROPERTY:bintools,elfconvert_flag_infile>${OUTPUT_OBJ_PATH}
|
||||
$<TARGET_PROPERTY:bintools,elfconvert_flag_outfile>${OUTPUT_OBJ_RENAMED}
|
||||
$<TARGET_PROPERTY:bintools,elfconvert_flag_final>
|
||||
DEPENDS output_lib
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
COMMAND_EXPAND_LISTS
|
||||
|
@ -1114,6 +1116,7 @@ if(CONFIG_BUILD_OUTPUT_HEX OR BOARD_FLASH_RUNNER STREQUAL openocd)
|
|||
$<TARGET_PROPERTY:bintools,elfconvert_flag_section_remove>.eh_frame
|
||||
$<TARGET_PROPERTY:bintools,elfconvert_flag_infile>${KERNEL_ELF_NAME}
|
||||
$<TARGET_PROPERTY:bintools,elfconvert_flag_outfile>${KERNEL_HEX_NAME}
|
||||
$<TARGET_PROPERTY:bintools,elfconvert_flag_final>
|
||||
)
|
||||
list(APPEND
|
||||
post_build_byproducts
|
||||
|
@ -1137,6 +1140,7 @@ if(CONFIG_BUILD_OUTPUT_BIN)
|
|||
$<TARGET_PROPERTY:bintools,elfconvert_flag_section_remove>.eh_frame
|
||||
$<TARGET_PROPERTY:bintools,elfconvert_flag_infile>${KERNEL_ELF_NAME}
|
||||
$<TARGET_PROPERTY:bintools,elfconvert_flag_outfile>${KERNEL_BIN_NAME}
|
||||
$<TARGET_PROPERTY:bintools,elfconvert_flag_final>
|
||||
)
|
||||
list(APPEND
|
||||
post_build_byproducts
|
||||
|
@ -1159,6 +1163,7 @@ if(CONFIG_BUILD_OUTPUT_S19)
|
|||
$<TARGET_PROPERTY:bintools,elfconvert_flag_srec_len>1
|
||||
$<TARGET_PROPERTY:bintools,elfconvert_flag_infile>${KERNEL_ELF_NAME}
|
||||
$<TARGET_PROPERTY:bintools,elfconvert_flag_outfile>${KERNEL_S19_NAME}
|
||||
$<TARGET_PROPERTY:bintools,elfconvert_flag_final>
|
||||
)
|
||||
list(APPEND
|
||||
post_build_byproducts
|
||||
|
@ -1182,6 +1187,7 @@ if(CONFIG_OUTPUT_DISASSEMBLE_ALL)
|
|||
${disassembly_type}
|
||||
$<TARGET_PROPERTY:bintools,disassembly_flag_infile>${KERNEL_ELF_NAME}
|
||||
$<TARGET_PROPERTY:bintools,disassembly_flag_outfile>${KERNEL_LST_NAME}
|
||||
$<TARGET_PROPERTY:bintools,disassembly_flag_final>
|
||||
)
|
||||
list(APPEND
|
||||
post_build_byproducts
|
||||
|
@ -1199,6 +1205,7 @@ if(CONFIG_OUTPUT_STAT)
|
|||
$<TARGET_PROPERTY:bintools,readelf_flag_headers>
|
||||
$<TARGET_PROPERTY:bintools,readelf_flag_infile> ${KERNEL_ELF_NAME}
|
||||
$<TARGET_PROPERTY:bintools,readelf_flag_outfile> ${KERNEL_STAT_NAME}
|
||||
$<TARGET_PROPERTY:bintools,readelf_flag_final>
|
||||
)
|
||||
list(APPEND
|
||||
post_build_byproducts
|
||||
|
@ -1214,6 +1221,7 @@ if(CONFIG_BUILD_OUTPUT_STRIPPED)
|
|||
$<TARGET_PROPERTY:bintools,strip_flag_all>
|
||||
$<TARGET_PROPERTY:bintools,strip_flag_infile>${KERNEL_ELF_NAME}
|
||||
$<TARGET_PROPERTY:bintools,strip_flag_outfile>${KERNEL_STRIP_NAME}
|
||||
$<TARGET_PROPERTY:bintools,strip_flag_final>
|
||||
)
|
||||
list(APPEND
|
||||
post_build_byproducts
|
||||
|
|
|
@ -31,6 +31,21 @@
|
|||
# To disable the message, simply silence the command with:
|
||||
# set_property(TARGET bintools PROPERTY <command>_command ${CMAKE_COMMAND} -E echo "")
|
||||
#
|
||||
# The bintools properties are made generic so that implementing support for an
|
||||
# additional native tool should be as easy as possible.
|
||||
# However, there might be tools and/or use cases where the current property
|
||||
# scheme does not cover the exact needs. For those use-cases it is possible
|
||||
# to implement the call to a native tool inside a CMake script.
|
||||
# For example, to call a custom script for elfconvert command, one can specify:
|
||||
# set_property(TARGET bintools PROPERTY elfconvert_command ${CMAKE_COMMAND})
|
||||
# set_property(TARGET bintools PROPERTY elfconvert_flag "")
|
||||
# set_property(TARGET bintools PROPERTY elfconvert_flag_final -P custom_elfconvert.cmake)
|
||||
# set_property(TARGET bintools PROPERTY elfconvert_flag_strip_all "-DSTRIP_ALL=True")
|
||||
# set_property(TARGET bintools PROPERTY elfconvert_flag_infile "-DINFILE=")
|
||||
# set_property(TARGET bintools PROPERTY elfconvert_flag_outfile "-DOUT_FILE=")
|
||||
|
||||
#
|
||||
#
|
||||
# bintools property overview of all commands:
|
||||
#
|
||||
# Command:
|
||||
|
@ -38,6 +53,7 @@
|
|||
# Note: For gcc compilers this command is not used,
|
||||
# instead a linker flag is used for this)
|
||||
# memusage_flag : Flags that must always be applied when calling memusage command
|
||||
# memusage_flag_final : Flags that must always be applied last at the memusage command
|
||||
# memusage_byproducts : Byproducts (files) generated when calling memusage
|
||||
#
|
||||
#
|
||||
|
@ -45,6 +61,7 @@
|
|||
# For GNU binary utilities this is objcopy
|
||||
# elfconvert_formats : Formats supported by this command.
|
||||
# elfconvert_flag : Flags that must always be applied when calling elfconvert command
|
||||
# elfconvert_flag_final : Flags that must always be applied last at the elfconvert command
|
||||
# elfconvert_flag_strip_all : Flag that is used for stripping all symbols when converting
|
||||
# elfconvert_flag_strip_debug : Flag that is used to strip debug symbols when converting
|
||||
# elfconvert_flag_intarget : Flag for specifying target used for infile
|
||||
|
@ -63,6 +80,7 @@
|
|||
# - disassembly : Name of command for disassembly of files
|
||||
# For GNU binary utilities this is objdump
|
||||
# disassembly_flag : Flags that must always be applied when calling disassembly command
|
||||
# disassembly_flag_final : Flags that must always be applied last at the disassembly command
|
||||
# disassembly_flag_inline_source : Flag to use to display source code mixed with disassembly
|
||||
# disassembly_flag_all : Flag to use for disassemble everything, including zeroes
|
||||
# disassembly_flag_infile : Flag for specifying the input file
|
||||
|
@ -73,6 +91,7 @@
|
|||
# - readelf : Name of command for reading elf files.
|
||||
# For GNU binary utilities this is readelf
|
||||
# readelf_flag : Flags that must always be applied when calling readelf command
|
||||
# readelf_flag_final : Flags that must always be applied last at the readelf command
|
||||
# readelf_flag_headers : Flag to use for specifying ELF headers should be read
|
||||
# readelf_flag_infile : Flag for specifying the input file
|
||||
# readelf_flag_outfile : Flag for specifying the output file
|
||||
|
@ -82,6 +101,7 @@
|
|||
# - strip: Name of command for stripping symbols
|
||||
# For GNU binary utilities this is strip
|
||||
# strip_flag : Flags that must always be applied when calling strip command
|
||||
# strip_flag_final : Flags that must always be applied last at the strip command
|
||||
# strip_flag_all : Flag for removing all symbols
|
||||
# strip_flag_debug : Flag for removing debug symbols
|
||||
# strip_flag_dwo : Flag for removing dwarf sections
|
||||
|
@ -96,11 +116,13 @@ set(COMMAND_NOT_SUPPORTED "command not supported on bintools: ")
|
|||
# set_property(TARGET linker ... ) found in cmake/linker/linker_flags.cmake instead
|
||||
set_property(TARGET bintools PROPERTY memusage_command "")
|
||||
set_property(TARGET bintools PROPERTY memusage_flag "")
|
||||
set_property(TARGET bintools PROPERTY memusage_flag_final "")
|
||||
set_property(TARGET bintools PROPERTY memusage_byproducts "")
|
||||
|
||||
# disassembly command to use for generation of list file.
|
||||
set_property(TARGET bintools PROPERTY disassembly_command ${CMAKE_COMMAND} -E echo "disassembly ${COMMAND_NOT_SUPPORTED} ${BINTOOLS}")
|
||||
set_property(TARGET bintools PROPERTY disassembly_flag "")
|
||||
set_property(TARGET bintools PROPERTY disassembly_flag_final "")
|
||||
set_property(TARGET bintools PROPERTY disassembly_flag_inline_source "")
|
||||
set_property(TARGET bintools PROPERTY disassembly_flag_infile "")
|
||||
set_property(TARGET bintools PROPERTY disassembly_flag_outfile "")
|
||||
|
@ -109,6 +131,7 @@ set_property(TARGET bintools PROPERTY disassembly_flag_outfile "")
|
|||
set_property(TARGET bintools PROPERTY elfconvert_command ${CMAKE_COMMAND} -E echo "elfconvert ${COMMAND_NOT_SUPPORTED} ${BINTOOLS}")
|
||||
set_property(TARGET bintools PROPERTY elfconvert_formats "")
|
||||
set_property(TARGET bintools PROPERTY elfconvert_flag "")
|
||||
set_property(TARGET bintools PROPERTY elfconvert_flag_final "")
|
||||
set_property(TARGET bintools PROPERTY elfconvert_flag_outtarget "")
|
||||
set_property(TARGET bintools PROPERTY elfconvert_flag_section_remove "")
|
||||
set_property(TARGET bintools PROPERTY elfconvert_flag_gapfill "")
|
||||
|
@ -118,6 +141,7 @@ set_property(TARGET bintools PROPERTY elfconvert_flag_outfile "")
|
|||
# readelf for processing of elf files.
|
||||
set_property(TARGET bintools PROPERTY readelf_command ${CMAKE_COMMAND} -E echo "readelf ${COMMAND_NOT_SUPPORTED} ${BINTOOLS}")
|
||||
set_property(TARGET bintools PROPERTY readelf_flag "")
|
||||
set_property(TARGET bintools PROPERTY readelf_flag_final "")
|
||||
set_property(TARGET bintools PROPERTY readelf_flag_headers "")
|
||||
set_property(TARGET bintools PROPERTY readelf_flag_infile "")
|
||||
set_property(TARGET bintools PROPERTY readelf_flag_outfile "")
|
||||
|
@ -125,6 +149,7 @@ set_property(TARGET bintools PROPERTY readelf_flag_outfile "")
|
|||
# strip command for stripping symbols
|
||||
set_property(TARGET bintools PROPERTY strip_command ${CMAKE_COMMAND} -E echo "strip ${COMMAND_NOT_SUPPORTED} ${BINTOOLS}")
|
||||
set_property(TARGET bintools PROPERTY strip_flag "")
|
||||
set_property(TARGET bintools PROPERTY strip_flag_final "")
|
||||
set_property(TARGET bintools PROPERTY strip_flag_all "")
|
||||
set_property(TARGET bintools PROPERTY strip_flag_debug "")
|
||||
set_property(TARGET bintools PROPERTY strip_flag_dwo "")
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
# In this implementation `objcopy` is used
|
||||
# elfconvert_formats : Formats supported: ihex, srec, binary
|
||||
# elfconvert_flag : empty
|
||||
# elfconvert_flag_final : empty
|
||||
# elfconvert_flag_strip_all : -S
|
||||
# elfconvert_flag_strip_debug : -g
|
||||
# elfconvert_flag_intarget : --input-target=
|
||||
|
@ -28,6 +29,7 @@ set_property(TARGET bintools PROPERTY elfconvert_command ${CMAKE_OBJCOPY})
|
|||
set_property(TARGET bintools PROPERTY elfconvert_formats ihex srec binary)
|
||||
|
||||
set_property(TARGET bintools PROPERTY elfconvert_flag "")
|
||||
set_property(TARGET bintools PROPERTY elfconvert_flag_final "")
|
||||
|
||||
set_property(TARGET bintools PROPERTY elfconvert_flag_strip_all "-S")
|
||||
set_property(TARGET bintools PROPERTY elfconvert_flag_strip_debug "-g")
|
||||
|
@ -53,6 +55,7 @@ set_property(TARGET bintools PROPERTY elfconvert_flag_outfile "")
|
|||
# - disassembly : Name of command for disassembly of files
|
||||
# In this implementation `objdump` is used
|
||||
# disassembly_flag : -d
|
||||
# disassembly_flag_final : empty
|
||||
# disassembly_flag_inline_source : -S
|
||||
# disassembly_flag_all : -SDz
|
||||
# disassembly_flag_infile : empty, objdump doesn't take arguments for filenames
|
||||
|
@ -60,6 +63,7 @@ set_property(TARGET bintools PROPERTY elfconvert_flag_outfile "")
|
|||
|
||||
set_property(TARGET bintools PROPERTY disassembly_command ${CMAKE_OBJDUMP})
|
||||
set_property(TARGET bintools PROPERTY disassembly_flag -d)
|
||||
set_property(TARGET bintools PROPERTY disassembly_flag_final "")
|
||||
set_property(TARGET bintools PROPERTY disassembly_flag_inline_source -S)
|
||||
set_property(TARGET bintools PROPERTY disassembly_flag_all -SDz)
|
||||
|
||||
|
@ -70,6 +74,7 @@ set_property(TARGET bintools PROPERTY disassembly_flag_outfile > )
|
|||
# - strip: Name of command for stripping symbols
|
||||
# In this implementation `strip` is used
|
||||
# strip_flag : empty
|
||||
# strip_flag_final : empty
|
||||
# strip_flag_all : --strip-all
|
||||
# strip_flag_debug : --strip-debug
|
||||
# strip_flag_dwo : --strip-dwo
|
||||
|
@ -81,6 +86,7 @@ set_property(TARGET bintools PROPERTY strip_command ${CMAKE_STRIP})
|
|||
|
||||
# Any flag the strip command requires for processing
|
||||
set_property(TARGET bintools PROPERTY strip_flag "")
|
||||
set_property(TARGET bintools PROPERTY strip_flag_final "")
|
||||
|
||||
set_property(TARGET bintools PROPERTY strip_flag_all --strip-all)
|
||||
set_property(TARGET bintools PROPERTY strip_flag_debug --strip-debug)
|
||||
|
@ -93,6 +99,7 @@ set_property(TARGET bintools PROPERTY strip_flag_outfile -o )
|
|||
# - readelf : Name of command for reading elf files.
|
||||
# In this implementation `readelf` is used
|
||||
# readelf_flag : empty
|
||||
# readelf_flag_final : empty
|
||||
# readelf_flag_headers : -e
|
||||
# readelf_flag_infile : empty, readelf doesn't take arguments for filenames
|
||||
# readelf_flag_outfile : '>', readelf doesn't take arguments for output
|
||||
|
@ -103,6 +110,7 @@ set_property(TARGET bintools PROPERTY strip_flag_outfile -o )
|
|||
set_property(TARGET bintools PROPERTY readelf_command ${CMAKE_READELF})
|
||||
|
||||
set_property(TARGET bintools PROPERTY readelf_flag "")
|
||||
set_property(TARGET bintools PROPERTY readelf_flag_final "")
|
||||
set_property(TARGET bintools PROPERTY readelf_flag_headers -e)
|
||||
|
||||
set_property(TARGET bintools PROPERTY readelf_flag_infile "")
|
||||
|
|
Loading…
Reference in a new issue