Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/bin/bash
# >>>>>> HELPER FUNCTIONS
function echoSection {
echo -en "\e[33m\n" #set color
echo "--------------------------------------------------------------------------------"
echo "--"
echo "-- " $1
echo "--"
echo -en "--------------------------------------------------------------------------------\e[37m\n"
}
function echoLine {
echo -en "\e[33m\n" #set color
echo "-- " $1
echo -en "\e[37m\n"
}
function echoConfirm {
echo -en "\e[35m---------------------------------------------------------------------------------\n"
read -p "-- $1 [Y/n]? " -n 1 -r
echo -en "\n--------------------------------------------------------------------------------\e[37m\n"
}
#END HELPER FUNCTIONS <<<<<<<<
echoSection "Creating Development Directories"
mkdir -p ~/Development/haxe/{dev,lib,source}
echoSection "Installing dependencies for haxe"
# get dependencies
sudo apt-get install -y libgc-dev libpcre3-dev
sudo apt-get install -y build-essential git cmake
sudo apt-get install -y libudev-dev
sudo apt-get install -y ocaml ocaml-native-compilers libpcre-ocaml-dev
sudo apt-get install -y sqlite3 libsqlite3-dev
sudo apt-get install -y libmysqlclient-dev
sudo apt-get install -y libasound2-dev
echoSection "Downloading and installing neko"
# get neko first
cd ~/Development/haxe/source
wget -c http://builds.openfl.org.s3-us-east-2.amazonaws.com/neko/neko-2.0.0-rpi.zip
sudo mkdir -p /usr/lib/neko
sudo rm -rf /usr/lib/neko/neko
sudo rm -rf /usr/lib/neko/nekotools
sudo unzip -o neko-2.0.0-rpi.zip -d /usr/lib/neko/
sudo cp -r /usr/lib/neko/bin/* /usr/lib/neko
sudo rm -rf /usr/lib/neko/bin
sudo rm -rf /usr/bin/neko
sudo rm -rf /usr/bin/nekoc
sudo rm -rf /usr/bin/nekotools
sudo rm -rf /usr/lib/libneko.so
sudo ln -s /usr/lib/neko/libneko.so /usr/lib/libneko.so
sudo ln -s /usr/lib/neko/neko /usr/bin/neko
sudo ln -s /usr/lib/neko/nekoc /usr/bin/nekoc
sudo ln -s /usr/lib/neko/nekotools /usr/bin/nekotools
rm neko-2.0.0-rpi.zip
echoSection "Downloading and compiling haxe 3.4.2 from source"
#get haxe
cd ~/Development/haxe/source
git clone --recursive https://github.com/HaxeFoundation/haxe -b 3.4.2
cd haxe
make
make tools
sudo make install install_tools
echoSection "Setting up haxelib and install packages"
cd ~/Development/haxe/
haxelib setup ./lib
haxelib install format
haxelib install hxcpp
haxelib install openfl
haxelib run openfl setup
echoSection "Create clean .hxcpp_config.xml file for Raspberry Pi"
rm -f ~/.hxcpp_config.xml
echo '<?xml version="1.0" encoding="utf-8"?>
<xml>
<section id="vars">
<set name="rpi" value="1"/>
<set name="HXCPP_COMPILE_CACHE" value="/home/pi/Development/.hxcpp_compilecache"/>
</section>
<section id="exes">
</section>
</xml>' >> ~/.hxcpp_config.xml
echoSection "Getting latest lime"
cd ~/Development/haxe/dev/
git clone --recursive https://github.com/openfl/lime
haxelib dev lime lime
echoSection "Rebuilding hxcpp for Raspberry Pi"
lime rebuild hxcpp linux -rpi -v
lime rebuild hxcpp linux -rpi -static -v
echoSection "Rebuilding Lime tools and Lime for Raspberry Pi"
lime rebuild tools linux -rpi -v
lime rebuild lime linux -rpi -v
echoSection "Create clean .lime/config.xml file for Raspberry Pi"
rm -f ~/.lime/config.xml
echo '<?xml version="1.0" encoding="utf-8"?>
<xml>
<section id="defines">
<set name="rpi" value="1"/>
</section>
</xml>' >> ~/.lime/config.xml
echoConfirm "Would you like to add some aliases for building and running openfl projects to ~/.bash_aliases?"
if [[ $REPLY =~ ^[Yy]$ ]]
then
if grep -q "ofbuild" ~/.bash_aliases; then
echoLine "It appears you already have these aliases. Try: gofl, ofbuild, oftest or ofrun"
else
echo "alias gofl='cd ~/Development/openfl'
alias ofbuild='openfl build linux -v'
alias oftest='openfl test linux -v'
alias ofrun='openfl run linux'" >> ~/.bash_aliases
source ~/.bash_aliases
echoLine "you now have the following aliases: gofl, ofbuild, oftest, ofrun"
fi
fi
echoConfirm "Would you like to check out the openfl-samples-raspberrypi samples?"
if [[ $REPLY =~ ^[Yy]$ ]]
then
mkdir -p ~/Development/openfl
cd ~/Development/openfl
git clone https://github.com/gepatto/openfl-samples-raspberrypi.git
echoSection "Now cd into one of the samples at ~/Development/openfl/openfl-samples-raspberrypi and run: openfl test linux"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment