Home Home > 2014 > 03 > 24 > Emscripten and openSUSE: Hands on.. Hands up!
Sign up | Login

Deprecation notice: openSUSE Lizards user blog platform is deprecated, and will remain read only for the time being. Learn more...

Emscripten and openSUSE: Hands on.. Hands up!

March 24th, 2014 by

Emscripten logo
I can code with javascript and I’m fairly good at it (not marvelous just brialiant!). If you have read some of my resent blog post I think in C/C++/Perl or Bash. I also have some kind of a hobby to help out with UnReal world RPG game. Mostly my part is to make it work with *nix platform (mainly Linux and Mac OS X).
As we have seen world is moving fast forward towards web. It’s the-place-to-be for everyone. There is huge potential for players just wandering around and yelling for pleasure to play UrW! So I thought let’s see if we could port SDL to javascript/Flash or something straight from same source. after tiny amount of searching I popped up Emscripten.

Emscripten in nutshell

Emscripten is stated in their Github page (which seems to be only place to reach this project) like this:

Emscripten is an LLVM-to-JavaScript compiler. It takes LLVM bitcode - which can be generated from C/C++, using llvm-gcc or clang, or any other language that can be converted into LLVM - and compiles that into JavaScript, which can be run on the web (or anywhere else JavaScript can run).

So in other words you can your existing C++ or C source code and compile it (with minor changes) to javascript pseudocode with LLVM back-end. I thought it can’t be working and started digging further.

How to test it on openSUSE

If you have openSUSE 12.3 or above you are good to go or you need to install LLVM 3.2 or above from OBS. You can do it with zypper like this:

zypper install llvm llvm-devel llvm-clang llvm-clang-devel git nodejs

Ain’t Clang just another C-compiler? So why not use GCC? Answer is LLVM is very flexible system (GCC is kinda married to C/C++. even there is many other backends) that turns code to Abstract syntax tree and then back-end compiles it to binary (which can anything from machine code to some of your favorite byte code like Java/C#). So in other words you have parser (clang) and you write back-end to generate code (javascript) quite easily (in theory). I think it was kind idea behind GCC in version 3.0 but as said it doesn’t work as seamlessly as it works in LLVM. Another strong point with LLVM is license. (L)GPL is fine license but if you have compiler you license should be as free as it gets.

So HOW TO TEST IT?

I haven’t got time to make rpm-package from Emscripten because I’m still learning by myself but I’ll share now what I have learned:

Ok now you have read Emscripten documentation and you have clang, nodejs and git installed. Clone the Emscripten Git-repo

git clone https://github.com/kripken/emscripten.git

If you just want to test something you can follow this tutorial: http://sol.gfxile.net/emscripten/ so you get the idea. This how far I’ll take you this time. I’ll figure out some SDL examples to be ported (since UnReal World RPG uses SDL) in near future so stay tuned.

Both comments and pings are currently closed.

Comments are closed.