comparison local.cmake @ 1:b9ec45077bff

Use MAKE_C_IDENTIFIER since it's available. Add comment about where we got the magic from. Add _end symbol.
author Daniel O'Connor <darius@dons.net.au>
date Mon, 29 Mar 2021 13:54:55 +1030
parents a55e39064a71
children
comparison
equal deleted inserted replaced
0:a55e39064a71 1:b9ec45077bff
15 #message("BINFILE ${BINFILE} BIN_SYMNAME ${BIN_SYMNAME}") 15 #message("BINFILE ${BINFILE} BIN_SYMNAME ${BIN_SYMNAME}")
16 16
17 # Get directory name of source file 17 # Get directory name of source file
18 # ld will name the symbol based on the full path so we have to mangle it 18 # ld will name the symbol based on the full path so we have to mangle it
19 get_filename_component(BIN_SRC_DIR ${FILENAME} DIRECTORY) 19 get_filename_component(BIN_SRC_DIR ${FILENAME} DIRECTORY)
20 string(REPLACE "/" "_" SRC_DIRNAME_MANGLED ${BIN_SRC_DIR}) 20 string(MAKE_C_IDENTIFIER ${BIN_SRC_DIR} SRC_DIRNAME_MANGLED)
21 #message("SRC_DIRNAME_MANGLED ${SRC_DIRNAME_MANGLED}") 21 #message("SRC_DIRNAME_MANGLED ${SRC_DIRNAME_MANGLED}")
22 22
23 # http://stupefydeveloper.blogspot.com/2008/08/cc-embed-binary-data-into-elf.html
23 add_custom_command(OUTPUT ${ELFNAME} 24 add_custom_command(OUTPUT ${ELFNAME}
24 COMMAND arm-none-eabi-ld -r -b binary -o ${ELFNAME} 25 COMMAND arm-none-eabi-ld -r -b binary -o ${ELFNAME}
25 --defsym=${BIN_SYMNAME}_start=_binary_${SRC_DIRNAME_MANGLED}_${BIN_SYMNAME}_start 26 --defsym=${BIN_SYMNAME}_start=_binary_${SRC_DIRNAME_MANGLED}_${BIN_SYMNAME}_start
27 --defsym=${BIN_SYMNAME}_end=_binary_${SRC_DIRNAME_MANGLED}_${BIN_SYMNAME}_end
26 --defsym=${BIN_SYMNAME}_size=_binary_${SRC_DIRNAME_MANGLED}_${BIN_SYMNAME}_size 28 --defsym=${BIN_SYMNAME}_size=_binary_${SRC_DIRNAME_MANGLED}_${BIN_SYMNAME}_size
27 ${FILENAME} 29 ${FILENAME}
28 DEPENDS ${FILENAME}) 30 DEPENDS ${FILENAME})
29 add_dependencies(${TARGET} ${BIN_GEN_TARGET}) 31 add_dependencies(${TARGET} ${BIN_GEN_TARGET})
30 32