Saturday, June 11, 2011

Guidelines to port webkit

As i write this blog the webkit is ported to at least 8 platforms like gtk,qt,mac,symbian,haiku,wince,android,efl and many more to come..
If some one is new to webkit and wants to know where to start porting from I will try and put some basic guidelines to follow.
First and foremost see if you have what is needed to port on your platform:
i) Threading -> pthread equivalent API's if you want multi-threading (ENABLE_JSC_MULTIPLE_THREADS turn it OFF if you do not have one)
ii) Timers -> any platform would have this so it should be fine
iii) Drawing surface/Graphics Library
iv) Way to integrate widgets with your drawing surface; put it another way how to provide input to your webpage. Gtk has clean way of doing this, can be followed
v) Theme for widgets
vi) Define API layer -> follow QT/GTK/MAC/Android port for defining one.
vii) Porting JSCore by defining classes PageAllocation/Reservation
viii) Some other classes/functions are needed like random number function, date etc;
ix) I am keeping it very brief but you need a way to take care of plugins
-) Plugin Creation
-) Plugin Drawing Surface
x) Networking component like curl,soup
xi) Need to port the WebCoreSupport classes again follow GTK/QT port for ease
xii) Image decoders
After checking if you have got everything { only v) is not mandatory ix) is not mandatory if you do not want plugins}

Now after getting the first step right second thing to do is getting your build set up:
Start with javascriptcore, you need to build the source and generate derivedsources and see if you can get it built right. To do this you have to port some functions as I mentioned earlier.
To test if you got the build right you can run the javscriptcore tests.

Once this is done you can replicate the same for Webcore, you need to create the stub files/functions for port. Follow one port like GTK/QT for this like create files in WebCore/platform/xyz folder;

Once this is ready, you need to get this port back into open source as later sync up with the open source is necessity. Follow http://trac.webkit.org/wiki/SuccessfulPortHowTo for creating DRT, automation tests which is needed for getting code back into trunk.



Sunday, June 5, 2011

WebKit Build Issues

Steps to build webkit gtk port (I am doing this on Ubunty Natty )are :
Installing dependencies ->
sudo apt-get install build-essential vim subversion libglib2.0-dev gtk-doc-tools bison flex gperf libicu-dev libjpeg62-dev libpng12-dev libxml2-dev libpango1.0-dev libgail-dev libxt-dev libsoup2.4-dev libsqlite3-dev libxslt1-dev libgstreamer-plugins-base-0.10-dev

you can enable/disable different features by passing the parameters to autogen.sh
like -> sh autogen.sh --enable-3d-transforms=yes
NOTE that if some feature is turned OFF by default and you enable it then there is no guarantee that your build will go through; that feature could be work in progress or an unstable one.

for default build options
sh autogen.sh && make

but there are times when it is not as simple as that..some of the errors you might get i will list them down and their fixes:

If you get this error while building gtk port of webkit

error: webkitmarshal.h: No such file or directory..
work around to fix this is
touch ./Source/WebKit/gtk/webkitmarshal.list

if you get an error like
ld terminated by signal 9 ..you need to increase swap space do the below:
sudo dd if=/dev/zero of=/swapfile bs=1M count=1024
sudo mkswap /swapfile
If you want to have this change after reboot as well, add below line at the end to /etc/fstab
/swapfile none swap sw 0 0

sudo swapon -a to turn on the swap space