开发者

How should I collect dependencies from Adobe Flex files?

I'm looking fo开发者_如何学编程r a way to collect the file dependencies from Flex ActionScript and MXML files. I was hoping that mxmlc could spit them out (like gcc's -M option), but its option list doesn't seem to have anything relevant. I could write a parser, but would prefer not to reinvent the wheel if it has already been done, particularly given the two very different languages involved. In particular, star imports and in-package implicit imports could be troublesome.

Is there a program available to do this for me?


i am suspecting that since mxmlc is pretty smart and handles dependencies correctly, few people would need to figure out the dependencies themselves, and so the tool may have not come into existence.

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


The -link-report option of mxmlc produces a file containing most of the appropriate information, except that it reports fake file names for embedded assets, and ignores included source files. To collect everything, 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 of the mxmlc and compc commands in the makefile now have -link-report generating an appropriately-named .xml file in the .deps directory. I still have to search files for Embed and Script directives, but the hard part (determining which classes get included) has been done for me. I could use a real parser for each step, but grep, sed, and cut work well enough for the files as given.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜