Eclipse Theia is a platform to create IDEs and custom (modeling) tools based on web technology (Typescript, CSS and HTML). Please see this article for details about this new Eclipse project.
One advantage of using web technology and more in particular Eclipse Theia is that the tool can then be accessed directly in the browser without any installation or client set-up. However, this only works, if the tool based on Theia has been deployed somewhere. This could be a cloud server, a docker container, or in our case a Raspberry Pi! You might wonder why you would want to deploy a browser tool on a Raspberry Pi. First of all, a Raspberry is probably the cheapest server you can imagine, so if, for whatever reason, you cannot deploy and access your tool in the cloud, a Raspberry still allows a local client/server deployment. More interestingly, Raspberry Pis are often used to control or orchestrate embedded use cases. That means, the Raspberry executes some software which can control devices that are connected to it. In this scenario, having the tooling to develop this software running on the Raspberry provides a very consistent set-up. You could then ship a Raspberry which includes the software and the tooling – all on one device.
Anyway, since when do we need a reason to deploy something on a Raspberry Pi? It is just fun, so let us get going!
At this point we assume that you already installed the runtime dependencies of Theia, namingly Node.js v8 and Yarn.
The main issue we will have to deal with is a mismatch of processor architectures. The Raspberry Pi is powered by an ARM processor, while your development machine is likely an x86 based architecture. While it is certainly possible to build Theia directly on the Raspberry, you might want to instead use your regular computer for this. Doings so will save you the hassle of setting up the full build environment on the Raspberry and compilation will also be much faster.
First, compile Theia as usual using
This will build Theia for your current architecture (x86). Now we need to re-compile the native bits using our cross compiler. To do that we have to set two environment variables, defining the C and CPP compiler to use. You can set them like so:
export CC=/opt/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-gcc export CXX=/opt/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-g++
Make sure to accordingly adapt the locations to your installation.
Afterwards, you need to run the following command line in the Theia project root directory to re-compile the native code parts for a
npm rebuild --target_arch=arm
Finally, unset the cross-compiler using:
unset CC CXX
That’s it! Copy your project directory onto your Raspberry and start it as usual:
Note: There is currently a time out issue when running Theia on a slow machine like a Raspberry Pi. You can avoid this problem by appending –no-cluster to the yarn start command. With this option, everything will run in the same process rather than separate worker processes. The progress of this issue is being tracked here.