I figured I'd share a few bash
functions that I find
useful for Mozilla development. There are only a handful of people in
the world who care about this stuff, and this entry is for them. The
rest of you can feel free to ignore it.
For a start, there's this one that's useful when I need to revise the
IID of “interfaces” that aren't defined in IDL:
uuidgen-c++()
{
local UUID=$(uuidgen)
echo "// $UUID"
echo "#define NS__IID \\"
echo "{ 0x${UUID:0:8}, 0x${UUID:9:4}, 0x${UUID:14:4}, \\"
echo -n " { 0x${UUID:19:2}, 0x${UUID:21:2}, 0x${UUID:24:2}, "
echo -n "0x${UUID:26:2}, 0x${UUID:28:2}, 0x${UUID:30:2}, "
echo "0x${UUID:32:2}, 0x${UUID:34:2} } }"
}
It saves the manual typing involved in splitting up a generated
IID.
But the more interesting one is the way I deal with my many
mozconfig
files. First of all, I have them all in a directory,
~/mozilla/mozconfig/
. But then I have the following bash
function to switch between them:
moz()
{
local FILE=~/mozilla/mozconfig/$1
if [ ! -f $FILE ]
then
echo "Error: $FILE does not exist." 1>&2
return 1
fi
export MOZCONFIG=$FILE
if [ -d ../obj -a ! -d ../obj/$1 ]
then
echo "Warning: Will create new objdir" 1>&2
fi
}
My ~/.bashrc
file contains a call to this function too,
moz firefox-debugopt
, so that my MOZCONFIG
environment variable is never unset, so I can't accidentally do a srcdir
build (horrors, never mind the damage to that source tree).
Since many of my build options are in common, I have the various
files include other files. For example, my
~/mozilla/mozconfig/firefox-debug
contains the lines:
. $(dirname $MOZCONFIG)/common
. $(dirname $MOZCONFIG)/common-debug
. $(dirname $MOZCONFIG)/common-gtk2+xft
which allow sharing of common bits of configuration. This part
didn't have to depend on the fact that I'm always using mozconfigs via
the MOZCONFIG
environment variable to allow my
MOZCONFIG
files. However, the next bit does. The trick I
use in ~/mozilla/mozconfig/common
to ensure that I never
accidentally create a MOZCONFIG
file that will build in the
wrong object directory is this:
mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/../obj/$(basename $MOZCONFIG)/
which ensures that whenever I do a build with one of my mozconfig
files, it will always end up in an object directory based on the
name of that mozconfig file.
This way of dealing with mozconfig files has made it a lot easier for
me to deal with the combination of multiple source trees and multiple
build configurations for each tree.
Last Saturday I went up to San Francisco and did a little hiking.
Believe it or not, there are some worthwhile places to hike within city
limits (I'm a big fan of both Golden Gate Park and Lincoln Park). I
took some photographs of the Golden Gate Bridge from Lincoln Park,
including this one, which is a view of the bridge from the
ocean side: