-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.sh
executable file
·98 lines (84 loc) · 2.27 KB
/
build.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/bin/bash
# this is just here for my convenience, because I am an idiot
# REPLACE WITH THE NAME OF YOUR PLAYDATE GAME PDX
GAME="Playnote.pdx"
# SDK installer writes the install location to ~/.Playdate/config
if [ -z $PLAYDATE_SDK_PATH ]; then
SDK=$(egrep '^\s*SDKRoot' ~/.Playdate/config | head -n 1 | cut -c9-)
else
SDK=$PLAYDATE_SDK_PATH
fi
if [ -z $SDK ]; then
echo "Playdate SDK path not found; set environment value PLAYDATE_SDK_PATH."
exit 1
fi
CMD=$1
if [ -z $CMD ]; then
echo "No command provided"
exit 1
fi
if [ $CMD == "sim" ]; then
echo "compiling simulator build..."
cd build
cmake ..
make
cd ..
fi
if [ $CMD == "dev" ]; then
echo "compiling dev device build..."
# compile C
cd build
cmake -DCMAKE_TOOLCHAIN_FILE=${SDK}/C_API/buildsupport/arm.cmake ..
make
# compile lua and assets
cd ..
make pdc
# copy to Playdate Simulator disk location
cp -a ./${GAME} ${SDK}/Disk/Games/${GAME}
fi
if [ $CMD == "build" ]; then
echo "compiling prod device build..."
# compile C
cd build
cmake -DCMAKE_TOOLCHAIN_FILE=${SDK}/C_API/buildsupport/arm.cmake ..
make
cd ..
# compile lua and assets, tell pdc to compile lua without debug symbols
pdc -s Source ${GAME}
# assumes that you import all the files your game uses into main.lua
# strip unused .pdz files
find ./${GAME} -name "*.pdz" -type f -depth 2 -delete
find ./${GAME} -name "*.pdz" -not -name "main.pdz" -type f -delete
# remove simulator binaries that aren't needed for a device-only build
find ./${GAME} -name "*.dylib" -type f -delete
find ./${GAME} -name "*.dll" -type f -delete
# cleapup empty directories
find ./${GAME} -empty -type d -delete
# cleanup macOS extended attribute files
find . -type f -name '._*' -delete
# zip result, skipping pesky DS_Store files
rm ./${GAME}.zip
zip -vr ./${GAME}.zip ./${GAME}/ -x "*.DS_Store"
fi
if [ $CMD == "lua" ]; then
echo "compiling lua changes..."
make pdc
fi
if [ $CMD == "clean" ]; then
cd build
make clean
cd ..
fi
if [ $CMD == "reset" ]; then
rm -rf ./build/*
fi
if [ $CMD == "release" ]; then
if [ -z $2 ]; then
echo "Specify a release version (e.g. 1.0.0)"
exit 1
fi
./build.sh build
gh release create v${2} --draft "./${GAME}.zip#Playnote Studio for Playdate"
rm ./${GAME}.zip
fi
exit 0