Flex, Ant, mxmlc and conditional compilation
- by Rezmason
My ActionScript project builds with several compile-time specified constants. They are all Booleans, and only one of them is true at any given time. The rest must be false.
When I represented my build process in a bash script, I could loop through the names of all these constants, set one of them to be true and the rest to be false, then concatenate them onto a string to be inserted as a set of arguments passed to mxmlc.
In Ant, looping is more complicated. I've tried the ant-contrib for tag:
<mxmlc file='blah' output='blah'>
<!- ... ->
<for list='${commaSeparatedListOfConstNames}' param='constName'>
<sequential>
<define>
<name>${constName}</name>
<value>${constName} == ${theTrueConst}</value>
<!--
(mxmlc's define arguments can be strings
that are evaluated at compile time)
-->
</define>
</sequential>
</for>
</mxmlc>
Long story short, ant-contrib tags like the for tag can't go in the mxmlc task. So now I'm using Ant's propertyregex to take my list of arguments and format them into a set of define args, like my old bash script:
<propertyregex property='defLine.first' override='false' input='${commaSeparatedListOfConstNames}' regexp='([^\|]+)\,' replace='\1,false ' />
<propertyregex property='defLine.final' input='${defLine.first}' regexp='(@{theTrueConst}\,)false' replace='\1true' />
<!--
result: -define+=CONST_ONE,false -define+=CONST_TWO,false -define+=TRUE_CONST,true
-->
Now my problem is, what can I do with this mxmlc argument and the mxmlc task? Apparently arg tags can go inside the mxmlc task without it throwing an error, but they don't seem to have any effect.
What am I supposed to do? How do I make this work with the mxmlc task?