我应该如何从 Adob​​e Flex 文件收集依赖项?

发布于 2024-09-01 10:51:36 字数 205 浏览 5 评论 0原文

我正在寻找一种从 Flex ActionScript 和 MXML 文件收集文件依赖项的方法。我希望 mxmlc 可以将它们吐出来(就像 gcc 的 -M 选项),但它的选项列表似乎没有任何相关内容。我可以编写一个解析器,但如果已经完成,我不想重新发明轮子,特别是考虑到所涉及的两种截然不同的语言。特别是,星号导入和包内隐式导入可能会很麻烦。

有没有可用的程序可以为我执行此操作?

I'm looking for 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

陌上芳菲 2024-09-08 10:51:36

我怀疑,由于 mxmlc 非常智能并且可以正确处理依赖关系,因此很少有人需要自己找出依赖关系,因此该工具可能还没有出现。

我想解析导入语句是正确的方法?

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?

南街九尾狐 2024-09-08 10:51:36

mxmlc 的 -link-report 选项生成一个包含大部分适当信息的文件,但它报告嵌入资源的假文件名,并忽略包含的源文件。为了收集所有内容,我的 makefile 中现在包含以下内容:

.deps/%.d: .deps/%.xml
    # $@: 
lt;
    grep '<script name=./' 
lt; | 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)

makefile 中的所有 mxmlc 和 compc 命令现在都具有 -link-report,在 .deps 目录中生成适当命名的 .xml 文件。我仍然需要在文件中搜索嵌入和脚本指令,但困难的部分(确定包含哪些类)已经为我完成了。我可以为每个步骤使用真正的解析器,但 grep、sed 和 cut 对于给定的文件来说足够好。

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
    # $@: 
lt;
    grep '<script name=./' 
lt; | 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文