Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
193 lines (176 sloc) 9.35 KB
<?xml version="1.0"?>
<project name="as3couchdb" basedir="." default="build-project">
<!-- as3couchdb library requires the following libraries in order to be built properly: -->
<!-- [as3corelib] can be found at: http://code.google.com/p/as3corelib/ -->
<!-- [as3crypto] can be found at http://code.google.com/p/as3crypto/ -->
<!-- [as3httpclientlib] can be found at: http://code.google.com/p/as3httpclientlib -->
<!-- -->
<!-- The 'lib' target locates these external libraries within a directory described in the -->
<!-- build.properties file denoted as ${lib.dir}. Make sure you have these libraries within -->
<!-- that defined directory in order to properly build the as3couchdb.swc and/or optimized -->
<!-- SWF file. -->
<!-- -->
<!-- In order to be truly ActionScript 3 compliant (and not resticted to rely on classes -->
<!-- from the Flex framework), specific sources are targeted from the as3corelib project. -->
<!-- Specifically, these are the JSON and NET packages, and the StringUtil class. -->
<!-- The project is set up to have a local checkout of as3corelib within a directory -->
<!-- called externals on the root basedir. compc looks into this directory for as3corelib -->
<!-- sources listed in build.properties. -->
<!-- Property file. -->
<property file="build.properties" />
<!-- Generated file names for ease on conditionals. -->
<property name="standalone.swc" value="${standalone.bin.dir}/${library.name}.swc" />
<property name="external.swc" value="${external.bin.dir}/${external.name}.swc" />
<!-- Clean previously buil standalone library based on version. -->
<target name="clean" description="Cleans any previously build library related to projectname-version">
<echo>[CLEAN] Cleaning ${lib.bin.dir}/${lib.name}.swc</echo>
<delete file="${lib.bin.dir}/${lib.name}.swc" />
<echo>[CLEAN] Successfully cleaned ${lib.bin.dir}/${lib.name}.swc</echo>
</target>
<!-- Clean previously built standalone optimized SWF. -->
<target name="clean-optimize" description="Cleans any previously generated optimized standalone library">
<echo>[CLEAN] Cleaning ${lib.bin.dir}/${lib.name}.swf</echo>
<delete file="${lib.bin.dir}/${lib.name}.swf" />
<echo>[CLEAN] Succesfully cleaned ${lib.bin.dir}/${lib.name}.swf</echo>
</target>
<!-- Unpacks built standalone library SWC in order to optimize. -->
<target name="unpack-lib" description="Unpacks the pre-packaged library SWC.">
<!-- See if the SWC already exists. If so, no need to rebuild it. If not, we need to generate one. -->
<condition property="standalone.available">
<available file="${lib.swc}" />
</condition>
<!-- Unless not exists, this is called. -->
<antcall target="build-swc-for-optimize">
<param name="lib.name" value="${lib.name}" />
<param name="lib.bin.dir" value="${lib.bin.dir}" />
<param name="config" value="${config}" />
</antcall>
<!-- Move on to optimizing. -->
<echo>[UNZIP] Unpackaging ${lib.name}.swc.</echo>
<unzip src="${lib.bin.dir}/${lib.name}.swc" dest="${optimize.temp.dir}" />
<echo>[COPY] Moving unpacked library SWF to ${standalone.bin.dir}</echo>
<copy file="${optimize.temp.dir}/library.swf" tofile="${lib.bin.dir}/${lib.name}.swf" />
<echo>[CLEAN] Removing temporary directory for unpacking ${library.name}.swc.</echo>
<delete dir="${optimize.temp.dir}" includeemptydirs="true" />
<echo>[CLEAN] Successful unpackage of ${lib.name}.swc</echo>
</target>
<!-- Conditional task entered from optimize/unpack task if library SWC not previously gernerated. -->
<target name="build-swc-for-optimize" unless="standalone.available" description="Generate the library SWC of not already present.">
<echo>[INFO] SWC not available for optimization. Generating ${lib.name}.swc...</echo>
<antcall target="lib">
<param name="lib.name" value="${lib.name}" />
<param name="lib.bin.dir" value="${lib.bin.dir}" />
<param name="config" value="${config}" />
</antcall>
</target>
<!-- Parameterized target call for generating either standalone or external SWC. -->
<!-- The following parameters need to be passed when invoking this target: -->
<!-- [config] - The custom configuration file to compile against. -->
<!-- [lib.name] - The name of the generated library SWC. -->
<!-- [lib.bin.dir] - The output directory for the generated SWC. -->
<target name="lib" description="Generates the library SWC based on parameters.">
<!-- Clean first -->
<antcall target="clean">
<param name="lib.name" value="${lib.name}" />
<param name="lib.bin.dir" value="${lib.bin.dir}" />
</antcall>
<!-- Compile against config -->
<echo>[EXEC] Compiling ${lib.name}.swc</echo>
<exec executable="${compc.loc}" dir="${basedir}">
<arg line="+playerglobal.lib.dir=${playerglobal.lib.dir}" />
<arg line="+lib.dir=${lib.dir}" />
<arg line="+as3corelib.net.src=${as3corelib.net.src}" />
<arg line="+as3corelib.json.src=${as3corelib.json.src}" />
<arg line="+as3corelib.utils.StringUtil=${as3corelib.utils.StringUtil}" />
<arg line="+lib.bin.dir=${lib.bin.dir}" />
<arg line="+lib.name=${lib.name}" />
<arg line="+src.dir=${src.dir}" />
<arg line="-load-config+=${config}" />
</exec>
<echo>[EXEC] Finished compiling ${lib.name}.swc. ${lib.name}.swc can be found in ${lib.bin.dir}/.</echo>
</target>
<!-- Parameterized target call for generating either standalone or external optimized SWF. -->
<!-- The following parameters need to be passed when invoking this target: -->
<!-- [config] - The custom configuration file to compile against. -->
<!-- [lib.name] - The name of the generated library SWC. -->
<!-- [lib.bin.dir] - The output directory for the generated SWC. -->
<!-- [lib.swc] - The generated SWC file location. If not avialable, will create. -->
<target name="optimize" description="Generates an optimized SWF file from a library SWC.">
<echo>[EXEC] Optimizing ${lib.name}</echo>
<antcall target="clean-optimize">
<param name="lib.name" value="${lib.name}" />
<param name="lib.bin.dir" value="${lib.bin.dir}" />
</antcall>
<antcall target="unpack-lib">
<param name="lib.name" value="${lib.name}" />
<param name="lib.bin.dir" value="${lib.bin.dir}" />
<param name="lib.swc" value="${lib.swc}" />
<param name="config" value="${config}" />
</antcall>
<exec executable="${optimizer.loc}">
<arg line="-input ${lib.bin.dir}/${lib.name}.swf" />
<arg line="-output ${lib.bin.dir}/${lib.name}.swf" />
</exec>
<echo>[EXEC] Finished optimizing ${lib.name}. The optimized SWF can be found at ${lib.bin.dir}/${lib.name}.swf</echo>
</target>
<!-- Build the standalone library swc. DEFAULT -->
<target name="standalone" description="Generates the standalone library SWC.">
<antcall target="lib">
<param name="lib.name" value="${library.name}" />
<param name="lib.bin.dir" value="${standalone.bin.dir}" />
<param name="config" value="${standalone.config}" />
</antcall>
</target>
<!-- Build the external library swc. -->
<target name="external" description="Generates the external library SWC.">
<antcall target="lib">
<param name="lib.name" value="${external.name}" />
<param name="lib.bin.dir" value="${external.bin.dir}" />
<param name="config" value="${external.config}" />
</antcall>
</target>
<!-- Build the optimized standalone swf based on the output library SWC. -->
<target name="optimize-standalone" description="Optimizes the standalone library SWC into a generated SWF file.">
<antcall target="optimize">
<param name="lib.name" value="${library.name}" />
<param name="lib.bin.dir" value="${standalone.bin.dir}" />
<param name="lib.swc" value="${standalone.swc}" />
<param name="config" value="${standalone.config}" />
</antcall>
</target>
<!-- Build the optimized external swf based on the output library SWC. -->
<target name="optimize-external" description="Optimizes the external library SWC into a generated SWF file.">
<antcall target="optimize">
<param name="lib.name" value="${external.name}" />
<param name="lib.bin.dir" value="${external.bin.dir}" />
<param name="lib.swc" value="${external.swc}" />
<param name="config" value="${external.config}" />
</antcall>
</target>
<!-- Clean documents directory. -->
<target name="clean-doc" description="Cleans the document directory.">
<echo>[CLEAN] Cleaning ${doc.dir}</echo>
<delete includeemptydirs="true">
<fileset dir="${doc.dir}" includes="**/*" />
</delete>
<echo>[CLEAN] Successfully cleaned ${doc.dir}</echo>
</target>
<!-- Create the ASDocs for the library project. -->
<target name="doc" depends="clean-doc" description="Creates the ASDoc files for the library project.">
<exec executable="${asdoc.loc}" spawn="no">
<arg line="-library-path+=${lib.dir}" />
<arg line="-source-path ${src.dir}" />
<arg line="-doc-sources ${src.dir} " />
<arg line="-output ${doc.dir}" />
<arg line="-window-title 'AS3CouchDB Library - ${library.name}' "/>
</exec>
</target>
<!-- DEFAULT. Runs all tasks to build standard and external SWCs and optimized SWFs as well as project docs. -->
<target name="build-project" description="Runs all tasks to generate SWC, SWF and doc files.">
<antcall target="standalone" />
<antcall target="optimize-standalone" />
<antcall target="external" />
<antcall target="optimize-external" />
<antcall target="doc" />
</target>
</project>