Skip to content

Commit 3a03115

Browse files
committed
Merge branch 'master' of github.com:kirjavascript/TetrisGYM
2 parents 4e77499 + 5bfb260 commit 3a03115

File tree

1 file changed

+33
-8
lines changed

1 file changed

+33
-8
lines changed

build.sh

100644100755
Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,20 @@ png2chr() {
5050

5151
# build CHR if it doesnt already exist
5252

53-
if [ "$(find src/chr/*.chr 2>/dev/null | wc -l)" = 0 ]; then
53+
if [ "$(find src/chr/*.chr 2>/dev/null | wc -l | xargs)" = 0 ]; then
5454
echo "building CHR for the first time"
5555
png2chr
5656
else
5757

5858
# if it does exist check if the PNG has been modified
59-
60-
pngTimes=$(stat -c "%Y" src/chr/*.png)
61-
scriptTime=$(stat -c "%X" "$0")
59+
if [[ $(uname) == "Darwin" ]]; then
60+
# mac support
61+
pngTimes=$(stat -f "%m" src/chr/*.png)
62+
scriptTime=$(stat -f "%m" "$0")
63+
else
64+
pngTimes=$(stat -c "%Y" src/chr/*.png)
65+
scriptTime=$(stat -c "%X" "$0")
66+
fi
6267

6368
for pngTime in $pngTimes; do
6469
if [ "$pngTime" -gt "$scriptTime" ]; then
@@ -84,11 +89,31 @@ ca65 ${compile_flags[*]} -l tetris.lst -g src/main.asm -o main.o
8489
ld65 -m tetris.map -Ln tetris.lbl --dbgfile tetris.dbg -o tetris.nes -C src/tetris.nes.cfg main.o header.o
8590

8691
# create patch
87-
88-
./tools/flips-linux --create clean.nes tetris.nes tetris.bps
92+
if [[ -f clean.nes ]] && [[ $(uname) == "Darwin" ]]; then
93+
echo "Unable to create patch on mac"
94+
elif [[ -f clean.nes ]]; then
95+
./tools/flips-linux --create clean.nes tetris.nes tetris.bps
96+
else
97+
echo "clean.nes not found. Skipping patch creation."
98+
fi
8999

90100
# show some stats
101+
if command -v sha1sum &>/dev/null; then
102+
sha1sum tetris.nes
103+
elif command -v shasum &>/dev/null; then
104+
# mac support
105+
shasum tetris.nes
106+
else
107+
echo "sha1sum or shasum not found. Unable to get SHA-1 hash of tetris.nes."
108+
fi
91109

92-
sha1sum tetris.nes
93110
sed -n '23,27p' < tetris.map
94-
stat -c %s tetris.bps
111+
112+
if [[ -f tetris.bps ]]; then
113+
# mac support
114+
if [[ $(uname) == "Darwin" ]]; then
115+
stat -f %z tetris.bps
116+
else
117+
stat -c %s tetris.bps
118+
fi
119+
fi

0 commit comments

Comments
 (0)