Build System

by 1 contributor:

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 jar.mn 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.

mozconfig

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

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

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

# Needed to keep allmakefiles.sh 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

mozilla/path/to/myExtension/Makefile.in

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

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

include $(DEPTH)/config/autoconf.mk

MODULE = gdata-provider

export USE_EXTENSION_MANIFEST = 1
export XPI_NAME = gdata-provider
DIST_FILES = install.rdf
XPI_PKGNAME = gdata-provider
DEFINES += -DAB_CD=$(AB_CD)
STRIP_XPI = 1

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

include $(topsrcdir)/config/rules.mk

mozilla/path/to/myExtension/jar.mn

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

mozilla/path/to/myExtension/build.mk

I needed a build.mk 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 :pserver:anonymous:anonymous@cvs-mirror.mozilla.org:/cvsroot co mozilla/client.mk
MOZCONFIG=/path/to/custom/mozconfig make -f client.mk checkout
MOZCONFIG=/path/to/custom/mozconfig make -f client.mk build


Troubleshooting

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

Document Tags and Contributors

Contributors to this page: XFallenAngel
Last updated by: XFallenAngel,