IDL pre-processing

IDL pre-processor Perl script and a text/plain version.

Following up on my previous post, here is evil, nefarious scheme number 692. Sample .mozconfig:

. /cygdrive/m/configs/sm-debug.mozconfig
ac_add_options --disable-mailnews
ac_add_options --disable-composer
mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/../nav-sm-debug
OBJDIR_CONFIG=${topsrcdir}/../nav-sm-debug/config
mkdir -p ${OBJDIR_CONFIG}
echo "
export:: idl-preprocess
idl-preprocess::
\$(PERL) /cygdrive/m/idl-preprocess.pl \$(XULPPFLAGS) \$(DEFINES) \$(ACDEFINES) --srcdir=\$(srcdir)
.PHONY: idl-preprocess
" > ${OBJDIR_CONFIG}/myconfig.mk
echo ${OBJDIR_CONFIG}/myconfig.mk
cat ${OBJDIR_CONFIG}/myconfig.mk

This allows me to take a foo.idl.in file and create a foo.idl file from it. Two known bugs in it: foo.idl must exist before you call it via the Makefile rule above, and you really can’t risk compiling more than one build at a time over the directory foo.idl.in must live in (lest conflicting #ifdef macros take effect).

Why, you might ask, would anyone in their right mind want to preprocess IDL? One of the big goals of IDL is to make sure your interfaces are clearly defined, and preprocessing clutters it up.

I answer: because I want to preprocess C++ and chrome files using the same flags. But I want to do it locally only, in my development tree.

Basically, I’m combining a lot of ongoing work into a “supertrunk” tree (evil, nefarious scheme number 691), which I’ll use to develop a lot of Web Forms 2 code concurrently. When I’m ready to create a patch, I’ll make a complete copy of this tree and use preprocessing (of IDL, C++ and chrome) on the copy to get rid of the code that isn’t relevant to that patch.

This also allows me to develop code which depends on other code which awaits reviews. In other words, I only create a new tree when I absolutely have to. Plus, conflicts when I update (after a checkin) become somewhat more manageable.

Note that I don’t recommend this script be checked into mozilla.org’s repository. One of the big reasons I wrote this IDL preprocessor was to avoid mixing up UUID’s for each change to the interface. Consider:

#switchdef
#casedef FOO
[scriptable, uuid(e78e4889-d21d-442b-b89f-ab757f40458d)]
#casebreak
#default
[scriptable, uuid(6438d086-68a4-4938-a781-b88f674f3eb1)]
#casebreak
#endswitchdef

There’s no way in the world I’d want to see that in a patch for mozilla.org code. I use the switchdef structure so that when I go from one patch to another, I’ll ultimately get a different UUID for each patch to the same IDL file – which is perfectly reasonable. But I don’t see any reason to have code like this ifdef’d in mozilla.org’s repository. This is just to help me out on my local tree.