How do I collect dependencies from Adobe Flex files?

I'm looking for a way to collect file dependencies from Flex ActionScript and MXML files. I was hoping that mxmlc could spit them out (like the gcc -M variant), but its list of options doesn't seem to have anything to do with it. I could write a parser, but would rather not reinvent the wheel if already done, especially given two very different languages. In particular, animal imports and implicit imports in packaging can be frustrating.

Do I have a program for this?

+2


a source to share


2 answers


The -link-report mxmlc option generates a file that contains most of the relevant information, except that it reports fake file names for embedded assets and ignores included source files. To put everything together, I now have the following in my makefile:

.deps/%.d: .deps/%.xml
    # $@: $<
    grep '<script name=./' $< | cut -f2 -d'"' | cut -f1 -d'(' | cut -f1 -d'$$' | sort -u  | sed -e "s|^$$(pwd)/||" > .deps/$*.f
    grep '\.mxml$$' .deps/$*.f | xargs grep -H 'mx:Script source' | sed -s 's|/[^/]*.mxml:.*source="\([^"]*\)".*|/\1|;' > .deps/$*.i
    for path in $$(grep -h '\.\(mxml\|as\|css\)$$' .deps/$*.[fi] | xargs grep '\bEmbed([^.)]' | \
        sed "s@\\(\\w\\+\\)/.*Embed([^'\")]*['\"][./]*\\([^'\"]*\\)['\"] *[,)].*@\\1/*/\\2@"); \
        do find */src -path "$$path"; done | sort -u > .deps/$*.e
    cat .deps/$*.[fie] | sed -e "s|^|$(flashpath)$*.swf $@ : |" > $@

# This includes targets, so should not be before the first target defined here.
built := $(wildcard .deps/*.xml)
include $(built:xml=d)

      



All mxmlc and compc commands in the makefile now have -link-report, which creates a file with the appropriate name .xml in the .deps directory. I still have to search for files for the Embed and Script directives, but the tricky part (determining which classes are included) was done for me. I could use a real parser for each step, but grep, sed and cut work well enough for files as stated.

0


a source


I suspect that since mxmlc is pretty smart and manages dependencies correctly, few people will need to define dependencies themselves, and so the tool may not have come along.



I think parsing import statements would be the way to go?

0


a source







All Articles