Friday, January 4, 2013

Compile OpenJFX RT on MacOsX

This time I want to describe what was necessary for me to compile the OpenJFX Project on my laptop, a MacBook Pro running Mountain Lion.
Quoting from the page:
As you can imagine, building a UI toolkit for many different platforms is quite complex. It requires platform specific tools such as C compilers as well as portable tools like ant. The build and project structure of JavaFX like most large projects has evolved over time and is constantly being revised.

I'm writing this early January 2013, maybe things will change in the future. I would love to see a mavenized build for OpenJFX, or even for the whole JDK which would increase adoption tremendously for the whole OpenJDK in my opinion.   

Step 1 to 10 - Checkout the source and do the rest

Mercurial, java, and ant should be installed, then the getting started guide gives you following recipe:

Here is the recipe for building OpenJFX (use a Cygwin shell on Windows):

  • Download the latest JavaFX Developer Preview binary
  • Unzip the binary and put it in ~/closed-jfx
  • mkdir -p ~/open-jfx
  • cd ~/open-jfx
  • hg clone http://hg.openjdk.java.net/openjfx/2.1/master
  • cd master
  • mkdir -p artifacts/sdk/rt
  • cp -r ~/closed-jfx/javafx-sdk2.1.0-beta/rt artifacts/sdk
  • hg clone http://hg.openjdk.java.net/openjfx/2.1/master/rt
  • cd rt
  • Edit build-defs.xml (comment out '<propertycopy name="javac.debuglevel" from="${ant.project.name}.javac.debuglevel" silent="true" override="true"/>')
  • cd javafx-ui-controls
  • ant
..... One hour later: I've followed those instructions, but got in trouble with step one (bravely continued with step 2, though). Searched for a macos binary (didn't know what to search for really?). Decided to go on. Sadly enough, I got stuck some time later with compile errors (Abstract methods not implemented by ... ?! well - this was rather strange.)

But ...


Just before giving it up, I've found after some googling the website of Peter Pilgrim, who just briefly mentioned that the getting started guide was somewhat outdated and after following his instructions I happily compiled openjfx the first time on my laptop!

For further reference, here are the necessary steps to compile OpenJFX:

mkdir openjfx-2.2/
cd openjfx-2.2/
hg clone http://hg.openjdk.java.net/openjfx/2.2/master
cd master
mkdir -p artifacts/sdk/rt/lib
cp $JAVA_HOME/jre/lib/jfxrt.jar artifacts/sdk/rt/lib
hg clone http://hg.openjdk.java.net/openjfx/2.2/master/rt
cd rt
-> edit common.properties, set property javac.debuglevel=lines,vars,source
ant clean dist


The story doesn't end here, in fact I've discovered that there are already efforts on mavenizing openjfx, at least I've found a pom.xml in the rt subdirectory.

With
hg log pom.xml
I've found out that in RT-19825 Adam Bien contributed those pom files.

After commenting the system dependency for the jfxrt.jar (since I've copied the jfxrt.jar into the jre/lib/ext directory by using zonskis maven fix classpath plugin) it happily compiled (by skipping the tests ) using following command :

mvn clean package -Dmaven.test.skip

(Disclaimer: I don't know if the maven build does the same as the ant build does - after inital commit those files seem to be untouched.)

Bottom line for me is that building/compiling (parts of/all of??) OpenJFX was easier than expected. Although I'm sure that this is not the end of the story. I would suspect that the native stuff wasn't compiled?! At least in the 'rt' directory there are only java sources...

The answer to this seems to be that this was only a small part of OpenFX. If you look at the Mercurial index page there are lots of different versions and components for OpenFX:


As you can see, I was only in one sub module of the whole game, but I hope you got the idea how to check out and build the project - it is as simple as described above!

For example, have a look in the openjfx 2.2.6 development:



mkdir openjfx-2.2.6/
cd openjfx-2.2.6/
hg clone http://hg.openjdk.java.net/openjfx/2.2.6/master
cd master
mkdir -p artifacts/sdk/rt/lib
cp $JAVA_HOME/jre/lib/jfxrt.jar artifacts/sdk/rt/lib
hg clone http://hg.openjdk.java.net/openjfx/2.2.6/master/rt
cd rt
-> edit common.properties, set property javac.debuglevel=lines,vars,source
ant clean dist

For the JDK8 branch the procedure works as described, but make sure you set your path to a JDK8. You could of course compile this also from source, but it's maybe easier to get a full JDK8 early access build from here.


ant clean dist for OpenFX-8 (in green)

Small update:

Only recently the structure of the repositories was explained a little bit, quoting Kevin Rushforth:

Each of the following should be treated as a separate forest. You would only grab one of these forests depending on which one you want.
1. The controls team forest:
openjfx/8/controls   openjfx/8/controls/rt   openjfx/8/controls/tests
2. The graphics team forest:
openjfx/8/graphics   openjfx/8/graphics/rt   openjfx/8/graphics/tests
3. The master forest:
openjfx/8/master   openjfx/8/master/rt   openjfx/8/master/tests
The team forests is where the work happens. Each team integrates into the master forest regularly (typically weekly).

Update February 2013:


Note: This tutorial was written early 2013, maybe in the meantime things have changed. There are efforts going on to restructure the build using gradle scripts, so maybe things have changed. This wiki page should be up to date and reflecting the current status of the build.

Have also a look at this video (after reading the whole blog post ;-) on how to do it:




This video shows that compiling JavaFX from source is just some clicks away. 

No comments:

Post a Comment