Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WebKit JS bindings: step by step how to

I have to admit I'm new to WebKit so asking the right question is not that easy.

What I have is the WebKit from WebKit.org. It updates, builds, I can debug - I got it working on Windows.

What I'm interested in is how to generate the stub files for some IDL files that I have. I understand the high level picture:

  1. Write the interfaces using the IDL language
  2. Generate stub files (.h & .cpp files).
  3. Add your code in the previously generated stub files.

I've specified my IDL files in "WebCore.gypi". I've specified then the path to my IDL files in "WebCore.gyp". Apparently this is not enough as building the WebKit doesn't generate the stub files for my IDL files.

I've suspected at one point that maybe my IDL files contain undefined attributes but everything seems fine.

Any tips? Also, do you know of any explicit "How to"?

Thanks!

Edit 130206:

I dug some more and apparently WebKit interacts with several build systems; for example GYP is for Chromium. I honestly didn't expect that complication so I didn't mention I needed to generate binding for Safari which has a different build system and as such its own unique "how to". So, the question would now be, how does the Safari build system work? Where do I need to place my IDL files? Thanks!

like image 308
takanokage Avatar asked Jan 31 '13 13:01

takanokage


1 Answers

Well, I can tell you what helped me. Unfortunately I still couldn't find any documentation so a lot of trial and error was involved.

If you want to generate JS bindings for Safari you have to:

  1. Modify 'DerivedSources.make'.
  2. Make sure your IDL files are correct.

'DerivedSources.make' can be found in '\WebKit\Source\WebCore\'. Inside this make file you have to specify the following:

  1. The path to your folder (containing the IDL files) in 'VPATH'.
  2. Each and all of your IDL files in 'BINDINGS_IDLS'.
  3. Again the path to your folder in 'IDL_INCLUDES'.

Build WebKit. If after this step you still can't see your JSXXX.h and JSXXX.cpp files (genererated for each XXX.IDL file) than you have to check your IDL files.

In my case nothing was generated after the build step and I got an error like this:

6>Next token should be implements, but MyModule at module MyModule {
6> IDLParser.pm:750 at /WebKit/Source/WebCore/bindings/scripts//IDLParser.pm line 129.
6> in /WebKit/Source/WebCore/MyFolder/XXX.idl at /WebKit/Source/WebCore/bindings/scripts//IDLParser.pm line 173.
6>/WebKit/Source/WebCore/DerivedSources.make:1024: recipe for target `XXX.h' failed
6>make: * [XXX.h] Error 255

The problem was that each of the IDL interfaces where enclosed in a module (namespace) called MyModule as you can see above. I've removed all this modules (keeping the interfaces of course) and at the next build everything was generated just fine. Using your own module name seems to not be as straight-forward as enclosing the IDL interfaces with it; most probably you'd be forced to write custom bindings to accomplish this (which is not recommended by the WebKit team).

So that was it for me, hope it's also helpful to you.

like image 91
takanokage Avatar answered Oct 12 '22 02:10

takanokage