hopefully more portable way of packaging binary embeds

This commit is contained in:
veclavtalica 2025-03-08 18:11:39 +03:00
parent 826622cd58
commit 36c0af9953
2 changed files with 10 additions and 5 deletions

View File

@ -364,11 +364,8 @@ target_link_libraries(${TWN_TARGET} PUBLIC
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/font.o
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND ${CMAKE_LINKER} --relocatable --format binary
--output ${CMAKE_CURRENT_BINARY_DIR}/font.o
share/assets/Dernyns256.ttf
DEPENDS share/assets/Dernyns256.ttf
)
COMMAND ${CMAKE_COMMAND} -E env CMAKE_CURRENT_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR} sh bin/prep-embed.sh
DEPENDS share/assets/Dernyns256.ttf)
add_custom_target(asset-compilation ALL DEPENDS
${CMAKE_CURRENT_BINARY_DIR}/font.o)

8
bin/prep-embed.sh Normal file
View File

@ -0,0 +1,8 @@
#!/bin/env sh
set -e
# packages embedded resources with objcopy, so that it is more portable
# ld.lld on windows doesn't recognize --format binary, sadly
objdump=$(objdump -i)
bdfname=$(echo "$objdump" | sed -n 2p)
objcopy -I binary -O "$bdfname" share/assets/Dernyns256.ttf "$CMAKE_CURRENT_BINARY_DIR/font.o"