Hunting the Shmoo

Screencasts and blog posts on workflow, productivity, tools, Mozilla and whatever else tickles my fancy.

An Easier way to Manage Mozconfigs

Mozconfigwrapper is a tool inspired by Doug Hellman’s magnificent virtualenvwrapper. In a nutshell, mozconfigwrapper hides all of your mozconfigs into a configurable directory (defaults to ~/.mozconfigs), and lets you easily switch, create, remove, edit and list them. Mozconfigwrapper is Unix only for now.

Mozconfigwrapper is brand new. I still need to add some better error checking and do testing on OSX. So if you have any problems installing or using it, please let me know or file an issue.

Installation

To install first make sure you have pip. Then run the command

sudo pip install mozconfigwrapper

Next open up your ~/.bashrc file and add the line

source /usr/local/bin/mozconfigwrapper.sh

Note that it may have been installed to a different location on your system. You can use the command ‘which mozconfigwrapper.sh’ to find it.

Finally run the command

source ~/.bashrc

Mozconfigwrapper is now installed.

Usage

Mozconfigwrapper allows you to create, remove, switch, list and edit mozconfigs.

To build with (activate) a mozconfig named foo, run:

buildwith foo

To create a mozconfig named foo, run:

mkmozconfig foo

To delete a mozconfig named foo, run:

rmmozconfig foo

To see the currently active mozconfig, run:

mozconfig

To list all mozconfigs, run:

mozconfig -l

To edit the currently active mozconfig, run (the $EDITOR variable must be set):

mozconfig -e

Configuration

By default mozconfigs are stored in the ~/.mozconfigs directory, but you can override this by setting the $BUILDWITH_HOME environment variable. e.g, add:

export BUILDWITH_HOME=~/my/custom/mozconfig/path 

to your ~/.bashrc file.

When you make a new mozconfig, it will be populated with some basic build commands and the name of the mozconfig will be appended to the end of the OBJDIR instruction. You can modify what gets populated by default by editing the ~/.mozconfigs/.template file. For example, if I wanted my default configuration to store object directories in a folder called objdirs and enable debugging and tests, I’d edit the ~/.mozconfigs/.template file to look like:

mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/objdirs/
ac_add_options --enable-application=browser
ac_add_options --enable-debug
ac_add_options --enable-tests

Now if I ran the command ‘mkmozconfig foo’, foo would be populated with the above and have the word ‘foo’ appended to the first line.


Share