Finally, after much trial and error, I have something approaching a usable development environment for a firefox extension. It’s based around roachfiend’s helloworld tutorial.
- Set up a separate development profile in firefox that you can play around with. The article Setting up extension development environment is a good source for this. I also found this in my
~/.zshrc
useful:alias firefoxdev="MOZ_NO_REMOTE=1 firefox -p dev -console"
- Download roachfiend’s helloworld extension. Extract it into a directory called
helloworld
. - Inside the helloworld directory, remove the
install.js
file. It’s only used by older mozilla’s and we don’t care about it. - Inside
helloworld/chrome
, create a newhelloworld
directory and extract the contents ofhelloworld.jar
into it. Then removehelloworld.jar
. - Edit the
install.rdf
so thaturn:mozilla:extension:file:helloworld
no longer has a ”.jar” on the end. - Now we’re ready to import this lot into subversion:
% cd helloworld % svn import $SVNROOT/helloworld/trunk/src
- The extension needs to be built and imported into firefox once.
% zip -9r ../helloworld.xpi *
- Start firefox (in your development profile), do File / Open / helloworld.xpi and install. Then quit firefox.
- Change into the development profile directory (I chose ~/work/mozdev to make it easy to find. Then replace the installed extension with the one checked out of subversion.
% cd ~/work/mozdev % cd extensions % uuid="{9AA46F4F-4DC7-4c06-97AF-5035170633FE}" % mv $uuid $uuid.old % svn co $SVNROOT/helloworld/trunk/src $uuid % mv $uuid.old/uninstall $uuid
Of course, this will differ if you have a different UUID (in which case don’t forget to update
install.rdf
!). - You probably want to set a property to ignore that uninstall directory:
% svn propset svn:ignore uninstall $uuid % svn commit -m 'Ignore uninstall.'
- Start firefox and check that the extension still works.
- You might want to create a symbolic link to get into the directory easily.
% cd % ln -s ~/work/mozdev/extensions/$uuid helloworld
At this point, you have a version of firefox, with access to a full expanded extension, which you can start developing in. Also the extension is inside subversion, so you can keep track of things sensibly. You’ll note that I imported the extension into a directory called “src”—that’s so that I can put a build script and other stuff above it, in case I ever actually get as far as releasing something.
The steps for cvs instead of subversion should be pretty similiar.
Two very good sources of documentation are: mozillazine knowledgebase: Extension development and devmo: Extensions. It seems like they held all the pieces I needed to pull this together even though I wasn’t coherent enough to spot it.