Skip to content

Instantly share code, notes, and snippets.

@gepatto
Last active January 13, 2021 16:24
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gepatto/325441767959d79e00378e54cf9f4ad9 to your computer and use it in GitHub Desktop.
Save gepatto/325441767959d79e00378e54cf9f4ad9 to your computer and use it in GitHub Desktop.
Install set versions of haxe, openfl and lime on Raspberry Pi 3 running Stretch

#DEPRECATED, here for historic value

UPDATED to work with Raspbian Stretch

These scripts install a set version of openfl and lime in this case openfl 8.4.0 and Lime 7.0.0 (but you change those) Sometimes the latest version of lime or openfl doesn't work (yet) on the Raspberry Pi.

There's 2 scripts here to install haxe and openfl on Raspberry Pi. One that doesn't ask any questions and just installs everything
and one that takes you step by step.
( I recommend the latter )

After installation completes you need to logout and login to have ~/.bashrc set HAXE_STD_PATH correctly or do
source ~/.bashrc

if for some reason you still get Standard library not found error
Manually add the following line to your ~/.bashrc script export HAXE_STD_PATH=/usr/lib/haxe/std

#!/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"
}
function echoWarn {
echo -en "\e[38m\n" #set color
echo "--------------------------------------------------------------------------------"
echo -en $1
echo -en "\n--------------------------------------------------------------------------------\e[37m\n"
}
function echoFail {
echo -en "\e[31m\n" #set color
echo "--------------------------------------------------------------------------------"
echo -en $1
echo -en "\n--------------------------------------------------------------------------------\e[37m\n"
}
function echoConfirm {
echo -en "\n\e[35m------------------------------------------------------------------------------------\n"
echo -en "$1 [y/n]:? "
read REPLY
echo -en "-----------------------------------------------------------------------------------\e[37m\n"
}
#END HELPER FUNCTIONS <<<<<<<<
HAXE_VERSION='3.4.7'
OPENFL_VERSION='8.4.0'
LIME_VERSION='7.0.0'
HAXEPATHCOMMAND="export HAXE_STD_PATH=/usr/lib/haxe/std"
echoSection "Creating Development Directories: ~/Development/haxe"
mkdir -p ~/Development/haxe/{dev,lib,source}
echoConfirm "Would you like to download dependencies for building haxe from source?"
if [[ $REPLY =~ ^[Yy]$ ]]
then
echoSection "Installing dependencies for haxe"
sudo apt-get update
# 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 libasound2-dev
if grep -q "stretch" /etc/*-release;then
sudo apt-get install -y default-libmysqlclient-dev
else
sudo apt-get install -y libmysqlclient-dev
fi
fi
echoConfirm "Download and install neko"
if [[ $REPLY =~ ^[Yy]$ ]]
then
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
fi
echoConfirm "Download and compile haxe ${HAXE_VERSION} from source"
if [[ $REPLY =~ ^[Yy]$ ]]
then
echoSection "Downloading and compiling haxe ${HAXE_VERSION} from source"
#get haxe
cd ~/Development/haxe/source
git clone --recursive https://github.com/HaxeFoundation/haxe -b $HAXE_VERSION
cd haxe
make
make tools
sudo make install install_tools
export HAXE_STD_PATH=/usr/lib/haxe/std
fi
if [ -z "$HAXE_STD_PATH" ]; then
if grep -qs "HAXE_STD_PATH" ~/.bashrc
then
echo "good HAXE_STD_PATH is already exported in ~/.bashrc. It should be set on next login."
else
echoConfirm "For proper functioning, HAXE_STD_PATH should be set.
Would you like to add HAXE_STD_PATH to .bashrc"
if [[ $REPLY =~ ^[Yy]$ ]]
then
echo $HAXEPATHCOMMAND >> ~/.bashrc
else
echo -e "You will need to add the following export line to .bashrc or .profile script: \n $HAXEPATHCOMMAND"
fi
fi
export HAXE_STD_PATH=/usr/lib/haxe/std
fi
echoConfirm "Setup haxelib and install packages"
if [[ $REPLY =~ ^[Yy]$ ]]
then
echoSection "Setting up haxelib and install packages required for building lime"
cd ~/Development/haxe/
haxelib setup ./lib
haxelib install format
haxelib install hxcpp
haxelib install hxp
haxelib install openfl
haxelib run openfl setup
fi
echoConfirm "Create clean .hxcpp_config.xml file for Raspberry Pi and turn on hxcpp compilercache"
if [[ $REPLY =~ ^[Yy]$ ]]
then
echoSection "Creating clean .hxcpp_config.xml file for Raspberry Pi and turning on hxcpp compilercache in /home/pi/Development/.hxcpp_compilecache"
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
fi
echoConfirm "Create clean .lime/config.xml file for Raspberry Pi"
if [[ $REPLY =~ ^[Yy]$ ]]
then
echoSection "Creating clean .lime/config.xml file for Raspberry Pi"
rm -f ~/.lime/config.xml
mkdir -p ~/.lime
echo '<?xml version="1.0" encoding="utf-8"?>
<xml>
<section id="defines">
<set name="rpi" value="1"/>
</section>
</xml>' >> ~/.lime/config.xml
fi
echoConfirm "Get lime version $LIME_VERSION from git"
if [[ $REPLY =~ ^[Yy]$ ]]
then
echoSection "Get lime version $LIME_VERSION from git"
cd ~/Development/haxe/dev/
git clone --recursive https://github.com/openfl/lime -b $LIME_VERSION
haxelib dev lime lime
fi
echoConfirm "Rebuild hxcpp"
if [[ $REPLY =~ ^[Yy]$ ]]
then
echoSection "Rebuilding hxcpp for Raspberry Pi"
haxelib run lime rebuild hxcpp linux -rpi -v
haxelib run lime rebuild hxcpp linux -rpi -static -v
fi
echoConfirm "Rebuild Lime"
if [[ $REPLY =~ ^[Yy]$ ]]
then
echoSection "Rebuilding Lime tools and Lime for Raspberry Pi"
lime rebuild tools linux -rpi -v
lime rebuild lime linux -rpi -v
fi
echoSection "Now get version $OPENFL_VERSION of openfl that works with version $LIME_VERSION of lime"
haxelib install openfl $OPENFL_VERSION
haxelib set openfl $OPENFL_VERSION
echoSection "All Done. You should now be able to compile an openfl project"
lime -v
openfl -v
## NOT YET VERIFIED
#!/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"
}
function echoWarn {
echo -en "\e[38m\n" #set color
echo "--------------------------------------------------------------------------------"
echo -en $1
echo -en "\n--------------------------------------------------------------------------------\e[37m\n"
}
function echoFail {
echo -en "\e[31m\n" #set color
echo "--------------------------------------------------------------------------------"
echo -en $1
echo -en "\n--------------------------------------------------------------------------------\e[37m\n"
}
function echoConfirm {
echo -en "\n\e[35m------------------------------------------------------------------------------------\n"
echo -en "$1 [y/n]:? "
read REPLY
echo -en "-----------------------------------------------------------------------------------\e[37m\n"
}
#END HELPER FUNCTIONS <<<<<<<<
HAXE_VERSION='3.4.7'
OPENFL_VERSION='8.4.0'
LIME_VERSION='7.0.0'
HAXEPATHCOMMAND="export HAXE_STD_PATH=/usr/lib/haxe/std"
echoSection "Creating Development Directories: ~/Development/haxe"
mkdir -p ~/Development/haxe/{dev,lib,source}
echoSection "Installing dependencies for haxe"
sudo apt-get update
# 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 libasound2-dev
if grep -q "stretch" /etc/*-release;then
sudo apt-get install -y default-libmysqlclient-dev
else
sudo apt-get install -y libmysqlclient-dev
fi
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 ${HAXE_VERSION} from source"
#get haxe
cd ~/Development/haxe/source
git clone --recursive https://github.com/HaxeFoundation/haxe -b $HAXE_VERSION
cd haxe
make
make tools
sudo make install install_tools
if [ -z "$HAXE_STD_PATH" ]; then
if grep -qs "HAXE_STD_PATH" ~/.bashrc
then
echo "good HAXE_STD_PATH is already exported in ~/.bashrc. It should be set on next login."
else
echo $HAXEPATHCOMMAND >> ~/.bashrc
fi
export HAXE_STD_PATH=/usr/lib/haxe/std
fi
echoSection "Setting up haxelib and install packages required for building lime"
cd ~/Development/haxe/
haxelib setup ./lib
haxelib install format
haxelib install hxcpp
haxelib install hxp
haxelib install openfl
haxelib run openfl setup -y
echoSection "Creating clean .hxcpp_config.xml file for Raspberry Pi and turning on hxcpp compilercache in /home/pi/Development/.hxcpp_compilecache"
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 "Creating clean .lime/config.xml file for Raspberry Pi"
rm -f ~/.lime/config.xml
mkdir -p ~/.lime
echo '<?xml version="1.0" encoding="utf-8"?>
<xml>
<section id="defines">
<set name="rpi" value="1"/>
</section>
</xml>' >> ~/.lime/config.xml
echoSection "Get lime version $LIME_VERSION from git"
cd ~/Development/haxe/dev/
git clone --recursive https://github.com/openfl/lime -b $LIME_VERSION
haxelib dev lime lime
echoSection "Rebuilding hxcpp for Raspberry Pi"
haxelib run lime rebuild hxcpp linux -rpi -v
haxelib run 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 "Now get version $OPENFL_VERSION of openfl that works with version $LIME_VERSION of lime"
haxelib install openfl $OPENFL_VERSION
haxelib set openfl $OPENFL_VERSION
echoSection "All Done. You should now be able to compile an openfl project"
lime -v
openfl -v
@Absulit
Copy link

Absulit commented Dec 28, 2018

I'm having the following error in a raspberry pi 3

/home/pi/Development/haxe/lib/hxp/1,0,5/src/hxp/System.hx:4: characters 7-20 : Type not found : haxe.MainLoop

I tried a couple of scripts:

install_haxe_rpi.sh and install_openfl/sh

This error appear in two places for me, when using the scripts trying to execute this line:

lime rebuild hxcpp linux -rpi -v

and later trying to test or build a openfl project

At some point I was able to not have the errors by using this fix you mention here
https://community.haxe.org/t/solved-raspberry-pi-setup-issue/1111/3
Even with the fix I was not able to compile, but I think is a different issue, this because the error was related to the "project.xml" or wrong parameters.

Anyway, I rolled back to try again and the error persist (it's showing again and I'm not able to fix it).

Can you point me in the right direction?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment