2020-09-05 11:33:54 +02:00
|
|
|
#!/bin/bash
|
2020-09-04 18:36:19 +02:00
|
|
|
#
|
|
|
|
# Automatic resource file list generation
|
|
|
|
# Created by Dimok
|
|
|
|
|
|
|
|
outFile="./src/resources/filelist.h"
|
|
|
|
count_old=$(cat $outFile 2>/dev/null | tr -d '\n\n' | sed 's/[^0-9]*\([0-9]*\).*/\1/')
|
|
|
|
|
|
|
|
count=0
|
|
|
|
if [[ $OSTYPE == darwin* ]];
|
|
|
|
then
|
|
|
|
|
|
|
|
for i in $(gfind ./data/images/ ./data/sounds/ ./data/fonts/ -maxdepth 1 -type f \( ! -printf "%f\n" \) | sort -f)
|
|
|
|
do
|
|
|
|
files[count]=$i
|
|
|
|
count=$((count+1))
|
|
|
|
done
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
for i in $(find ./data/images/ ./data/sounds/ ./data/fonts/ -maxdepth 1 -type f \( ! -printf "%f\n" \) | sort -f)
|
|
|
|
do
|
|
|
|
files[count]=$i
|
|
|
|
count=$((count+1))
|
|
|
|
done
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$count_old" != "$count" ] || [ ! -f $outFile ]
|
|
|
|
then
|
|
|
|
|
|
|
|
echo "Generating filelist.h for $count files." >&2
|
|
|
|
cat <<EOF > $outFile
|
|
|
|
/****************************************************************************
|
|
|
|
* Resource files.
|
|
|
|
* This file is generated automatically.
|
|
|
|
* Includes $count files.
|
|
|
|
*
|
|
|
|
* NOTE:
|
|
|
|
* Any manual modification of this file will be overwriten by the generation.
|
|
|
|
****************************************************************************/
|
2020-09-05 12:58:27 +02:00
|
|
|
#pragma once
|
2020-09-04 18:36:19 +02:00
|
|
|
|
|
|
|
#include "Resources.h"
|
2020-09-05 12:58:27 +02:00
|
|
|
#ifndef _CMAKE_BUILD_
|
2020-09-04 18:36:19 +02:00
|
|
|
EOF
|
|
|
|
|
|
|
|
for i in ${files[@]}
|
|
|
|
do
|
|
|
|
filename=${i%.*}
|
|
|
|
extension=${i##*.}
|
|
|
|
echo '#include "'$filename'_'$extension'.h"' >> $outFile
|
|
|
|
done
|
|
|
|
|
|
|
|
echo '' >> $outFile
|
|
|
|
|
|
|
|
echo 'static RecourceFile RecourceList[] =' >> $outFile
|
|
|
|
echo '{' >> $outFile
|
|
|
|
|
|
|
|
for i in ${files[@]}
|
|
|
|
do
|
|
|
|
filename=${i%.*}
|
|
|
|
extension=${i##*.}
|
|
|
|
echo -e '\t{"'$i'", '$filename'_'$extension', '$filename'_'$extension'_size, NULL, 0},' >> $outFile
|
|
|
|
done
|
|
|
|
|
|
|
|
echo -e '\t{NULL, NULL, 0, NULL, 0}' >> $outFile
|
|
|
|
echo '};' >> $outFile
|
2020-09-05 12:58:27 +02:00
|
|
|
echo '' >> $outFile
|
|
|
|
echo '#else' >> $outFile
|
|
|
|
for i in ${files[@]}
|
|
|
|
do
|
|
|
|
filename=${i%.*}
|
|
|
|
extension=${i##*.}
|
|
|
|
echo 'extern uint8_t '$filename'_'$extension'[];' >> $outFile
|
|
|
|
echo 'extern uint32_t '$filename'_'$extension'_size;' >> $outFile
|
|
|
|
done
|
|
|
|
|
2020-09-04 18:36:19 +02:00
|
|
|
echo '' >> $outFile
|
|
|
|
|
2020-09-05 12:58:27 +02:00
|
|
|
echo 'static RecourceFile RecourceList[] =' >> $outFile
|
|
|
|
echo '{' >> $outFile
|
|
|
|
|
|
|
|
for i in ${files[@]}
|
|
|
|
do
|
|
|
|
filename=${i%.*}
|
|
|
|
extension=${i##*.}
|
|
|
|
echo -e '\t{"'$i'", (uint8_t*)&'$filename'_'$extension', '$filename'_'$extension'_size, NULL, 0},' >> $outFile
|
|
|
|
done
|
|
|
|
|
|
|
|
echo -e '\t{NULL, NULL, 0, NULL, 0}' >> $outFile
|
|
|
|
echo '};' >> $outFile
|
|
|
|
echo '' >> $outFile
|
2020-09-04 18:36:19 +02:00
|
|
|
echo '#endif' >> $outFile
|
|
|
|
|
|
|
|
fi
|