Fix scripts on Mac OS X by using the GNU variants

This commit is contained in:
Erik Andrén Zachrisson 2021-02-17 17:18:13 +00:00
parent c669033ef3
commit f737f5b185
2 changed files with 33 additions and 17 deletions

View File

@ -6,8 +6,17 @@
outFile="./source/themes/filelist.h"
count_old=$(cat $outFile 2>/dev/null | tr -d '\n\n' | sed 's/[^0-9]*\([0-9]*\).*/\1/')
# Need to use GNU find and echo on Mac OS X
if [[ $(uname -s) == Darwin ]]; then
ECHO=gecho
FIND=gfind
else
ECHO=echo
FIND=find
fi
count=0
for i in $(find ./data/images/ ./data/sounds/ ./data/fonts/ ./data/binary/ -maxdepth 1 -type f \( ! -printf "%f\n" \))
for i in $($FIND ./data/images/ ./data/sounds/ ./data/fonts/ ./data/binary/ -maxdepth 1 -type f \( ! -printf "%f\n" \))
do
files[count]=$i
count=$((count+1))
@ -16,7 +25,7 @@ done
if [ "$count_old" != "$count" ] || [ ! -f $outFile ]
then
echo "Generating filelist.h for $count files." >&2
$ECHO "Generating filelist.h for $count files." >&2
cat <<EOF > $outFile
/****************************************************************************
* USB Loader GX resource files.
@ -37,28 +46,28 @@ for i in ${files[@]}
do
filename=${i%.*}
extension=${i##*.}
echo 'extern const u8 '$filename'_'$extension'[];' >> $outFile
echo 'extern const u32 '$filename'_'$extension'_size;' >> $outFile
echo '' >> $outFile
$ECHO 'extern const u8 '$filename'_'$extension'[];' >> $outFile
$ECHO 'extern const u32 '$filename'_'$extension'_size;' >> $outFile
$ECHO '' >> $outFile
done
echo 'RecourceFile Resources::RecourceFiles[] =' >> $outFile
echo '{' >> $outFile
$ECHO 'RecourceFile Resources::RecourceFiles[] =' >> $outFile
$ECHO '{' >> $outFile
for i in ${files[@]}
do
filename=${i%.*}
extension=${i##*.}
echo -e '\t{"'$i'", '$filename'_'$extension', '$filename'_'$extension'_size, NULL, 0},' >> $outFile
$ECHO -e '\t{"'$i'", '$filename'_'$extension', '$filename'_'$extension'_size, NULL, 0},' >> $outFile
done
echo -e '\t{"listBackground.png", NULL, 0, NULL, 0},\t// Optional' >> $outFile
echo -e '\t{"carouselBackground.png", NULL, 0, NULL, 0},\t// Optional' >> $outFile
echo -e '\t{"gridBackground.png", NULL, 0, NULL, 0},\t// Optional' >> $outFile
echo -e '\t{NULL, NULL, 0, NULL, 0}' >> $outFile
echo '};' >> $outFile
$ECHO -e '\t{"listBackground.png", NULL, 0, NULL, 0},\t// Optional' >> $outFile
$ECHO -e '\t{"carouselBackground.png", NULL, 0, NULL, 0},\t// Optional' >> $outFile
$ECHO -e '\t{"gridBackground.png", NULL, 0, NULL, 0},\t// Optional' >> $outFile
$ECHO -e '\t{NULL, NULL, 0, NULL, 0}' >> $outFile
$ECHO '};' >> $outFile
echo '' >> $outFile
echo '#endif' >> $outFile
$ECHO '' >> $outFile
$ECHO '#endif' >> $outFile
fi

View File

@ -1,5 +1,12 @@
#! /bin/bash
# Need to use GNU sed on Mac OS X
if [[ $(uname -s) == Darwin ]]; then
SED=gsed
else
SED=sed
fi
# Correct the path on Windows so that git works correctly
if [[ $(uname -s) == MSYS* ]]; then
winpath=$(cmd //c REG QUERY "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" -v PATH | grep '^ PATH'| sed 's/ PATH REG_SZ //')
@ -9,9 +16,9 @@ fi
commit_id=$(git rev-parse HEAD 2>/dev/null | head -c 7)
[ -z "$commit_id" ] && commit_id="0000001"
commit_message=$(git show -s --format="%<(52,trunc)%s" $commit_id 2>/dev/null | sed -e 's/[[:space:]]*$//')
commit_message=$(git show -s --format="%<(52,trunc)%s" $commit_id 2>/dev/null | $SED -e 's/[[:space:]]*$//')
[ -z "$commit_message" ] && commit_message="unable to get the commit message"
commit_id_old=$(cat ./source/gitver.c 2>/dev/null | tr -d '\n' | sed -r 's/.*([0-9a-f]{7}).*/\1/')
commit_id_old=$(cat ./source/gitver.c 2>/dev/null | tr -d '\n' | $SED -r 's/.*([0-9a-f]{7}).*/\1/')
if [ "$commit_id" != "$commit_id_old" ] || [ ! -f ./source/gitver.c ]; then