How to determine what files MXMLC compiles

泪湿孤枕 提交于 2019-12-23 02:25:08

问题


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


回答1:


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.




回答2:


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




回答3:


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.



来源:https://stackoverflow.com/questions/5174162/how-to-determine-what-files-mxmlc-compiles

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!