AARON SMITH’S CODE ENDEAVOR

Removing Classes from MXMLC Link Reports

I started creating swcs for guttershark and ran into an annoying problem that I’m sure others have run into. In order to exclude classes from a swc you have to generate a link report from mxmlc. Then re-create the swc but tell mxmlc to load that report file and use it as the source for files to exclude.

That’s great and all, but the link report is usually huge, especially if you’re code links against flash components or flvplayback code. So in order to include only the classes you want (like only guttershark classes), I was starting to poke through the link report, and remove the guttershark classes.

Just to get this straight. MXMLC uses the link report as a source for actionscript classes to exclude from the swc. So if I want only the guttershark classes, you have to go into the link report and remove any guttershark class. The GS classes won’t be in the link report, which will cause them to be included in the swc.

Pretty simple; either poke through it and remove classes manually or try to write regular expressions to match only GS files. Then you think, “shit, this is a huge pain in the ass, and I’m going to waste a ton of time every time I need to update this link report.”

Here’s what I’m getting to: a python script to do it for you. This is the general usage sequence:

#...generate swc and link report with compc...
python swc_link_report_remove.py -l report.xml -m "/Users/aaronsmith/Development/git/guttershark" -o gsreport.xml
#...generate swc passing gsreport.xml for -load-externs to compc...

Here’s what the script does:

  • Load the original report.xml and parse it
  • Loop through each script item
  • If the script name attribute matches against the -m property, skip the item.
  • Write out the new link report file.

This is a much faster way to remove the classes you actually want included in the swc. I don’t use mxmlc or compc all that much, so maybe there is any easier way but the documentation certainly doesn’t outline any.

I’m on a mac, and you’ll need to install “lxml” for python.

sudo easy_install lxml

Here’s the script. Put it somewhere in your path for easy access and make sure it’s executable. Even if this isn’t exactly what you need, it’s a good starting point for scripting updates to the link reports.

  

No comments yet. Be the first.

Leave a reply