cmake: Add new and improved wut_create_rpl implementation.

This safely deprecates the old usage of wut_create_rpl.

Benefits are:
- Previously it would re-generate the RPX every time even with no changes.
- No longer creates a new build target just for the rpx file
This commit is contained in:
James Benton 2019-11-22 17:43:31 +00:00
parent 159284a93d
commit c74eb52c67

View File

@ -38,7 +38,7 @@ macro(wut_add_exports target exports_file)
set_source_files_properties(${RPL_EXPORT_GEN_OUTPUT} PROPERTIES LANGUAGE C)
endmacro()
function(wut_create_rpl target source)
function(wut_create_rpl_deprecated target source)
set(RPL_OPTIONS IS_RPX)
set(RPL_SINGLE_ARGS "")
set(RPL_MULTI_ARGS "")
@ -61,6 +61,32 @@ function(wut_create_rpl target source)
add_dependencies(${target} ${source})
endfunction()
function(wut_create_rpl target)
set(RPL_OPTIONS IS_RPX)
set(RPL_SINGLE_ARGS "")
set(RPL_MULTI_ARGS "")
cmake_parse_arguments(RPL "${RPL_OPTIONS}" "${RPL_SINGLE_ARGS}" "${RPL_MULTI_ARGS}" "${ARGN}")
if(${ARGC} GREATER 1 AND NOT "${ARGV1}" STREQUAL "IS_RPX")
message(DEPRECATION "wut_create_rpl(dest.rpx source) is deprecated, prefer using wut_create_rpl(target)")
wut_create_rpl_deprecated(${ARGV0} ${ARGV1} ${RPL_OPTIONS})
return()
endif()
if(RPL_IS_RPX)
# Do nothing - the defaults are good for RPX
else()
set(ELF2RPL_FLAGS ${ELF2RPL_FLAGS} --rpl)
set_property(TARGET ${target} APPEND_STRING PROPERTY
LINK_FLAGS "-specs=${WUT_ROOT}/share/rpl.specs")
endif()
add_custom_command(TARGET ${target} POST_BUILD
COMMAND ${CMAKE_STRIP} -g $<TARGET_FILE:${target}>
COMMAND ${WUT_ELF2RPL} ${ELF2RPL_FLAGS} $<TARGET_FILE:${target}> $<TARGET_FILE_DIR:${target}>/${target}.rpx
COMMENT "Creating ${target}.rpx")
endfunction()
function(wut_create_rpx)
wut_create_rpl(${ARGV} IS_RPX)
endfunction()