-
Notifications
You must be signed in to change notification settings - Fork 1
/
build_desktop.sh
executable file
·133 lines (100 loc) · 3.61 KB
/
build_desktop.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#!/usr/bin/env bash
set -euo pipefail
BUILD_MAC=0
BUILD_WIN=0
# get app version from lib/version.lua
appver=$(grep "^version_str =" lib/version.lua | cut -d '"' -f 2)
[[ "$appver" =~ ^[0-9]\.[0-9][0-9]$ ]] || (echo "App version extraction failed: $appver is not x.xx. Aborting." && exit 1)
options=$(getopt -l "win,mac,help" -o "w,m,h" -a -- "$@")
eval set -- "$options"
while true
do
case $1 in
-w|--win)
BUILD_WIN=1
;;
-m|--mac)
BUILD_MAC=1
;;
-h|--help)
echo "Produce flowit.love in the build directory."
echo ""
echo "Usage:"
echo " $0 [-w | --win] [-m | --mac]"
echo ""
echo " -w, --win also build windows executable (.exe)"
echo " -m, --mac also build mac app (.app)"
exit 0
;;
--)
shift
break;;
esac
shift
done
shopt -s extglob
mkdir -p build
echo "Compressing flowit.love..."
zip -9 -q -r build/flowit.love lib/!(*_vita.lua) fonts images levels LICENSE main.lua sounds
cd build
if [[ $BUILD_WIN -eq 1 ]]; then
echo "Packaging Windows exe..."
WIN_FLOWIT_DIR="flowit-win"
WIN_FLOWIT_ZIP="${WIN_FLOWIT_DIR}-v${appver}.zip"
WIN_LOVE_DIR="love-11.4-win32"
WIN_LOVE_ZIP="$WIN_LOVE_DIR.zip"
# download zip if it doesn't exist
if [ ! -f "$WIN_LOVE_ZIP" ]; then
curl -L -O "https://github.com/love2d/love/releases/download/11.4/love-11.4-win32.zip"
fi
# delete directories built previously
if [ -d "$WIN_LOVE_DIR" ]; then
rm -r "$WIN_LOVE_DIR"
fi
if [ -d "$WIN_FLOWIT_DIR" ]; then
rm -r "$WIN_FLOWIT_DIR"
fi
unzip -q "$WIN_LOVE_ZIP"
mkdir -p "$WIN_FLOWIT_DIR"
cat "$WIN_LOVE_DIR/love.exe" flowit.love > "$WIN_FLOWIT_DIR/Flowit.exe"
cp "$WIN_LOVE_DIR/"*.dll "$WIN_FLOWIT_DIR"
cp "$WIN_LOVE_DIR/license.txt" "$WIN_FLOWIT_DIR/love_license.txt"
cp "../README.md" "$WIN_FLOWIT_DIR/flowit_readme_license.md"
cat "../LICENSE" >> "$WIN_FLOWIT_DIR/flowit_readme_license.md"
zip -q -r "$WIN_FLOWIT_ZIP" "$WIN_FLOWIT_DIR"
rm -r "$WIN_FLOWIT_DIR"
rm -r "$WIN_LOVE_DIR"
fi
if [[ $BUILD_MAC -eq 1 ]]; then
echo "Packaging Mac app..."
MAC_LOVE_APP_DIR="love.app"
MAC_FLOWIT_APP_DIR="Flowit.app"
MAC_FLOWIT_APP_ZIP="Flowit-mac-v${appver}.zip"
MAC_LOVE_DIR="love-11.4-macos"
MAC_LOVE_ZIP="$MAC_LOVE_DIR.zip"
# download zip if it doesn't exist
if [ ! -f "$MAC_LOVE_ZIP" ]; then
curl -L -O "https://github.com/love2d/love/releases/download/11.4/love-11.4-macos.zip"
fi
# delete directories built previously
if [ -d "$MAC_LOVE_DIR" ]; then
rm -r "$MAC_LOVE_DIR"
fi
if [ -d "$MAC_LOVE_APP_DIR" ]; then
rm -r "$MAC_LOVE_APP_DIR"
fi
if [ -d "$MAC_FLOWIT_APP_DIR" ]; then
rm -r "$MAC_FLOWIT_APP_DIR"
fi
unzip -q "$MAC_LOVE_ZIP"
mv "$MAC_LOVE_APP_DIR" "$MAC_FLOWIT_APP_DIR"
cp flowit.love "$MAC_FLOWIT_APP_DIR/Contents/Resources/Flowit.love"
cp ../desktop_resources/Info.plist "$MAC_FLOWIT_APP_DIR/Contents/"
cp ../desktop_resources/flowit.icns "$MAC_FLOWIT_APP_DIR/Contents/Resources/GameIcon.icns"
cp ../desktop_resources/flowit.icns "$MAC_FLOWIT_APP_DIR/Contents/Resources/OS X AppIcon.icns"
rm "$MAC_FLOWIT_APP_DIR/Contents/Resources/Assets.car"
cp "../README.md" "$MAC_FLOWIT_APP_DIR/Contents/Resources/flowit_readme_license.md"
cat "../LICENSE" >> "$MAC_FLOWIT_APP_DIR/Contents/Resources/flowit_readme_license.md"
zip -q -r "$MAC_FLOWIT_APP_ZIP" "$MAC_FLOWIT_APP_DIR"
rm -r "$MAC_FLOWIT_APP_DIR"
fi