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" outFile="./source/themes/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/')
# 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 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 do
files[count]=$i files[count]=$i
count=$((count+1)) count=$((count+1))
@ -16,7 +25,7 @@ done
if [ "$count_old" != "$count" ] || [ ! -f $outFile ] if [ "$count_old" != "$count" ] || [ ! -f $outFile ]
then then
echo "Generating filelist.h for $count files." >&2 $ECHO "Generating filelist.h for $count files." >&2
cat <<EOF > $outFile cat <<EOF > $outFile
/**************************************************************************** /****************************************************************************
* USB Loader GX resource files. * USB Loader GX resource files.
@ -37,28 +46,28 @@ for i in ${files[@]}
do do
filename=${i%.*} filename=${i%.*}
extension=${i##*.} extension=${i##*.}
echo 'extern const u8 '$filename'_'$extension'[];' >> $outFile $ECHO 'extern const u8 '$filename'_'$extension'[];' >> $outFile
echo 'extern const u32 '$filename'_'$extension'_size;' >> $outFile $ECHO 'extern const u32 '$filename'_'$extension'_size;' >> $outFile
echo '' >> $outFile $ECHO '' >> $outFile
done done
echo 'RecourceFile Resources::RecourceFiles[] =' >> $outFile $ECHO 'RecourceFile Resources::RecourceFiles[] =' >> $outFile
echo '{' >> $outFile $ECHO '{' >> $outFile
for i in ${files[@]} 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 $ECHO -e '\t{"'$i'", '$filename'_'$extension', '$filename'_'$extension'_size, NULL, 0},' >> $outFile
done done
echo -e '\t{"listBackground.png", NULL, 0, NULL, 0},\t// Optional' >> $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{"carouselBackground.png", NULL, 0, NULL, 0},\t// Optional' >> $outFile
echo -e '\t{"gridBackground.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 -e '\t{NULL, NULL, 0, NULL, 0}' >> $outFile
echo '};' >> $outFile $ECHO '};' >> $outFile
echo '' >> $outFile $ECHO '' >> $outFile
echo '#endif' >> $outFile $ECHO '#endif' >> $outFile
fi fi

View File

@ -1,5 +1,12 @@
#! /bin/bash #! /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 # Correct the path on Windows so that git works correctly
if [[ $(uname -s) == MSYS* ]]; then 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 //') 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) commit_id=$(git rev-parse HEAD 2>/dev/null | head -c 7)
[ -z "$commit_id" ] && commit_id="0000001" [ -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" [ -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 if [ "$commit_id" != "$commit_id_old" ] || [ ! -f ./source/gitver.c ]; then