forked from Whitebrim/VSCode-PlaydateTemplate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBuildAndRun.sh
executable file
·49 lines (41 loc) · 1002 Bytes
/
BuildAndRun.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
#!/bin/bash
# Parameters with default values
build="./builds"
source="./source"
name=$(basename "$(pwd)")
dontbuild=false
# Check if the first argument (build path) is provided
if [ -z "$1" ]; then
echo "Error: Build path is required."
exit 1
else
build="$1"
fi
pdx="$build/$name.pdx"
# Create build folder if not present
if [ "$dontbuild" = false ]; then
mkdir -p "$build"
fi
# Clean build folder
if [ "$dontbuild" = false ]; then
rm -rf "$build/*"
fi
# Build
if [ "$dontbuild" = false ]; then
pdc -sdkpath "$PLAYDATE_SDK_PATH" "$source" "$pdx"
fi
# Close Simulator
sim_pid=$(ps aux | grep PlaydateSimulator | grep -v grep | awk '{print $2}')
if [ ! -z "$sim_pid" ]; then
kill -TERM "$sim_pid"
count=0
while kill -0 "$sim_pid" 2> /dev/null; do
sleep 1
count=$((count+1))
if [ $count -ge 30 ]; then
kill -KILL "$sim_pid"
fi
done
fi
# Run (Simulator)
open "$PLAYDATE_SDK_PATH/bin/Playdate Simulator.app" "$pdx"