Prebop Preprocessor

Preprocessing Prebop style

Prebop is not your father's preprocessor. In fact, you may not even think it's a preprocessor! Call it a "version configurer".

Instead of running every time you compile a file, like the C/C++ preprocessor, Prebop runs only when you tell it to.

Instead of creating an invisible intermediate file, Prebop writes a real file to the file system.

What's it for?

The primary use of Prebop is to maintain multiple versions of software from one source code base.

You can use a source code control system like CVS and accomplish the same objective with branch and merge, but what a collosal PITA! When your versions are multi-dimensional, e.g., your application runs on different versions of a framework and, in addition, has multiple versions (a trial version, a "pro" version, an "enterprise" version, etc.), plus for each of these there are released versions and beta versions, most source control systems are way cumbersome.

On the other hand, many Java programmers are only too happy to be free of the C/C++ preprocessor, with its cryptic syntax and hard to understand conditional expansion. If you've ever wasted time trying to figure out the effect of a half-dozen levels of nested #IFDEFs, you know what I mean.

A better idea

Instantiations had a better idea! Using their CodePro preprocessor as a design point, we rewrote it from scratch as an open source project. Here's the idea:

  1. Wrap the preprocessor if/else/endif statements in ordinary programming language comments, so the source is always compilable.
  2. Run a program (like Prebop) over the source and have it move the comment brackets around, based on conditions you define.
  3. Define an Ant task for the program (like the Prebop preprocess Ant task, so the preprocessor can be run as part of build scripts.
  4. Write an Eclipse plug-in so the Ant task is defined when you run Ant from inside Eclipse, allowing you to quickly change versions of the code for testing.


Here's an example to give the flavor:

  /* $if version < 1.0.0$ */
  /* $endif$ */

This is how the source looks before Prebop is run on it, or if the value of the version preprocessor variable (which you define) is, say, 0.9.0. Alternatively,

  /* $if version < 1.0.0$
  $endif$ */

The second example is how the source looks after Prebop is run on it, if the value of the version preprocessor variable is, say, 1.0.0.

That's all there is to it!

Note that your programming editor makes it easy to see what the effect of the preprocessor is, because only included lines are colored as source code, while all preprocessor statements and excluded lines are colored as comments.

Eclipse plug-in

You can install Prebop in the usual way to use it from standalone Ant. The preprocessor.jar file from the distribution is all you need.

But Eclipse users have it easier. All you need to do is install the plug-in in the usual way and the preprocess Ant task will be defined for any Ant projects launched from within Eclipse.

Where to go

The project page lets you download a zip containing the Eclipse plug-in, including the preprocessor.jar file.

The documentation tells you how to use the preprocess task. This is also available through Eclipse Help, after the plug-in is installed.