-
Notifications
You must be signed in to change notification settings - Fork 1
/
CompleteHaxeLimeInstall_Menu_RPi.sh
316 lines (258 loc) · 9.57 KB
/
CompleteHaxeLimeInstall_Menu_RPi.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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
#!/bin/bash
##########################################
# Gepatto 2023 #
# find me on openfl or haxe discord #
##########################################
### Color Variables ###
BLACK="\e[30m"
RED="\e[31m"
GREEN="\e[32m"
YELLOW="\e[33m"
BLUE="\e[34m"
PURPLE="\e[35m"
TEAL="\e[36m"
WHITE="\e[37m"
WARN="\e[38m"
CLEAR='\e[0m'
# >>>>>> HELPER FUNCTIONS
Section() {
local color="${2:-$YELLOW}";echo -en "$color\n--------------------------------------------------------------------------------\n* \n* "$1"\n* \n--------------------------------------------------------------------------------$WHITE\n"
}
Line() {
local color="${2:-$YELLOW}";echo -en "$color\n* "$1"$WHITE\n"
}
Done() {
echo -en "$GREEN\n--------------------------------------------------------------------------------\n* \n* "$1"\n* \n--------------------------------------------------------------------------------$WHITE\n"
}
Warn() {
echo -en "$WARN\n--------------------------------------------------------------------------------\n* \n* "$1"\n* \n--------------------------------------------------------------------------------$WHITE\n"
}
Fail() {
echo -en "$RED\n--------------------------------------------------------------------------------\n* \n* "$1"\n* \n--------------------------------------------------------------------------------$WHITE\n"
}
Confirm() {
echo -en "\n$PURPLE--------------------------------------------------------------------------------\n* $1?$WHITE "
read -p "[Y/n] " -n 1 -r
echo -en "\n$PURPLE--------------------------------------------------------------------------------\n$WHITE"
}
ColorGreen(){
echo -en $GREEN$1$CLEAR
}
ColorBlue(){
echo -en $BLUE$1$CLEAR
}
ColorPurple(){
echo -en $PURPLE$1$CLEAR
}
#END HELPER FUNCTIONS <<<<<<<<
DEFAULTTAGNAME="4.3.1-bullseye"
DOCKER='/usr/bin/docker'
function installDocker {
Section "Installing Docker"
if test -f "$DOCKER";
then
DOCKERVERSION=$(docker -v)
Done "Docker $DOCKERVERSION is already installed"
else
Confirm "Docker is not installed yet, would you like to install (needs reboot)"
if [[ $REPLY =~ ^[Yy]$ ]]
then
curl -sSL https://get.docker.com | sh
sudo usermod -aG docker $USER
Section "Docker is now installed, but you need to reboot and run this script again."
exit 0;
else
Warn "Ok, not running this script any further"
exit 0;
fi
fi
}
function installHaxeFromDocker {
INSTALL=0
if test -f "$DOCKER";
then
Section "Installing haxe from docker"
else
Warn "Installing docker first ..."
installDocker
fi
if test -f "/usr/local/bin/haxe";
then
HAXEVERSION=$(haxe --version)
Confirm "It seems Haxe $HAXEVERSION is already installed, would you like to overwrite it"
if [[ $REPLY =~ ^[Yy]$ ]]
then
INSTALL=1
fi
else
INSTALL=1
fi
if [ $INSTALL -eq 1 ];
then
mkdir -p ./docker_haxe/
sudo mkdir -p /usr/local/share/haxe/
echo -en "\n$PURPLE>> "
read -p "Please enter the haxe docker tagname to install [$DEFAULTTAGNAME]: " dockertagname
TAGNAME=${dockertagname:-$DEFAULTTAGNAME}
echo -en $WHITE"\n"
Line "running/getting docker image ${TAGNAME}";
docker run haxe:${TAGNAME}
Line "getting CONTAINERID"
CONTAINERID=`docker ps -aq --latest`
Line "copying from container: $CONTAINERID"
docker cp $CONTAINERID:/usr/local/bin/haxe ./docker_haxe/
docker cp $CONTAINERID:/usr/local/bin/haxelib ./docker_haxe/
docker cp $CONTAINERID:/usr/local/share/haxe/std ./docker_haxe/
sleep 2
# create archive of binaries for future use
HAXEVERSION=$(haxe --version)
Line "creative haxe-binaries-$HAXEVERSION.tgz archive for future use"
tar zcf haxe-binaries-$HAXEVERSION.tgz ./docker_haxe
installHaxeFromDir "docker_haxe"
fi
}
function installHaxeFromDir {
if [[ $# -ne 1 ]]; then
Section "Installing haxe from a directory"
echo -en "\n$PURPLE>> "
read -p "Enter the path to the local dir with the haxe binaries [docker_haxe]: " dirname
SOURCEDIR=${dirname:-docker_haxe}
echo -en $WHITE
else
SOURCEDIR=$1
fi
if test -d $SOURCEDIR;
then
cd $SOURCEDIR
if test -f haxe;
then
Line "copying haxe and haxelib binaries from $SOURCEDIR to /usr/local/bin/"
sudo cp haxe /usr/local/bin/
sudo cp haxelib /usr/local/bin/
Line "copying haxe std lib to to /usr/local/share/haxe/std"
sudo cp -R std /usr/local/share/haxe/
else
Fail "No haxe binaries found in dir $SOURCEDIR"
fi
else
Fail "Sorry can't find the directory $SOURCEDIR"
fi
HAXEVERSION=$(haxe --version)
# if HAXE_STD_PATH is not already in bashrc
if [ `grep 'export HAXE_STD_PATH' ~/.bashrc | wc -l` -eq 0 ]; then
Line "adding HAXE_STD_PATH to ~/.bashrc"
echo -e "\nexport HAXE_STD_PATH=\"/usr/local/share/haxe/std\"" >> ~/.bashrc
fi
if test -f /usr/bin/neko;
then
Line "Good neko is already installed"
else
Line "installing neko"
sudo apt install -y neko
fi
# setup haxelib
Line "Setting up haxelib"
haxelib setup
haxelib --global update haxelib
Done "Haxe $HAXEVERSION is installed"
}
function installOpenFL {
Section "Installing OpenFL"
haxelib install format
haxelib install hxp
haxelib install hxcpp
haxelib install openfl
if [ ! -f /usr/local/bin/openfl ]; then
haxelib run openfl setup
fi
haxelib install flixel-tools
if [ ! -f /usr/bin/flixel ]; then
haxelib run flixel-tools setup
fi
}
function installLimeGit {
INSTALL=0
Section "Installing Lime fron Git"
Line "installing some dependencies so we can compile lime"
sudo apt install -y build-essential git
sudo apt install -y libdrm-dev libgbm-dev libx11-dev libxext-dev libgles2-mesa-dev libasound2-dev libudev-dev
sudo apt install -y libxcursor-dev libxinerama-dev libxi-dev libxrandr-dev libdbus-1-dev libpulse-dev
echo -en "\n$PURPLE>> "
read -p "Enter a path to install lime [~/Development/haxe/dev]: " dirname
installdir=${dirname:-~/Development/haxe/dev}
Line "creating $installdir"
mkdir -p $installdir
cd $installdir
if test -d "$installdir/lime";
then
Confirm "There already is a lime directory at $installdir/lime.\n* Would you like to rename it and continue "
if [[ $REPLY =~ ^[Yy]$ ]]; then
DATEPOSTFIX=$(date +%F)
mv $installdir/lime "$installdir/lime_$DATEPOSTFIX"
INSTALL=1
fi
else
INSTALL=1
fi
if [ $INSTALL -eq 1 ];
then
echo -en '\n'$PURPLE
read -p "Enter the Branch you want to checkout [8.2.0-Dev]: " branchname
branch=${branchname:-8.2.0-Dev}
Line "Checking out branch $branch"
echo -en $WHITE
git clone --recursive https://github.com/openfl/lime -b $branch
Line "Rebuilding lime for Raspberry Pi"
haxelib dev lime lime
cd 'lime'
lime rebuild lime linux -rpi -v
fi
}
function enableHxcppCompileCache {
Line "checking for /home/$USER/.hxcpp_config.xml"
if test -f /home/$USER/.hxcpp_config.xml
then
if [ `grep 'HXCPP_COMPILE_CACHE' ~/.hxcpp_config.xml | wc -l` -eq 0 ]; then
MATCH="<!-- If you want to control how many compilers get spawned"
PATCH=" <set name=\"HXCPP_COMPILE_CACHE\" value=\"\/home\/$USER\/.hxcpp_cache\" \/>\n"
sed -e "/$MATCH/i\ $PATCH" ~/.hxcpp_config.xml > ~/.hxcpp_config_new.xml
cp ~/.hxcpp_config.xml ~/.hxcpp_config_old.xml
mv ~/.hxcpp_config_new.xml ~/.hxcpp_config.xml
Done "HXCPP_COMPILE_CACHE with value /home/$USER/.hxcpp_cache has been added to /home/$USER/.hxcpp_config.xml"
fi
else
Warn "There is no .hxcpp_config.xml file yet"
fi
}
function about {
Section "This script was created to setup Haxe,Lime and OpenFL on a Raspberry Pi 3B+ or 4B running piOS (Raspbian Bullseye) \n* Your Raspberry Pi needs to have the (F)KMS driver overlay enabled\n* Lime applications build for native (hxcpp) can run from the commandline and on X11\n*\n* Gepatto 2023 - Find me on haxe or openfl discord"
}
function menu(){
Section "Menu for installing Docker, Haxe, OpenFL or Lime"
echo -ne \
"$(ColorGreen '1)') Install Docker (needed for installing haxe)
$(ColorGreen '2)') Install Haxe from Docker
$(ColorGreen '3)') Install and setup openFL
$(ColorGreen '4)') Install Lime from Github
$(ColorGreen '-- optional')
$(ColorGreen '5)') Install Haxe from a Directory ( archived binaries from previous docker installed haxe )
$(ColorGreen '6)') Enable Hxcpp Compile Cache (Experimental)
$(ColorGreen '7)') About
$(ColorGreen '0)') Exit
$(ColorPurple '>> Choose an option:') "
read a
case $a in
1) clear -x;installDocker ; menu ;;
2) clear -x;installHaxeFromDocker ; menu ;;
3) clear -x;installOpenFL ; menu ;;
4) clear -x;installLimeGit ; menu ;;
5) clear -x;installHaxeFromDir; menu ;;
6) clear -x;enableHxcppCompileCache ; menu ;;
7) clear -x;about ; menu ;;
0) exit 0 ;;
*) clear -x;echo -e $RED" Wrong option: "$a$CLEAR; menu;;
esac
}
# LET'S START THE MENU
clear -x;
menu