ochess/tools/embedded.sh

38 lines
953 B
Bash
Raw Normal View History

2023-06-02 10:26:23 +02:00
#!/bin/bash
# This file generate all the embedded binary resources required for OChess to run properly
2023-06-02 10:26:23 +02:00
########## RESOURCES ##########
ressources=$(cat <<-EndOfResources
2023-06-02 11:19:26 +02:00
assets/boards/chesscom_8bits.png
assets/pieces/cburnett.png
assets/icons/hide.png
assets/icons/mat.png
2023-06-02 10:26:23 +02:00
assets/icons/ochess.png
2023-06-02 11:19:26 +02:00
assets/icons/swap.png
assets/icons/zoomin.png
assets/icons/zoomout.png
2023-06-02 10:26:23 +02:00
EndOfResources
)
###############################
set -e
wai=$(dirname $(readlink -f "$0")) # Current script directory
dst="${wai}/../src/binres/binary_data.hpp"
2023-06-02 10:26:23 +02:00
# Binary to C headers
# $1 is the resource file and $2 the variable name to use in the C code
bin2c () {
xxd -n "$2" -i "$1"
}
# Generate headers
echo -n > "$dst"
2023-06-02 10:26:23 +02:00
for res in $ressources
do
ext="${res##*.}"
name="$(basename $res .${ext})"
echo "Generating resources for ${name}.${ext}..."
bin2c "$res" "${name}_${ext}" >> "$dst"
2023-06-02 10:26:23 +02:00
done
echo "Done! The generated resources are accessible here: \"$dst\""