Vershun’s Brain Dump

Archive for March, 2010

Flex Fast Compiler (FCSH frontend)

by Vershun on Mar.14, 2010, under Computers

Fast Flex Compiler (GUI frontend to FCSH with incremental compiling).

SOURCE JAR

Unzip source with 7-Zip, run jar with java -jar FastFlexCompile.jar.

So if you’ve been working on large-scale projects in Flex (especially if they’re monolithic beasts), you have undoubtably noticed how slow the compiler is in Flex Builder 3. This is because (from what I could find) Flex Builder 3 doesn’t allow incremental compilations, which drastically speeds up compiling.

FCSH, which comes with the Flex SDK, does. The problem with FCSH is it’s a pain in the ass to get setup and when you do every time you want to recompile you have to type “compile {target number},” it does not support the up arrow key for last command.

To make things a bit easier and to add highlighting, which I find useful, I made a quick Java Swing frontend to FCSH so you can enjoy quick compilation without dealing with FCSH directly.

To start: Run the app by using the command:

java -jar FlexFastCompile.jar

Put in your SDK path using forward slashes for a Windows machine, making sure to omit the trailing “/”
e.g.

C:/Development/Flex Builder 3/sdks/3.5.0

Put in your mxmlc command line arguments. If you’re unfamiliar with the switches, check out the documentation here. The common ones are: -o (output swf), -file-specs=(application file), -libarary-path+=(library path) for library directories, and -sp+=(path) for source paths.

Click “Spawn New Compiler.” This will execute FCSH and hold the session open in the tabbed window below. To recompile that instance, hit the “Recompile” button.

You can change your sdk and arguments and open up multiple FCSH sessions in the tabbed windows. Be sure to watch your memory usage as too many FCSH sessions can eat up your RAM right quick.

Developer Notes

The GUI and class skeletons was thrown together in NetBeans using Swing components.  The projects was then transferred into Eclipse because I’m more familiar with it.  There are probably still some artifacts from NetBeans in the source.

So the implementation ain’t pretty, and I’m actually passing the Swing JTextArea component down to the output reader threads directly (didn’t feel like messing with thread management much for such a quick and dirty project).  To avoid the possibility of race conditions, I’m using the JTextArea as a lock for the synchronized block that handles the highlighting (:cringe:).  If you want to customize this code for further development, that would be the first place I’d start.

To change the highlighting just edit the wordToLinePainter map in the FCSHOutputDump class. Changing the colors can be done in FCSHOutputDump by editing the DefaultHighlightPainter instantiations.

Feel free to use the code for whateverthehell you want.  There’s no license on here and no warranties as well.  I ask if you do use or modify the code shoot me an e-mail or comment (I like to know if projects are useful or not).  Thanks.

Leave a Comment :, , , more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit our friends!

A few highly recommended friends...