« Apollo on Techcrunch | Main | Personal Channels on Brightcove »

Speeding Up Builds with the Flex Compiler Shell

Two Flex projects were recently released on Adobe Labs, Flex Ant Tasks and Flex Compiler Shell. You would expect the Ant tasks to be the more exciting of the two from the build perspective, but the compiler shell (fcsh) could be the better choice for large, complicated projects. That's because fcsh allows multiple compilations to occur in one process without the need for reloading SWCs, restarting Java, etc. When you can use fcsh in a non-interactive manner, this can be very helpful for speeding up a build.

How can you use fcsh, which is supposed to be an interactive shell, in a build file? Simple piping of a file will do the trick. As an example, put the following in a file named "buildscript":

mxmlc -library-path+=frameworks/locale/{locale} -source-path+=samples/photoviewer/locale/{locale} -locale=en_US samples/photoviewer/PhotoViewer.mxml
mxmlc samples/restaurant/recentReviews.mxml
mxmlc samples/restaurant/finder.mxml
mxmlc samples/explorer/explorer.mxml
mxmlc samples/flexstore/flexstore.mxml

Then call the following:

bin\fcsh < buildscript

In Ant, you'd use the input attribute instead of "< buildscript".

I see a roughly 50% increase in the compilation speed from this example. But there's two problems with using fcsh:

1. Status codes are not returned correctly. Hopefully Adobe can fix this, but in the meantime, you'll need to search the output yourself for "Error".
2. You don't get the wildcard fileset benefits of the new Ant tasks.

Comments (2)

One thing I realized after writing this that the Ant tasks may take care of this speedup as well. It's possible that the Ant tasks could also keep the SWCs loaded between calls. They didn't do this when I saw them at Adobe, but things could've changed.

That would be great if the ant tasks sped things up. I was kind of disappointed to see that the ant tasks didn't use fcsh.