views:

470

answers:

2

Hi,

I'm trying to compile an SWC file from a list of given ActionScript classes. I'm using the compc compiler. The problem is that there are so many classes grouped into multiple namespaces that I am finding it very tedious to specify each individual class to be included in the SWC. Is there any easier way of doing this like just simply specifying a root directory of these classes?

At the moment I have something like this:

<?xml version="1.0"?>
<flex-config xmlns="http://www.adobe.com/2006/flex-config"&gt;
  <output>C:\SomeFolder\testSWC.swc</output>
  <compiler>
    <source-path>.</source-path>
  </compiler>
  <include-classes>
    <class>SomeNamespaceOne.One</class>
    <class>SomeNamespaceOne.Two</class>
    <class>SomeNamespaceOne.Three</class>
    <class>SomeNamespaceOne.Four</class>
    ...
    <class>SomeNamespaceFifty.One</class>
  </include-classes>
</flex-config>

But I want something like this:

<?xml version="1.0"?>
<flex-config xmlns="http://www.adobe.com/2006/flex-config"&gt;
  <output>C:\SomeFolder\testSWC.swc</output>
  <compiler>
    <source-path>. </source-path>
  </compiler>
  <include-classes>
    <class>SomeRootDirectoryOfClassesToCompile</class>
  </include-classes>
</flex-config>

Is this possible?

A: 

We wanted something similar, in "Ant".

I am assuming you are not using Flex Builder. In that case, I will definitely recommend using Ant and Flex Ant tasks available from Adobe. Even when you use Ant, its not easy doing what you want to do, so I am including our code below.

Following is our code. I don't remember where I got the idea from, so cannot thank the source for it :)

     <pathconvert property="XXX.classes" pathsep=" ">

  <fileset dir="${basedir}/XXX/src">
   <include name="**/*.as"/>
   <include name="**/*.mxml"/>
  </fileset>

  <compositemapper>
   <packagemapper from="${basedir}\XXX\src\*.as" to="*"/>
   <packagemapper from="${basedir}/XXX/src/*.as" to="*"/>
   <packagemapper from="${basedir}\XXX\src\*.mxml" to="*"/>
   <packagemapper from="${basedir}/XXX/src/*.mxml" to="*"/>
  </compositemapper>

 </pathconvert>

 <compc optimize="true" debug="false"
 include-classes="${XXX.classes}" output="${BUILD_FOLDER}/XXX.swc">
            </compc>
Tanmay
I would have tried this but too bad that I'm using MSBuild for this...sigh :(
Draco
A: 

Like Tanmay said, you should use the ANT tasks to make life easier, but there's an even simpler wach include an entire directory in the compc ant task. If you just need to include everything in src.dir you can do it like this:

<compc output="${target.dir}/foo.swc">
     <source-path path-element="${src.dir}"/>
     <include-sources dir="${src.dir}">
          <include name="**/*" />
     </include-sources>
</compc>
dan