Skip to content

typedef ant

Harbs edited this page Oct 19, 2017 · 2 revisions

Sample Ant Script for Generating Typedef SWC files

To use this script, you need the following:

  1. A project with a structure as follows:
  • src
    • com
      • acme
        • etc
    • main
      • config
        • compile-as-config.xml
  • typdefs
    • js.swc (copy the js.swc file from the SDK)
  1. Create the compile-as-config.xml using the provided template.
  2. Create the build.xml file at the root of your project.
  3. Replace PROJECT_NAME with the name of your project.

build.xml

<?xml version="1.0" ?>
<project name="PROJECT_NAME" default="main" basedir=".">
    <property environment="env"/>
    <condition property="ROYALE_HOME" value="${env.ROYALE_HOME}">
        <and>
            <not>
                <isset property="ROYALE_HOME" />
            </not>
            <available file="${env.ROYALE_HOME}/royale-sdk-description.xml" type="file" />
        </and>
    </condition>
    <condition property="ROYALE_HOME" value="/FlexSDK/FlexJSNightly">
        <not>
            <isset property="ROYALE_HOME" />
        </not>
    </condition>
    
    <!-- <property name="ROYALE_HOME" value="${basedir}/.." /> -->
    
    <condition property="FALCON_HOME" value="${env.FALCON_HOME}">
        <and>
            <not>
                <isset property="FALCON_HOME" />
            </not>
            <available file="${env.FALCON_HOME}/lib/compiler-mxmlc.jar" type="file" />
        </and>
    </condition>
    
    <condition property="FALCON_HOME" value="${ROYALE_HOME}/../royale-compiler/compiler">
        <and>
            <not>
                <isset property="FALCON_HOME" />
            </not>
            <available file="${ROYALE_HOME}/../royale-compiler/compiler/lib/compiler-mxmlc.jar" type="file" />
        </and>
    </condition>
    
    <condition property="FALCON_HOME" value="${ROYALE_HOME}">
        <and>
            <not>
                <isset property="FALCON_HOME" />
            </not>
            <available file="${ROYALE_HOME}/lib/compiler-mxmlc.jar" type="file" />
        </and>
    </condition>
    
    <condition property="FALCONJX_HOME" value="${env.FALCONJX_HOME}">
        <and>
            <not>
                <isset property="FALCONJX_HOME" />
            </not>
            <available file="${env.FALCONJX_HOME}/lib/jsc.jar" type="file" />
        </and>
    </condition>
    
    <condition property="FALCONJX_HOME" value="${ROYALE_HOME}/js">
        <and>
            <not>
                <isset property="FALCONJX_HOME" />
            </not>
            <available file="${ROYALE_HOME}/js/lib/jsc.jar" type="file" />
        </and>
    </condition>
    
    <condition property="FALCONJX_HOME" value="${ROYALE_HOME}/../royale-compiler/compiler-jx">
        <and>
            <not>
                <isset property="FALCONJX_HOME" />
            </not>
            <available file="${ROYALE_HOME}/../royale-compiler/compiler-jx/lib/jsc.jar" type="file" />
        </and>
    </condition>
    
    <target name="main" depends="clean, preprocess, externc, postprocess, compc" />

    <!-- we need to insert a line near the beginning of the file to make the
        compiler happy. -->
    <target name="preprocess">
    </target>
    
    <target name="externc" >
    </target>
    
    <target name="postprocess" >
    </target>
    
    <target name="compc" >
        <copy file="${basedir}/src/main/config/compile-as-config.xml" todir="${basedir}/target" />
        <java jar="${FALCON_HOME}/lib/compiler-compc.jar" fork="true"
            failonerror="true">
            <arg value="+royalelib=externs/frameworks" />
            <arg value="-debug" />
            <arg value="-load-config=${basedir}/src/main/config/compile-as-config.xml" />
            <arg value="-output=${basedir}/target/${ant.project.name}.swc" />
        </java>
    </target>
    
    <target name="clean">
        <delete dir="${basedir}/target" failonerror="false" includeEmptyDirs="true"/>
    </target>
    <target name="wipe" depends="clean">
    </target>
</project>
Clone this wiki locally