Flex Conditional Compilation Tweak
A little tweak to help make compilation more straightforward. 2009-03-13
One of the more interesting Flex compiler features is conditional compilation. This has been a real boon for us in development on a larger project because we're using it to conditionally include fake testing data in an offline mode, or to use online services. The docs talk about using 'debugging' and 'release' variables to conditionally include things. The code they give looks like this:
<compiler>
<define>
<name>CONFIG::debugging</name>
<value>true</value>
</define>
<define>
<name>CONFIG::release</name>
<value>false</value>
</define>
</compiler>
But why would I want to update two variables for something that is mutually exclusive? In my use case I want to include one thing, and if that's false, include the other thing. More importantly I don't want to introduce errors into the system. Conditional compilation only includes when something is true. BUT I've found a good workaround:
<compiler>
<define>
<name>CONFIG::debugging</name>
<value>true</value>
</define>
<define>
<name>CONFIG::release</name>
<value>!CONFIG::debugging</value>
</define>
</compiler>
And then you can do something similar to what they have in the docs:
package default{
CONFIG::debugging
public class MyClass{
...
}
CONFIG::release
public class MyClass{
...
}
}
|