# return to root directory
cd `git rev-parse --show-toplevel`

cd etc/resources/
dst="../../src/resources"
header="${dst}/resources.hpp"
echo "// This file was auto-generated by etc/meta/generate-resources.sh" > $header
echo "" >> $header
echo "#pragma once" >> $header
echo "" >> $header
echo "namespace ogm::resource {" >> $header
echo "" >> $header
for filename in *; do
    name="${filename//./_}"
    echo "embedding \"${filename}\" as \"${name}\""
    echo "// ${filename}" >> $header
    echo "extern unsigned char ${name}[];" >> $header
    echo "extern unsigned int ${name}_len;" >> $header
    echo "" >> $header
    out="${dst}/${filename}.cpp"
    echo "// This file was auto-generated by etc/meta/generate-resources.sh" > $out
    echo "// ${filename}" >> $out
    echo "" >> $out
    echo "#include \"resources.hpp\"" >> $out
    echo "" >> $out
    echo "namespace ogm::resource {" >> $out
    xxd -i "${filename}" >> $out
    echo "} /* namespace ogm::resource */" >> $out
done

echo "} /* namespace ogm::resource */" >> $header
