From f737f5b1852e187f2aa0a597a318907f51ad5aa4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Andr=C3=A9n=20Zachrisson?= Date: Wed, 17 Feb 2021 17:18:13 +0000 Subject: [PATCH] Fix scripts on Mac OS X by using the GNU variants --- filelist.sh | 39 ++++++++++++++++++++++++--------------- gitver.sh | 11 +++++++++-- 2 files changed, 33 insertions(+), 17 deletions(-) diff --git a/filelist.sh b/filelist.sh index bb87f26f..7bb11996 100644 --- a/filelist.sh +++ b/filelist.sh @@ -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 < $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 diff --git a/gitver.sh b/gitver.sh index f4abb612..33868886 100644 --- a/gitver.sh +++ b/gitver.sh @@ -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