mozconfig Files

mozconfig files are used to configure how a build works.

mozconfig files are actually shell scripts. They are executed in a special context with specific variables and functions exposed to them.



The following special functions are available to a mozconfig script.


This function is used to declare extra options/arguments to pass into configure.


ac_add_options --disable-tests
ac_add_options --enable-optimize


This function is used to inject statements into for execution. It is typically used to define variables, notably the object directory.


mk_add_options AUTOCLOBBER=1

Special mk_add_options Variables

For historical reasons, the method for communicating certain well-defined variables is via mk_add_options(). In this section, we document what those special variables are.


This variable is used to define the object directory for the current build.

Finding the active mozconfig

Multiple mozconfig files can exist to provide different configuration options for different tasks. The rules for finding the active mozconfig are defined in the mozbuild.mozconfig.MozconfigLoader.find_mozconfig() method:

class mozbuild.mozconfig.MozconfigLoader(topsrcdir)

Handles loading and parsing of mozconfig files.

find_mozconfig(env={'TASKCLUSTER_PORT_80_TCP_ADDR': '', 'TASKCLUSTER_INSTANCE_TYPE': 'm3.xlarge', 'TASKCLUSTER_WORKER_TYPE': 'gecko-t-linux-xlarge', 'MOZ_AUTOMATION': '1', 'LOGNAME': 'worker', 'USER': 'worker', 'HOME': '/builds/worker', 'PATH': '/builds/worker/checkouts/gecko/obj-x86_64-pc-linux-gnu/docs/html/main/_venv/bin:/builds/worker/checkouts/gecko/obj-x86_64-pc-linux-gnu/_virtualenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', 'LANG': 'en_US.UTF-8', 'TERM': 'xterm', 'SHELL': '/bin/bash', 'RUN_ID': '0', 'SHLVL': '1', 'TASKCLUSTER_PORT': 'tcp://', 'TASKCLUSTER_NAME': '/elegant_jepsen/taskcluster', 'GECKO_HEAD_REPOSITORY': '', 'SCCACHE_DISABLE': '1', 'TASKCLUSTER_PORT_80_TCP_PORT': '80', 'GECKO_HEAD_REV': 'b6bed1b710c3e22cab49f22f1b5f44d80286bcb9', 'MOZ_SCM_LEVEL': '3', 'GECKO_BASE_REPOSITORY': '', 'LC_ALL': 'en_US.UTF-8', '_': './mach', 'TASKCLUSTER_PORT_80_TCP_PROTO': 'tcp', 'TASK_ID': 'bX_mo03cRZqv63csmtVd9A', 'TASKCLUSTER_PORT_80_TCP': 'tcp://', 'OLDPWD': '/', 'HOSTNAME': 'taskcluster-worker', 'HG_STORE_PATH': '/builds/worker/checkouts/hg-store', 'PWD': '/builds/worker/checkouts/gecko', 'TASKCLUSTER_WORKER_GROUP': 'us-west-1', 'TASKCLUSTER_PUBLIC_IP': ''})

Find the active mozconfig file for the current environment.

This emulates the logic in mozconfig-find.

  1. If ENV[MOZCONFIG] is set, use that
  2. If $TOPSRCDIR/mozconfig or $TOPSRCDIR/.mozconfig exists, use it.
  3. If both exist or if there are legacy locations detected, error out.

The absolute path to the found mozconfig will be returned on success. None will be returned if no mozconfig could be found. A MozconfigFindException will be raised if there is a bad state, including conditions from #3 above.