summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-01-05 08:54:31 +0200
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-01-05 08:54:31 +0200
commit192d56c3fb61c43a3a5c3189a2a194a90e7bb3b4 (patch)
tree377ff4db63c278390d019aed2c245741cfb56de1
parentcb7d2aa7fd97407bcddf91d9d11a4ea3175b54d9 (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.cmake9
-rwxr-xr-xres/bincat.sh22
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
5option (ENABLE_RESOURCE_EMBED "Embed resources inside the executable" OFF) 5option (ENABLE_RESOURCE_EMBED "Embed resources inside the executable" OFF)
6option (ENABLE_BINCAT_SH "Prepare resource files using the 'bincat.sh' shell script" ON)
7
8if (ENABLE_BINCAT_SH OR CMAKE_CROSSCOMPILING)
9 set (embed_use_bincat_sh YES)
10endif ()
6 11
7# Build "bincat" for concatenating files. 12# Build "bincat" for concatenating files.
8if (NOT ENABLE_RESOURCE_EMBED) 13if (embed_use_bincat_sh)
14 set (BINCAT_COMMAND ${CMAKE_SOURCE_DIR}/res/bincat.sh)
15elseif (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
6OUTPUT=--
7SIZES=""
8for 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
21done
22echo $SIZES