Binary Components In Extensions 2008.04.19 00:37

The missing piece
The missing piece ©Esther Perez

So, you've decided you need a binary component in you add-on? Great! read this. Okay, that's a little long and complicated (sorry, Matt). How about this? Ah, that does look simpler, but it doesn't work on a recent Mozilla build, you say? Fear not, I have for you:

The Binary XPCOM Component Starter Kit

The actual component is the same from Alex Sirota, so do read his page, it has a ton of useful information. My version has an updated makefile (not yet tested on windows, I plan to do that soon), and is designed to be unpacked directly into your extension. It will create a "src" directory with sample sources.

What you need:

Once you unpack the tarball into your extension, go into the src directory and run 'make sdkdir=/path/to/sdk'. If all goes well, it should build the component and place it into a platform-specific directory in your extension (did you know you can include multiple builds of a binary component, for each platform, in the same extension?).

It's pretty rough, I just spent some time on the makefile yesterday and haven't tried to make it work on Windows yet. But it's a start!

Mossop said on 2008.4.19 14:10:
Couple of minor corrections:

* The Gecko SDK is more than just [objdir]/dist/sdk so presumably you need to point to the appropriate place if you download the SDK to use.
* I presume you mean a mozilla-config.h file which is what the bug you mention is about.
dave said on 2008.4.19 20:18:
Nice idea. I've done something similar here, showing the steps in a walk-through format:

http://zenit.senecac.on.ca/wiki/index.php/Real_World_Mozilla_First_XPCOM_Component
dave said on 2008.4.19 20:19:
hrm, my link was chomped. You can get it here.
Dan said on 2008.4.20 7:18:
Hey Mossop,

I didn't know there was a difference between a downloadable SDK (assuming you could get one for 1.9) and [objdir]/dist/sdk - what's the difference?

Dave, cool! My goal was to 1) make it as easy as possible to get started, and 2) to keep my files separate from the mozilla build tree.

I don't like modifying the mozilla build tree to add a component to my extension (which I track using a separate repository).
Mossop said on 2008.4.21 11:10:
Dan, To be precise the downloadable sdk is now:

dist/bin
dist/host/bin
dist/sdk
dist/include
dist/idl
dist/lib (copied from dist/sdk/lib)

They are spat out as part of the xulrunner build: http://ftp.mozilla.org/pub/mozilla.org/xulrunner/nightly/latest-trunk/

You might be interested to look at how McCoy builds since it can now build against just the downloadable SDK: http://wiki.mozilla.org/McCoy:Building
Matthew Gertner said on 2008.4.21 15:6:
Yeah, my doc is like 3 years old. It could definitely use an overhaul! Back then the SDK wasn't really usable, for one thing.
Dan said on 2008.4.21 22:37:
Mossop, I see. Benjamin has explained a bit in the bug as well. I'll make some updates to my "kit" and make a new blog post soon.

Matt, yup! Things are easier now, for sure, though the documentation isn't all there yet.
( v 0