Build System

Using the build system to create custom extensions

Following Creating_Custom_Firefox_Extensions_with_the_Mozilla_Build_System it is possible to use the build system to put together your extensions for you. This usually works quite well but requires you to build a full project. If your extension does not have many dependancies, it may be possible to shorten the process by lengths. The extension I tested this on only contains some javascript files, and some chrome from a file.

What you need

First of all, I have only gotten this to work on trunk. If anyone finds a way to make it work on branch feel free to add here.


If you have any advanced dependancies, you may need to include more directories. You will obviously need to customize the below mozconfig.

# Options for
mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/obj-gdata

mk_add_options MOZ_CO_PROJECT="gdata"
mk_add_options AVAILABLE_PROJECTS="gdata"

# Needed to keep from complaining that toolkit/ does not exist
export LIBXUL_SDK=1

# Extra modules and files
mk_add_options MODULES_gdata="mozilla/config mozilla/build mozilla/probes mozilla/calendar/providers/gdata mozilla/calendar/locales/en-US/chrome/calendar/providers/gdata"
mk_add_options MODULES_NS_gdata="mozilla/"

# Options for 'configure' (same as command-line options).
ac_add_options --enable-application=calendar/providers/gdata
ac_add_options --disable-tests


You will need a directory containing your extension code and the build-specific files. The could look like this:

DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@

include $(DEPTH)/config/

MODULE = gdata-provider

export XPI_NAME = gdata-provider
DIST_FILES = install.rdf
XPI_PKGNAME = gdata-provider

PREF_JS_EXPORTS = $(srcdir)/defaults/preferences.js
DIRS = components

include $(topsrcdir)/config/


This file is not technically required, but you will probably want one. See the page or Creating_Custom_Firefox_Extensions_with_the_Mozilla_Build_System for more details.


I needed a file in the target directory, so that the build system is correctly instructed to build my extension. This file is quite simple and contains only the following lines:

TIERS += app
tier_app_dirs += calendar/providers/gdata

Check out and Build your extension

Now you can try to build your extension:

cvs -dย co mozilla/
MOZCONFIG=/path/to/custom/mozconfig make -f checkout
MOZCONFIG=/path/to/custom/mozconfig make -f build


If any files seem to be missing, check out the mozilla/ file and look for MODULES_core. There are a number of directories there, you could try adding them to your MODULES_gdata equivalent.