mirror of
https://github.com/Maschell/SDL2_Playground.git
synced 2024-11-15 01:25:06 +01:00
92 lines
1.9 KiB
Bash
92 lines
1.9 KiB
Bash
|
#! /bin/bash
|
||
|
#
|
||
|
# 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.
|
||
|
****************************************************************************/
|
||
|
#ifndef _FILELIST_H_
|
||
|
#define _FILELIST_H_
|
||
|
|
||
|
|
||
|
#include "Resources.h"
|
||
|
#ifdef __WIIU__
|
||
|
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
|
||
|
echo '' >> $outFile
|
||
|
echo '#else' >> $outFile
|
||
|
|
||
|
echo 'static RecourceFile RecourceList[] =' >> $outFile
|
||
|
echo '{' >> $outFile
|
||
|
|
||
|
for i in ${files[@]}
|
||
|
do
|
||
|
filename=${i%.*}
|
||
|
extension=${i##*.}
|
||
|
echo -e '\t{"'$i'", NULL, NULL, NULL, 0},' >> $outFile
|
||
|
done
|
||
|
|
||
|
echo -e '\t{NULL, NULL, 0, NULL, 0}' >> $outFile
|
||
|
echo '};' >> $outFile
|
||
|
echo '' >> $outFile
|
||
|
echo '#endif' >> $outFile
|
||
|
|
||
|
echo '#endif' >> $outFile
|
||
|
|
||
|
fi
|