1

I need a way to programmatically record what source files are consumed in an MXMLC compile. Ideally there would be a flag to pass to MXMLC to have it report the complete list of source files it is compiling, but there doesn't seem to be such a flag. It seems generally you just pass a main.mxml file to MXMLC and it goes off and compiles everything it needs to without telling you what it's doing. As far as I can tell, you also cannot explicitly list the files for it to compile; it will resolve references automatically and compile referenced sources without any way to control that behavior or report on it.

If the compiler cannot supply this information and a user cannot control this behavior, the only other option I can think of is write my own source code scanner for MXML that will traverse all the references in a code tree to give a report of what MXMLC should be compiling, though that's obviously error prone and certainly not something I'm looking forward to.

Of course, since I don't have a whole lot of experience with Flex, there may be an obvious answer that I'm missing.

Thanks

Quinn Bailey
  • 200
  • 7

3 Answers3

7

You should find what you're after in the link report:

Add this param to your compiler arguments:

-link-report output.xml

It gives you a tonne of information, so there's also a handy AIR tool for parsing the results.

Marty Pitt
  • 28,822
  • 36
  • 122
  • 195
  • Well I feel a little silly now that I went to all that effort to code the solution myself (plus having looked over the compiler documents for hours and hours). I still kinda like my solution since it has exactly the info I need and nothing else to sort through. However, for general purposes, this really is the best answer. Thanks! – Quinn Bailey Mar 08 '11 at 02:02
0

I actually don't know of and would like to know a way to do what your saying through the command line, that would be great. But without the ability to do so I believe you could use a decompiler to examine your swf, something like Trillix I'm pretty sure will show you all the classes that have been compiled in (where they were resolved from is another story). To see what files are accessed you can (if you're using windows) use: http://technet.microsoft.com/en-us/sysinternals/bb896645 but you'll have to do some filtering to see the mxmlc process alone (it's pretty easy in there). Insofar as a direct answer I'd love to see one but these are some workarounds for now to see a bit more of whats going on under the hood. On the same topic but not necessarily related to your particular issue right now, Charles and Wireshark are good for capturing lots about what's going on with network traffic if you're having strange issues and need some good debugging tools.

I believe in the compilation of a swc you can be a bit more explicit and if you open a swc with an archive program you can look at the catalog.xml and see a list of referenced files but I'm not sure exactly how this is used in the IDE or at compile time. There's a reference to it here http://livedocs.adobe.com/flex/3/html/help.html?content=compilers_30.html but not a whole lot of depth. I wrote a small Java app to do the extraction and searching for some particular class to find how a class was ultimately getting into our code from an old sdk, definitely not fun.

Shaun

shaunhusain
  • 19,630
  • 4
  • 38
  • 51
  • I really would prefer to know/control what is being compiled at compile time, not after the fact, but thanks for the suggestions. Also, with COMPC you can explicitly list AS files to compile using the include-sources option, so you can control what's being compiled that way. Unfortunately there doesn't seem to be a comparable option for MXMLC ... – Quinn Bailey Mar 02 '11 at 23:22
  • @Quinn definitely can understand, hope you get a better answer. – shaunhusain Mar 02 '11 at 23:39
  • Okay after doing a bit more searching since this has bothered me as well I think I found the source for mxmlc that if compiled and debugged locally should be able to get to an answer about how this all works exactly and if there's possibly some way to get it to trace out the information your looking for... http://opensource.adobe.com/svn/opensource/flex/sdk/tags/4.0.0.7219_flex4_beta1/modules/compiler/src/java/flex2/tools/Mxmlc.java . I have some other work I need to do but will definitely be checking this out in the next few days. – shaunhusain Mar 03 '11 at 01:29
  • Also a good write up here http://stopcoding.wordpress.com/2008/04/19/understanding-the-flex-compiler/ that led me to search for the source of the compiler in the first place and may be able to answer your question without the need to dig through all the source. – shaunhusain Mar 03 '11 at 01:31
  • Very nice links Shaun, thank you. This is putting us on the right path I think. I'm going to fully take in that article and scan some of the code and see where that leads us. Thanks! – Quinn Bailey Mar 03 '11 at 17:44
  • After lots of digging (and a few dead ends) I think I found what I was looking for here: http://blogs.adobe.com/flexdoc/files/flexdoc/oem/oem_guide.pdf Basically, flex-compiler-oem.jar has what I was looking for. I was able to slightly modify the MyReportCompiler example on page 10 to do what I need for my simple example app. I want to do some more testing, but I think this might end up being the solution from my perspective. – Quinn Bailey Mar 04 '11 at 01:07
  • That looks pretty great I'll be checking it out more thanks for posting the link, if it works out for you maybe you can post it as an answer and mark it off since you were able to find it yourself. I'll definitely be using that resource thanks... actually after looking through it a bit I'm not sure that the report output would include the information about which swc or what source file a dependency was resolved from but the document seems informative anyhow. – shaunhusain Mar 04 '11 at 06:56
0

From everything I looked at, it seemed that the only way to capture this information at build time is to write your own java program that calls the Flex compiler classes. There are actually a few different ways to do it, but the method I went with was based on the report example starting on page 10 of the following pdf:

http://blogs.adobe.com/flexdoc/files/flexdoc/oem/oem_guide.pdf

All I was interested in knowing was the file dependencies for the build, so that I could link these to source versions in version control. For that I reason, I left out the Definitions, Dependencies, and Prerequisites sections of the referenced example. The basic idea is to construct a flex2.tools.oem.Application object, run the "build" method on it, and then use the getReport method to get all the gory details of the compilation. Here is a simplified version of what my solution code looked like:

File file = new File ("C:/MyFlexApp/main.mxml");
File outputFile = new File("C:/MyFlexApp/bin/Foo.swf");
Application application = new Application(file);
application.setOutput(outputFile);            

Configuration config = application.getDefaultConfiguration();
File[] libFile = new File[] {new File("C:/MyFlexApp/bin/baz.swc")};
config.addLibraryPath(libFile);

application.setConfiguration(config);
application.build(true);              

report = application.getReport();


Message[] m = report.getMessages();  
if (m != null)
{
    for (int i=0; i<m.length; i++) 
    {
        System.out.println(m[i].getLevel().toUpperCase() + 
                " MESSAGE " + i + ": " + m[i]);
    }
}
// Lists the image files that are embedded.
System.out.println("\n\nEMBEDDED ASSETS: ");
String[] assetnames = report.getAssetNames(Report.COMPILER);
if (assetnames != null)
{
    for (int i=0; i<assetnames.length; i++) 
    {
        System.out.println(assetnames[i]);         
    }     
}

// Lists the libraries that are used.
System.out.println("\nLIBRARIES: ");
String[] compilerLibs = report.getLibraryNames(Report.COMPILER);
if (compilerLibs != null)
{
    for (int i=0; i<compilerLibs.length; i++) 
    {
        System.out.println(compilerLibs[i]);         
    }     
}
System.out.println("\nSOURCE NAMES: "); 
String[] src = report.getSourceNames(Report.COMPILER);
if (src != null)
{
    for (int i=0; i<src.length; i++) {
        // Lists source files.
        System.out.println(src[i]);     
    }
}

Thanks to Shaun for all the help that led me to this solution.

Quinn Bailey
  • 200
  • 7