如何加快 MXMLC 编译速度?

发布于 2025-01-03 03:00:32 字数 4700 浏览 4 评论 0原文

我正在使用 ant 构建我的网络应用程序。我的 ant 脚本中有一个目标,编译大约需要 8 分钟。由于 mxmlc 每次都会从头开始编译所有内容并加载 JVM,因此需要花费大量时间。有没有办法优化这个任务?

我正在使用 Flex SDK 3.0。这是我的蚂蚁目标:

<target name="compile.organic.flash" depends="setup">
  <property name="WelcomeBack.swf" value="${www.dir}/swf/as3/apps/welcome/WelcomeBack.swf" />
  <mxmlc file="${AS3.classpath}/com/organic/app/fthb/welcome/src/WelcomeBack.as"
         output="${WelcomeBack.swf}"
         incremental="${mxmlc.inc}"
         default-frame-rate="30"
         accessible="true"
         default-background-color="${swf.backgrond.color}"
         allow-source-path-overlap="true"
         compiler.strict="true">
    <default-size width="940" height="528" />
    <source-path path-element="${Welcome.path}"/>
    <source-path path-element="${AS3.classpath}"/>
  </mxmlc>

  <property name="Welcome.swf" value="${www.dir}/swf/as3/apps/welcome/Welcome.swf" />
  <mxmlc file="${AS3.classpath}/com/organic/app/fthb/welcome/src/Welcome.as"
         output="${Welcome.swf}"
         incremental="${mxmlc.inc}"
         default-frame-rate="30"
         accessible="true"
         default-background-color="${swf.backgrond.color}"
         allow-source-path-overlap="true"
         compiler.strict="true">
    <default-size width="940" height="528" />
    <source-path path-element="${Welcome.path}"/>
    <source-path path-element="${AS3.classpath}"/>
    <compiler.include-libraries dir="${AS3.component}/" >
    </compiler.include-libraries>
  </mxmlc>

  <property name="App.swf" value="${www.dir}/swf/as3/apps/App-${svnVersion}.swf" />
  <mxmlc file="${AS3.classpath}/com/organic/app/fthb/App.as"
         output="${App.swf}"
         incremental="${mxmlc.inc}"
         default-frame-rate="30"
         default-background-color="${swf.backgrond.color}"
         compiler.strict="true">
    <default-size width="300" height="300" />
    <source-path path-element="${AS3.classpath}"/>
    <compiler.include-libraries dir="${AS3.component}/" >
    </compiler.include-libraries>
  </mxmlc>

  <property name="LSOApp.swf" value="${www.dir}/swf/as3/apps/LSOApp-${svnVersion}.swf" />
  <mxmlc file="${AS3.classpath}/com/organic/boa/fthb/LSOApp.as"
         output="${LSOApp.swf}"
         incremental="${mxmlc.inc}"
         default-frame-rate="30"
         default-background-color="${swf.backgrond.color}"
         compiler.strict="true">
    <default-size width="300" height="300" />
    <source-path path-element="${AS3.classpath}"/>
    <compiler.include-libraries dir="${AS3.component}/" >
    </compiler.include-libraries>
  </mxmlc>

  <property name="CheckRates.swf" value="${www.dir}/swf/as3/apps/CheckRates-${svnVersion}.swf" />
  <mxmlc file="${CheckRates.path}/CheckRates.as"
         output="${CheckRates.swf}"
         incremental="${mxmlc.inc}"
         default-frame-rate="40"
         accessible="true"
         default-background-color="${swf.backgrond.color}"
         compiler.strict="true" compiler.allow-source-path-overlap="true" >
    <default-size width="940" height="528" />
    <compiler.source-path path-element="${AS3.classpath}"/>
    <compiler.source-path path-element="${CheckRates.path}"/>
    <!--  <source-path path-element="${AS3.classpath}"/> -->
    <compiler.include-libraries dir="${AS3.classpath}">
    <include name="fl/fl.swc" />
    </compiler.include-libraries>
  </mxmlc>

  <copy file="${AS3.classpath}/com/organic/app/fthb/checkRates/js/config/check_rates_config.js" tofile="${www.dir}/swf/as3/apps/config/check_rates_config.js"/>
  <property name="PointsCalculator.swf" value="${www.dir}/swf/as3/apps/PointsCalculator-${svnVersion}.swf" />
  <property name="flash.apps.build.dir" value="${www.dir}/swf/as3/apps" />
  <compile-flash basename="PointsCalculator" srcdir="${flash.apps.src.dir}/pointsCalculator">
  </compile-flash>
  <copy todir="${flash.apps.build.dir}/config">
    <fileset dir="${flash.apps.src.dir}/pointsCalculator/config" includes="*.js"/>
  </copy>
  <copy todir="${build.dir}/www/css">
    <fileset dir="${flash.apps.src.dir}/pointsCalculator/css" includes="*.css"/>
  </copy>
  <copy todir="${build.dir}/www/swf/as3/apps/welcome/assets/swfs">
    <fileset dir="${flash.apps.src.dir}/welcome/assets/swfs" includes="*.swf"/>
  </copy>
  <copy file="${videoplayer.dir}/videoplayer.swf" tofile="${www.dir}/swf/as3/apps/videoplayer.swf" />
</target>

I am using ant to build my web application. I have a target in my ant script which takes approximately 8 minutes to compile. Since mxmlc compiles everything from scratch and loads up the JVM each time, it is taking a lot of time. Is there a way to optimize this task?

I am using Flex SDK 3.0. Here is my ant target:

<target name="compile.organic.flash" depends="setup">
  <property name="WelcomeBack.swf" value="${www.dir}/swf/as3/apps/welcome/WelcomeBack.swf" />
  <mxmlc file="${AS3.classpath}/com/organic/app/fthb/welcome/src/WelcomeBack.as"
         output="${WelcomeBack.swf}"
         incremental="${mxmlc.inc}"
         default-frame-rate="30"
         accessible="true"
         default-background-color="${swf.backgrond.color}"
         allow-source-path-overlap="true"
         compiler.strict="true">
    <default-size width="940" height="528" />
    <source-path path-element="${Welcome.path}"/>
    <source-path path-element="${AS3.classpath}"/>
  </mxmlc>

  <property name="Welcome.swf" value="${www.dir}/swf/as3/apps/welcome/Welcome.swf" />
  <mxmlc file="${AS3.classpath}/com/organic/app/fthb/welcome/src/Welcome.as"
         output="${Welcome.swf}"
         incremental="${mxmlc.inc}"
         default-frame-rate="30"
         accessible="true"
         default-background-color="${swf.backgrond.color}"
         allow-source-path-overlap="true"
         compiler.strict="true">
    <default-size width="940" height="528" />
    <source-path path-element="${Welcome.path}"/>
    <source-path path-element="${AS3.classpath}"/>
    <compiler.include-libraries dir="${AS3.component}/" >
    </compiler.include-libraries>
  </mxmlc>

  <property name="App.swf" value="${www.dir}/swf/as3/apps/App-${svnVersion}.swf" />
  <mxmlc file="${AS3.classpath}/com/organic/app/fthb/App.as"
         output="${App.swf}"
         incremental="${mxmlc.inc}"
         default-frame-rate="30"
         default-background-color="${swf.backgrond.color}"
         compiler.strict="true">
    <default-size width="300" height="300" />
    <source-path path-element="${AS3.classpath}"/>
    <compiler.include-libraries dir="${AS3.component}/" >
    </compiler.include-libraries>
  </mxmlc>

  <property name="LSOApp.swf" value="${www.dir}/swf/as3/apps/LSOApp-${svnVersion}.swf" />
  <mxmlc file="${AS3.classpath}/com/organic/boa/fthb/LSOApp.as"
         output="${LSOApp.swf}"
         incremental="${mxmlc.inc}"
         default-frame-rate="30"
         default-background-color="${swf.backgrond.color}"
         compiler.strict="true">
    <default-size width="300" height="300" />
    <source-path path-element="${AS3.classpath}"/>
    <compiler.include-libraries dir="${AS3.component}/" >
    </compiler.include-libraries>
  </mxmlc>

  <property name="CheckRates.swf" value="${www.dir}/swf/as3/apps/CheckRates-${svnVersion}.swf" />
  <mxmlc file="${CheckRates.path}/CheckRates.as"
         output="${CheckRates.swf}"
         incremental="${mxmlc.inc}"
         default-frame-rate="40"
         accessible="true"
         default-background-color="${swf.backgrond.color}"
         compiler.strict="true" compiler.allow-source-path-overlap="true" >
    <default-size width="940" height="528" />
    <compiler.source-path path-element="${AS3.classpath}"/>
    <compiler.source-path path-element="${CheckRates.path}"/>
    <!--  <source-path path-element="${AS3.classpath}"/> -->
    <compiler.include-libraries dir="${AS3.classpath}">
    <include name="fl/fl.swc" />
    </compiler.include-libraries>
  </mxmlc>

  <copy file="${AS3.classpath}/com/organic/app/fthb/checkRates/js/config/check_rates_config.js" tofile="${www.dir}/swf/as3/apps/config/check_rates_config.js"/>
  <property name="PointsCalculator.swf" value="${www.dir}/swf/as3/apps/PointsCalculator-${svnVersion}.swf" />
  <property name="flash.apps.build.dir" value="${www.dir}/swf/as3/apps" />
  <compile-flash basename="PointsCalculator" srcdir="${flash.apps.src.dir}/pointsCalculator">
  </compile-flash>
  <copy todir="${flash.apps.build.dir}/config">
    <fileset dir="${flash.apps.src.dir}/pointsCalculator/config" includes="*.js"/>
  </copy>
  <copy todir="${build.dir}/www/css">
    <fileset dir="${flash.apps.src.dir}/pointsCalculator/css" includes="*.css"/>
  </copy>
  <copy todir="${build.dir}/www/swf/as3/apps/welcome/assets/swfs">
    <fileset dir="${flash.apps.src.dir}/welcome/assets/swfs" includes="*.swf"/>
  </copy>
  <copy file="${videoplayer.dir}/videoplayer.swf" tofile="${www.dir}/swf/as3/apps/videoplayer.swf" />
</target>

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

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

发布评论

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

评论(2

听风吹 2025-01-10 03:00:32

使用fcsh。从该链接的第一段

fcsh(Flex Compiler Shell)实用程序提供 shell 环境
用于编译 Flex 应用程序、模块和组件
图书馆。它的工作方式与 mxmlc 和 compc 命令行非常相似
编译器,但它的编译速度比 mxmlc 和 compc 快
命令行编译器。原因之一是,通过将所有内容保留在
内存,fcsh 消除了启动 JVM 和加载的开销
编译器类。另一个原因是编译结果(对于
例如,类型信息)可以保存在内存中以供后续使用
汇编。

Use fcsh. From the first paragraph of that link

The fcsh (Flex Compiler Shell) utility provides a shell environment
that you use to compile Flex applications, modules, and component
libraries. It works very similarly to the mxmlc and compc command line
compilers, but it compiles faster than the mxmlc and compc
command-line compilers. One reason is that by keeping everything in
memory, fcsh eliminates the overhead of launching the JVM and loading
the compiler classes. Another reason is that compilation results (for
example, type information) can be kept in memory for subsequent
compilations.

咿呀咿呀哟 2025-01-10 03:00:32

我们发现减慢编译器速度的主要是链接资源。我们制作了一个库项目 swf,它仅用于除字体之外的资源(图像、swf 等),而且它的效果很好。

我们在 2 分钟内从 Maven 构建了一个大型项目。

We found that what was slowing down the compiler was mostly linking assets. We made a library project swf that is just used for assets (images, swfs, etc.) except fonts, and it works a treat.

We have a massive project building under 2 mins from maven.

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