diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-01-05 08:54:31 +0200 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-01-05 08:54:31 +0200 |
commit | 192d56c3fb61c43a3a5c3189a2a194a90e7bb3b4 (patch) | |
tree | 377ff4db63c278390d019aed2c245741cfb56de1 | |
parent | cb7d2aa7fd97407bcddf91d9d11a4ea3175b54d9 (diff) |
Embed: Use a shell script for bincat
Todo: Needs testing if this is portable enough. Should be pretty POSIX, though.
-rw-r--r-- | res/Embed.cmake | 9 | ||||
-rwxr-xr-x | res/bincat.sh | 22 |
2 files changed, 30 insertions, 1 deletions
diff --git a/res/Embed.cmake b/res/Embed.cmake index bab06347..1a971cc1 100644 --- a/res/Embed.cmake +++ b/res/Embed.cmake | |||
@@ -3,9 +3,16 @@ | |||
3 | # License: BSD 2-Clause | 3 | # License: BSD 2-Clause |
4 | 4 | ||
5 | option (ENABLE_RESOURCE_EMBED "Embed resources inside the executable" OFF) | 5 | option (ENABLE_RESOURCE_EMBED "Embed resources inside the executable" OFF) |
6 | option (ENABLE_BINCAT_SH "Prepare resource files using the 'bincat.sh' shell script" ON) | ||
7 | |||
8 | if (ENABLE_BINCAT_SH OR CMAKE_CROSSCOMPILING) | ||
9 | set (embed_use_bincat_sh YES) | ||
10 | endif () | ||
6 | 11 | ||
7 | # Build "bincat" for concatenating files. | 12 | # Build "bincat" for concatenating files. |
8 | if (NOT ENABLE_RESOURCE_EMBED) | 13 | if (embed_use_bincat_sh) |
14 | set (BINCAT_COMMAND ${CMAKE_SOURCE_DIR}/res/bincat.sh) | ||
15 | elseif (NOT ENABLE_RESOURCE_EMBED) | ||
9 | message (STATUS "Compiling bincat for merging resource files...") | 16 | message (STATUS "Compiling bincat for merging resource files...") |
10 | set (_catDir ${CMAKE_BINARY_DIR}/res) | 17 | set (_catDir ${CMAKE_BINARY_DIR}/res) |
11 | execute_process (COMMAND ${CMAKE_COMMAND} -E make_directory ${_catDir}) | 18 | execute_process (COMMAND ${CMAKE_COMMAND} -E make_directory ${_catDir}) |
diff --git a/res/bincat.sh b/res/bincat.sh new file mode 100755 index 00000000..46483998 --- /dev/null +++ b/res/bincat.sh | |||
@@ -0,0 +1,22 @@ | |||
1 | #!/bin/sh | ||
2 | # Binary Resource Concatenator | ||
3 | # Copyright: 2021 Jaakko Keränen <jaakko.keranen@iki.fi> | ||
4 | # License: BSD 2-Clause | ||
5 | |||
6 | OUTPUT=-- | ||
7 | SIZES="" | ||
8 | for fn in $*; do | ||
9 | if [ "$OUTPUT" == "--" ]; then | ||
10 | OUTPUT=$fn | ||
11 | rm -f ${OUTPUT} | ||
12 | else | ||
13 | vals=(`/bin/ls -l $fn`) | ||
14 | if [ "$SIZES" == "" ]; then | ||
15 | SIZES=${vals[4]} | ||
16 | else | ||
17 | SIZES=$SIZES\;${vals[4]} | ||
18 | fi | ||
19 | cat ${fn} >> ${OUTPUT} | ||
20 | fi | ||
21 | done | ||
22 | echo $SIZES | ||