Jeff Ward
Mobile, Web, Linux, and other cool Tech
find me at
Simbulus Consulting Stack Overflow Hacker Rank GitHub LinkedIn Twitter Google Plus

FCSH for ASC 2.0 Compiler

Oct 7, 2013 #Actionscript#Mobile#Linux#Windows#Mac#AIR#Compiler

If you remember how the fcsh / fcshd compiler wrappers sped up the Flex SDK compiler (or if you've noticed that the Flash Builder compiler is much faster than, say, Flash Develop), read on. Your AS3 workflow may get a performance boost from my new tools, ascsh and ascshd.

Backstory

Under the hood, Flash Builder has access to a memory-resident compiler that incrementally recompiles ActionScript 3 much faster than spinning up the compiler each time. In the old Flex SDK, Adobe delivered a tool called fcsh (flex compiler shell) that allowed command line and third party workflows (aka Flash Develop) access to this fast compilation mechanism. Some clever coders wrapped this tool in something called fcshd (fcsh daemon) that converted the awkward shell interface into a slick compiler service. And the as3 developers rejoiced.

Fast forward to present day, and the newer ASC 2.0 compiler in the AIR SDK is replacing the old Flex SDK compiler. As cool as this slick new compiler is (with bug fixes and features like inlining and advanced telemetry), it doesn't include a tool like fcsh to expose fast compilation outside Flash Builder. I'm not sure if this was an oversight, a simplification, or an effort to differentiate Flash Builder. But as you know I'm an avid command line workflow user, and I've been quite frustrated by this omission... Until now!

#IrritatedHackerEqualsProblemSolved =D

Hacking ascsh and ascshd

Looking into the ASC 2.0 compiler.jar, I noticed that the MXMLC and COMPC classes (those that compile SWFs and SWCs, respectively) have a staticMainNoExit(args) function. This is envoked when you type mxmlc on the command line. A quick wrapper around this call reveals that calling this function repeatedly (without exiting) did indeed pick up new code changes and reduce compile times significantly. Adding a simple shell interface around this (to parse arguments), ascsh was born. And just as fcshd is a socket-server wrapper around fcsh, ascshd maintains the ascsh shell in a background thread and passes compilation jobs to it.

I've open-sourced the ascsh and ascshd project on github. It includes setup and usage instructions and scripts.

The idea is that you can replace mxmlc ... in your build scripts with ascshd mxmlc ..., and the scripts maintain a background compiler process that makes your builds faster. In a simple test project and a large project, I've seen up to 4X improvement in compile times:

The tools should work under Windows*, Mac, and of course, Linux. Ideally Flash Develop users may be able to tweak their .bat scripts to use them as well, though the current implementation of ascshd may not be Windows-friendly (see below.)

Disclaimers

Ok, a couple disclaimers:

comments powered by Disqus