Import fixed filelist.sh from Space Game RPX branch

This commit is contained in:
CreeperMario 2017-03-05 12:10:46 +10:30 committed by GitHub
parent e6dc8032c9
commit 3e7f5508b4

View File

@ -7,24 +7,14 @@ outFile="./src/resources/filelist.h"
count_old=$(cat $outFile 2>/dev/null | tr -d '\n\n' | sed 's/[^0-9]*\([0-9]*\).*/\1/') count_old=$(cat $outFile 2>/dev/null | tr -d '\n\n' | sed 's/[^0-9]*\([0-9]*\).*/\1/')
count=0 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) for i in $(find ./data/images/ ./data/sounds/ ./data/fonts/ -maxdepth 1 -type f) #\( ! -printf "%f\n" \) | sort -f)
do do
files[count]=$i files[count]=$i
count=$((count+1)) count=$((count+1))
done done
else #fi
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 ] if [ "$count_old" != "$count" ] || [ ! -f $outFile ]
then then
@ -41,7 +31,6 @@ cat <<EOF > $outFile
****************************************************************************/ ****************************************************************************/
#ifndef _FILELIST_H_ #ifndef _FILELIST_H_
#define _FILELIST_H_ #define _FILELIST_H_
typedef struct _RecourceFile typedef struct _RecourceFile
{ {
const char *filename; const char *filename;
@ -50,13 +39,27 @@ typedef struct _RecourceFile
unsigned char *CustomFile; unsigned char *CustomFile;
unsigned int CustomFileSize; unsigned int CustomFileSize;
} RecourceFile; } RecourceFile;
EOF EOF
for i in ${files[@]} for i in ${files[@]}
do do
filename=${i%.*} filename=${i%.*}
extension=${i##*.} extension=${i##*.}
# For some reason, macOS and other Darwin-based operating systems contain a
# find untility that outputs full file paths instead of singular file names.
# To prevent this from screwing our program, we will remove the paths from the
# entries returned by the above loop if we are running on a Darwin platform.
if [[ $OSTYPE == darwin* ]]; then
if [[ ${filename:0:15} == ./data/sounds// ]]; then
filename=${filename:15}
elif [[ ${filename:0:15} == ./data/images// ]]; then
filename=${filename:15}
elif [[ ${filename:0:14} == ./data/fonts// ]]; then
filename=${filename:14}
fi
fi
echo 'extern const unsigned char '$filename'_'$extension'[];' >> $outFile echo 'extern const unsigned char '$filename'_'$extension'[];' >> $outFile
echo 'extern const unsigned int '$filename'_'$extension'_size;' >> $outFile echo 'extern const unsigned int '$filename'_'$extension'_size;' >> $outFile
echo '' >> $outFile echo '' >> $outFile
@ -69,7 +72,19 @@ for i in ${files[@]}
do do
filename=${i%.*} filename=${i%.*}
extension=${i##*.} extension=${i##*.}
echo -e '\t{"'$i'", '$filename'_'$extension', '$filename'_'$extension'_size, NULL, 0},' >> $outFile
# See above for documentation on what this does.
if [[ $OSTYPE == darwin* ]]; then
if [[ ${filename:0:15} == ./data/sounds// ]]; then
filename=${filename:15}
elif [[ ${filename:0:15} == ./data/images// ]]; then
filename=${filename:15}
elif [[ ${filename:0:14} == ./data/fonts// ]]; then
filename=${filename:14}
fi
fi
echo -e '\t{"'$filename'.'$extension'", '$filename'_'$extension', '$filename'_'$extension'_size, NULL, 0},' >> $outFile
done done
echo -e '\t{NULL, NULL, 0, NULL, 0}' >> $outFile echo -e '\t{NULL, NULL, 0, NULL, 0}' >> $outFile