Last month at FISL 9 I met again with my good friend Henri Bergius, and he told me about Midgard news and showed me some changes on version 2 of Midgard Core. Midgard Core is a glib based library that could be used to persist glib objects on databases. Since it uses the GLib object model it is very easy to create binding for Mono, and that's what we did it at FISL days.
That was not the first time that I created Mono bindings for GLib libraries, I had done it before for Maemo libraries, and this weekend again for WebKit, but at this time I decide to create a project skeleton so everybody that is interested in creating Mono binding for Glib based libraries could use this skeleton for easy bindings creation.
The steps below describe how I easily created WebKit bindings without typing any lines of C# code.
First, download the skeleton file, unpack it and rename it to "webkit-sharp":
# wget http://anonsvn.mono-project.com/viewcvs/trunk/monoskel-gapi.tar.gz
# tar -xzf monoskel-gapi.tar.gz
# mv monoskel-gapi webkit-sharp
Now, go into this new directory and run the script that will perform the magic:
# cd webkit-sharp
# chmod +x autogen.sh skel-create.sh
# ./skel-create.sh webkit-sharp
We now have our source tree ready with autotools and makefiles. In the next step we must tell gapi where the C header files of the library that we want to make bindings for are. Open sources/webkit-sharp-sources.xml with your preferred text editor and type the following content:
Here, the important information is "WebKit" that will be used as our namespace and "dir" that indicates the directory where our header (.h) files are.
And that is all, no changes needed anymore, you just need to run "make api" on the sources directory every time you change "webkit-sharp-sources.xml".
# cd sources
# make api
You can now follow the normal procedure to compile and install the linux package. On the package root directory, just type:
# make install
If you are a developer, it should be easy to understand and create more samples in "samples" dir. There are also some "Package settings" that can be changed on top of "configure.in".
I did some other changes in my webkit-sharp like creation of webbrowser sample and checking for installed WebKit in configure.in. On my next post I will show webkit-sharp in action.
More information about GAPI could be found here.