Improve embedded binary data and debug checkmate

This commit is contained in:
Loic Guegan 2023-06-02 15:07:44 +02:00
parent ddc0c7aee0
commit c8f72aeaac
11 changed files with 3647 additions and 3657 deletions

View file

@ -1,6 +1,6 @@
#!/bin/bash
# This file generate all the embedded binary resources required for OChess to run properly
########## RESOURCES ##########
ressources=$(cat <<-EndOfResources
assets/boards/chesscom_8bits.png
@ -17,7 +17,7 @@ EndOfResources
set -e
wai=$(dirname $(readlink -f "$0")) # Current script directory
dst="${wai}/../src/binres/"
dst="${wai}/../src/binres/binary_data.hpp"
# Binary to C headers
# $1 is the resource file and $2 the variable name to use in the C code
@ -26,17 +26,12 @@ bin2c () {
}
# Generate headers
includes=""
echo -n > "$dst"
for res in $ressources
do
ext="${res##*.}"
name="$(basename $res .${ext})"
name_std=${name}_${ext}.hpp # Header name standard
out="${dst}/${name_std}"
echo "- Generating ${name_std} resource..."
bin2c "$res" "${name}_${ext}" > "$out"
[ -z "$includes" ] && includes="${name_std}" || includes="${includes} ${name_std}"
echo "Generating resources for ${name}.${ext}..."
bin2c "$res" "${name}_${ext}" >> "$dst"
done
echo "Please update the binres.cpp and binres.hpp to reflect these changes."
echo "$includes"|tr "[:space:]" "\n"|awk '{print("#include \""$1"\"")}'
echo "Done! The generated resources are accessible here: \"$dst\""