Skip to content

Instantly share code, notes, and snippets.

@zrong
Created August 10, 2011 13:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zrong/1136833 to your computer and use it in GitHub Desktop.
Save zrong/1136833 to your computer and use it in GitHub Desktop.
使用target來控制部署路徑
# 设置FLEX SDK的路径
FLEX_HOME=d:/flex_sdks/4.5.0
# 设置源文件路径
# {$basedir} 就是本文件所在的目录
SRC_DIR =${basedir}/src
# libs目录,一般用来放swc文件
LIBS_DIR =${basedir}/libs
# 用于部署的文件夹
DEPLOY_DIR = ${basedir}/bin
#自定义的几个类库源码
SRC_ZRONG = e:/works/zrong.as3.git/src
<project name="kv7" default="debug_fdb">
<!-- 使用 ant -Dmain=A 来编译不同的主文件,本例将默认编译Emcee.as文件。如果提供了参数值,就编译${参数值}.as文件 -->
<!-- 使用 ant debug 编译debug版本的swf文件 -->
<!-- 使用 ant release 编译release版本的swf文件 -->
<!-- 使用 ant debug_fdb 编译debug版本的swf文件,并打开调试器 -->
<!-- 载入配置文件 -->
<property environment="env"/>
<property file="build.properties" />
<property name="main" value="Emcee" />
<!-- debug版本的swf文件的部署路径 -->
<property name="debugSWF" value="${DEPLOY_DIR}/${main}_debug.swf" />
<!-- release版本的swf文件的部署路径 -->
<property name="releaseSWF" value="${DEPLOY_DIR}/${main}.swf" />
<!-- 确定flexTasks.jar的位置 -->
<taskdef resource="flexTasks.tasks" classpath="${FLEX_HOME}/ant/lib/flexTasks.jar"/>
<!-- 建立调试版本并打开调试器 -->
<target name="debug_fdb" depends="init">
<antcall target="debug"/>
<antcall target="fdb" />
</target>
<!-- 建立调试版本 -->
<target name="debug">
<antcall target="init">
<param name="outputSWF" value="${debugSWF}" />
</antcall>
<antcall target="build_mxmlc">
<param name="isDebug" value="true" />
<param name="outputSWF" value="${debugSWF}" />
</antcall>
</target>
<!-- 部署用的发布版本 -->
<target name="release">
<antcall target="init">
<param name="outputSWF" value="${releaseSWF}" />
</antcall>
<antcall target="build_mxmlc">
<param name="isDebug" value="false" />
<param name="outputSWF" value="${releaseSWF}" />
</antcall>
</target>
<!-- 清理部署目录中的内容 -->
<target name="init">
<delete dir="${outputSWF}" />
<delete dir="${DEPLOY_DIR}/assets/magic" />
<!-- 将资源目录复制到部署目录 -->
<copy todir="${DEPLOY_DIR}/assets/magic">
<fileset dir="${SRC_DIR}/assets/magic" />
</copy>
</target>
<!-- 编译主播界面 -->
<target name="build_mxmlc">
<mxmlc file="${SRC_DIR}/${main}.as" output="${outputSWF}">
<load-config filename="${FLEX_HOME}/frameworks/flex-config.xml"/>
<source-path path-element="${SRC_ZRONG}" />
<compiler.library-path dir="${basedir}" append="true">
<include name="libs" />
</compiler.library-path>
<!-- 必须加上这行,如果不加,当使用[Embed]的标签的时候,就会出现VerifyError: Error #1014: 无法找到类 。 原因应该是没有将mx.core包编译进入。官方文档说这个属性默认是true, 不要相信它-->
<static-link-runtime-shared-libraries>true</static-link-runtime-shared-libraries>
<!-- 编译成可调试的版本 -->
<compiler.debug>${isDebug}</compiler.debug>
</mxmlc>
</target>
<!-- 打开调试器进行调试 -->
<target name="fdb">
<!-- 不能直接调用fdb,因为这样不会打开新的命令行窗口,必须使用/K或者/C参数,加上start来启动fdb -->
<exec executable="cmd" spawn="true" osfamily="windows">
<arg line="/K start fdb ${debugSWF}" />
</exec>
</target>
</project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment