A useful compiler switch to help with this is the -dump-config switch.

If you add -dump-config=c:\mycfg.xml to the compiler, it will generate a config file that represents all the compiler (either for mxmlc or compc) settings used for compilation in a Flex Builder compile and then you can use that config file in a commandline compile to do an equivalent compile.

A few notes on the generated configfile.

1. The file is not perfect. I found that the tag that was generated only had a relative path generated. It is much better if that were absolute, so before I used the config file, I changed the value for that tag to something like:

<manifest>C:\FlexBuilder2.0.1\Flex SDK 2\frameworks\mxml-manifest.xml</manifest>
 

2. For some reason the generated file has a token ${flexlib} which didn’t get resolved and filled in. I found that I could just comment out the 2 properties in the config file as they aren’t relevant to most compilations.

3. I found the easiest way to use mxmlc/compc was to copy the generated config file to the bin dir of the SDK under Flex Builder install. Then I could invoke mxmlc against the app like so:

./mxmlc -load-config+=mycfg.xml C:/myapp/src/app.mxml -output myswf.swf

4. For compc, the classes to actually compile to include in the generated swc aren’t actually output to the generated config file, so you have to add them manually (or on the commandline). I found the easiest way to do this was to add tags like below in the generated configfile

   <include-classes>
    <class>fooClass</class>
    <class>barClass</class>
  </include-classes>
 

The content for those tags comes from the project file – .flexLibProperties which looks something like this:

<?xml version="1.0" encoding="UTF-8"?>
<flexLibProperties version="1">
  <includeClasses>
    <classEntry path="fooClass"/>
    <classEntry path="barClass"/>
  </includeClasses>
  <includeResources/>
  <namespaceManifests/>
</flexLibProperties>
 

The classEntry paths translate into the class tag values.
After doing this you can run compc like this:

./compc -load-config+=mycfg.xml -output myswc.swc

HTH

-Kyle

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Slashdot
  • StumbleUpon
  • Technorati
  • TwitThis



No Comments »