forked from Maschell/WiiUPluginLoader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
filelist.sh
71 lines (58 loc) · 1.73 KB
/
filelist.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#! /bin/bash
#
# Automatic resource file list generation
# Created by Dimok
outFile="./src/resources/filelist.cpp"
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.c 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.
*****************************************************************************/
#include <resources/filelist.h>
#include <stdint.h>
EOF
for i in ${files[@]}
do
filename=${i%.*}
extension=${i##*.}
echo 'extern const uint8_t '$filename'_'$extension'[];' >> $outFile
echo 'extern const uint32_t '$filename'_'$extension'_size;' >> $outFile
echo '' >> $outFile
done
echo 'static ResourceFile ResourceList[] =' >> $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 'ResourceFile * getResourceList(){ return ResourceList; }' >> $outFile
echo '' >> $outFile
fi