intertwingly

It’s just data

Building Firefox with HTML5 parser support


Start by installing some build prerequisites.  The following are for Ubuntu, adjust as necessary:

sudo apt-get build-dep firefox
sudo apt-get install mercurial libasound2-dev libcurl4-openssl-dev

Now check out the source to an HTML5 enabled Firefox:

mkdir -p ~/hg/
cd ~/hg/
hg clone http://hg.mozilla.org/users/mrbkap_mozilla.com/html5parsing/

The next step requires requires Python, Subversion and JDK 5 or later (JDK 6 and Hardy’s OpenJDK work).

mkdir -p ~/svn/
cd ~/svn/
mkdir checker
cd checker
svn co http://svn.versiondude.net/whattf/build/trunk/ build
python build/build.py checkout dldeps

if you get a timeout from SourceForge, simply try again.  At the present time Google code’s hosting of jing-trang is currently down.  For our purposes, that library is not necessary.  Press on.

You are not done yet.

mkdir tmp
wget http://javaparser.googlecode.com/files/javaparser_2008-06-19.zip -O tmp/javaparser_2008-06-19.zip
unzip tmp/javaparser_2008-06-19.zip -d dependencies/ javaparser_2008-06-19.jar

On to generating the cpp sources from java...

cd htmlparser/translator-src/
javac nu/validator/htmlparser/generator/GenerateNamedCharactersCpp.java
java nu.validator.htmlparser.generator.GenerateNamedCharactersCpp ../doc/named-character-references.html ~/hg/html5parsing/content/html/parser/src/ 
javac -classpath .:../../dependencies/javaparser_2008-06-19.jar nu/validator/htmlparser/cpptranslate/Main.java
java -classpath .:../../dependencies/javaparser_2008-06-19.jar nu.validator.htmlparser.cpptranslate.Main ../src/nu/validator/htmlparser/impl/ ~/hg/html5parsing/content/html/parser/src/ ~/hg/html5parsing/content/html/parser/src/nsHtml5AtomList.h ~/hg/html5parsing/content/html/parser/src/nsHtml5StringLiterals.cpp

Create a mozilla build configuration file in ~/.mozconfig.  Here’s mine:

. $topsrcdir/browser/config/mozconfig
mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/ff-opt
# ac_add_options --enable-static --disable-libxul
ac_add_options --disable-tests
ac_add_options --disable-crashreporter

Note the commented out options are documented but don’t work.  Now build firefox.

cd ~/hg/html5parsing
make -f client.mk build

Before running, make sure you reset your expectations.  I ran it with my default profile, but I have plenty of backups.  Caveat emptor.

If you still insist on executing the results, you must first exit all Firefox windows.  Only then can you launch your executable with the following:

ff-opt/dist/bin/firefox