#!/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 assets/pieces/cburnett.png assets/icons/hide.png assets/icons/mat.png assets/icons/ochess.png assets/icons/swap.png assets/icons/zoomin.png assets/icons/zoomout.png EndOfResources ) ############################### set -e wai=$(dirname $(readlink -f "$0")) # Current script directory dst="${wai}/../src/binres/" # 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 includes="" 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}" done echo "Please update the binres.cpp and binres.hpp to reflect these changes." echo "$includes"|tr "[:space:]" "\n"|awk '{print("#include \""$1"\"")}'