as3 conditional compiling with flascc

375 Views Asked by At

I had as3 project with custom flex-config.xml and conditional compiling directives for mxmlc like this:

<define append="true">
  <name>CONFIG::DEBUG</name>
  <value>true</value>
</define>
<define append="true">
  <name>CONFIG::RELEASE</name>
  <value>false</value>
</define>

How I can to do that with flascc g++?

1

There are 1 best solutions below

1
On

The docs for FlasCC's gcc says

-fllvm-llc-opt= Pass an argument through to the final invocation of llc (LLVM-IR->ABC codegen).

while running $FLASCC_HOME/usr/bin/llc --help shows

-ascopt=<asc options> - Extra options to pass to ASC when compiling ActionScript

Finally, running java -jar $FLASCC_HOME/sdk/usr/lib/asc2.jar shows that one of the arguments it takes is

[-config <ns::name=value>]

So it seems like we should be able to do this:

gcc ... -fllvm-llc-opt="-ascopt=-config CONFIG::RELEASE=true"

Unfortunately, while the flag does actually make it to asc.jar (!), it appears to be getting passed as one argument (rather than two), so it errors out. The space required by -config is screwing things up.

The workaround is to pass the two pieces of the arg separately:

gcc ... -fllvm-llc-opt=-ascopt=-config -fllvm-llc-opt=-ascopt=CONFIG::RELEASE=true