Simple Actionscript Preprocessor

I was looking for a ’simple’ C preprocessor for actionscript. The best thing out there which is out of the box compatible with actionscript is “EnLarge” from Asual.

But even EnLarge is to complicated for me! I don’t want to make an ant build for every little thing I do. All I want is a preprocessor that takes an input folder and processes every single file to a specified output folder. So I took a peek on google and found “GPP“, which is a general-purpose preprocessor ‘almost’ perfect for my needs. Yes, ‘almost’ perfect because it’s missing some of my fundamental needs to process a folder for ex. So after some small modifications I’ve recompiled GPP to fit my needs. Download my binaries here, and get my patches for GPP 2.24 here.

GPP now supports the following syntax:
gpp.exe –source .\src_p –dest .\src –nocurinc –stdinclude .\macros

We’re using this in FlashDevelop using a shortcut key (F11) within the FlashDevelop menu, if you want this as well then copy gpp.exe to your FlashDevelop tools folder and modify MainMenu.xml with the following:

<button label="Preprocess src_p" click="RunProcess" shortcut="F11" tag="$(Quote)$(BaseDir)\Tools\gpp\gpp.exe$(Quote);--source $(Quote)$(ProjectDir)\src_p$(Quote) --dest $(Quote)$(ProjectDir)\src$(Quote) --nocurinc --stdinclude $(Quote)$(BaseDir)\Tools\gpp$(Quote)" />

Comments

8 Responses to “Simple Actionscript Preprocessor”

  1. Adam on March 22nd, 2008 05:20

    Hey do you have any documentation for this? Can you at least provide a few samples of how to use it in actionscript? Thanks!

  2. Sander Wichers on March 27th, 2008 15:31

    Adam, sorry no personal documentation. But there is a whole lot to read on the GPP website though:
    http://en.nothingisreal.com/wiki/GPP

  3. zwetan on September 27th, 2008 20:11

    you do know that mxmlc have conditionnal compilation
    do you :) ?

    http://livedocs.adobe.com/flex/3/html/help.html?content=compilers_21.html

  4. Sander Wichers on September 27th, 2008 20:18

    :) no I did not. I do know that Flash CS4 now has preprocessor support, which is excellent as well.

    Thanks!

  5. Evildave on October 24th, 2008 02:09

    Being a C-head, I think I’ll stick with my own ‘Preprocessor in Flash’ solutions. The problem with ‘GPP’ is there are no Windows builds for it, and I have Windows-using clients who will get upset if they can’t build it themselves (and I’m not going to be the one to bother porting it).

    The problem with the Adobe ‘conditional compilation’ is, it sucks.

    No macros. No token pasting.

    Nothing I’ve seen so far is anything like a replacement for running code through a straight-text GNU C preprocessor (and it DOES support unicode).

  6. makc on March 17th, 2009 12:30

    Evildave, there is a windows build, in this very blog post you were replying to :)

    Sander Whichers, this is great. How come I only found it now :(

  7. mlueft on March 31st, 2009 10:39

    Hi!

    when processdir is called ecursively, the include file is ignored.

    In my project I have an “includes” folder. In this folder I have ass actionscript files which get included into timelines.

    I use this gpp call:
    “C:\Programme\FlashDevelop\Tools\gpp\gpp.exe” –source “P:\AS2\bowlingLueftenegger\srcincludes” –dest “P:\AS2\bowlingLueftenegger\includes” –include “P:\AS2\bowlingLueftenegger\macro\macros.txt”

    in the includes folder there are sub folders. and the macros defined in macros.txt are not available for files in these sub folders.

    I need this feature. Would be really cool, if somebody could fix this and send me a note at mlueft at sbg dot at.

    sorry for asking for it, but i am not able to do it myself.

    regards,

    Michael

  8. Harold on July 18th, 2009 02:44

    Oh..this is beautiful.

    Thanks, exactly what I needed. I’ve been using flex preprocessor directives, but I needed more power, and this is perfect.

    Thanks for the share!

Leave a Reply