<?xml version="1.0"?>
<!--

  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.

-->

<!-- Note:
    If you modify this file you may have to make the same change in build_framework.xml.
    build_framework.xml is renamed to build.xml when it is packaged.
    It is used to build the frameworks directory from the zip file.
-->
<project name="frameworksJS" default="main" basedir=".">

    <property name="ROYALE_HOME" location="../../.."/>

    <!-- Required for OSX 10.6 / Snow Leopard Performance. -->
    <!-- Java 7 on Mac requires OSX 10.7.3 or higher and is 64-bit only -->
    <!-- local.d32 is set/used in build.properties so this needs to be done first. -->
    <condition property="local.d32" value="-d32">
        <and>
            <os family="mac"/>
            <matches pattern="1.6.*" string="${java.version}"/>
            <equals arg1="${sun.arch.data.model}" arg2="64"/>
            <equals arg1="${os.arch}" arg2="x86_64"/>
        </and>
    </condition>

    <!-- Property for the platform.  -->
    <condition property="isMac">
        <os family="mac"/>
    </condition>
    <condition property="isWindows">
        <os family="windows" />
    </condition>
    <condition property="isLinux">
        <and>
          <os family="unix"/>
          <not>
            <os family="mac"/>
          </not>
        </and>
    </condition>

    <property file="${ROYALE_HOME}/env.properties"/>
    <property environment="env"/>
    <property file="${ROYALE_HOME}/build.properties"/>
    <property name="ROYALE_HOME" value="${ROYALE_HOME}" />

    <target name="main" depends="check-compile-env,clean,prepare,compile"
        description="Clean build of all SWCs"/>

    <target name="check-compile-env" description="Check for the required environment variables">
        <ant antfile="${ROYALE_HOME}/build.xml" target="check-compile-env" dir="${ROYALE_HOME}"/>
    </target>


    <target name="prepare" depends="thirdparty-downloads"/>

    <target name="thirdparty-downloads" unless="no.thirdparty-downloads" description="Downloads all the required thirdparty code.">
    </target>

    <target name="compile" description="Builds all SWCs but not their resource bundles">
        <!-- order may matter due to dependencies -->
        <antcall target="Language"/>
        <antcall target="Core"/>
        <antcall target="Graphics"/>
        <antcall target="Binding"/>
        <antcall target="Collections"/>
        <antcall target="Basic"/>
        <antcall target="HTML"/>
        <antcall target="Flat"/>
        <antcall target="Charts"/>
        <antcall target="CreateJS"/>
        <antcall target="DragDrop"/>
        <antcall target="Effects"/>
        <antcall target="Formatters"/>
        <antcall target="GoogleMaps"/>
        <antcall target="HTML5"/>
        <antcall target="JQuery"/>
        <antcall target="Mobile"/>
        <antcall target="Reflection"/>
        <antcall target="Network"/>
        <antcall target="RoyaleUnit"/>
        <antcall target="Storage"/>
        <antcall target="XML"/>
        <antcall target="Text"/>
        <antcall target="TLF"/>
		<antcall target="MaterialDesignLite"/>
        <antcall target="Icons" />
        <antcall target="Jewel"/>
        <antcall target="MXRoyaleBase"/>
        <antcall target="MXRoyale"/>
        <antcall target="SparkRoyale"/>
        <antcall target="Crux"/>
        <antcall target="Ace"/>
        <antcall target="RoyaleSite"/>
    </target>

    <target name="other.locales" description ="Builds resource SWCs for all locales">
        <!--<ant dir="${basedir}/projects/RoyaleUI" target="other.locales"/>-->
    </target>

    <target name="doc" >
        <ant dir="${basedir}/projects/Core" target="doc" />
    </target>

    <!--
		Cleanup
	-->

    <target name="super-clean" depends="thirdparty-clean,clean" description="Cleans everything including thirdparty downloads."/>

    <target name="thirdparty-clean" unless="no.thirdparty-clean" description="Removes all thirdparty downloads.">
        <ant antfile="${basedir}/downloads.xml" target="clean" dir="${basedir}"/>
    </target>

    <target name="clean" description="Cleans all SWCs and their resource bundles">
        <!-- Delete output from SWC projects -->
        <ant dir="${basedir}/projects/BindingJS" target="clean"/>
        <ant dir="${basedir}/projects/ChartsJS" target="clean"/>
        <ant dir="${basedir}/projects/CollectionsJS" target="clean"/>
        <ant dir="${basedir}/projects/CoreJS" target="clean"/>
        <ant dir="${basedir}/projects/CreateJSJS" target="clean"/>
        <ant dir="${basedir}/projects/DragDropJS" target="clean"/>
        <ant dir="${basedir}/projects/EffectsJS" target="clean"/>
        <ant dir="${basedir}/projects/ExpressJS" target="clean"/>
        <ant dir="${basedir}/projects/FlatJS" target="clean"/>
        <ant dir="${basedir}/projects/FormattersJS" target="clean"/>
        <ant dir="${basedir}/projects/FontAwesomeJS" target="clean"/>
        <ant dir="${basedir}/projects/GoogleMapsJS" target="clean"/>
        <ant dir="${basedir}/projects/GraphicsJS" target="clean"/>
        <ant dir="${basedir}/projects/BasicJS" target="clean"/>
        <ant dir="${basedir}/projects/HTMLJS" target="clean"/>
        <ant dir="${basedir}/projects/HTML5JS" target="clean"/>
        <ant dir="${basedir}/projects/JQueryJS" target="clean"/>
        <ant dir="${basedir}/projects/LanguageJS" target="clean"/>
		<ant dir="${basedir}/projects/MaterialDesignLiteJS" target="clean"/>
        <ant dir="${basedir}/projects/MobileJS" target="clean"/>
        <ant dir="${basedir}/projects/NetworkJS" target="clean"/>
        <ant dir="${basedir}/projects/ReflectionJS" target="clean"/>
        <ant dir="${basedir}/projects/RoyaleUnitJS" target="clean"/>
        <ant dir="${basedir}/projects/StorageJS" target="clean"/>
        <ant dir="${basedir}/projects/TextJS" target="clean"/>
        <ant dir="${basedir}/projects/TLFJS" target="clean"/>
        <ant dir="${basedir}/projects/XMLJS" target="clean"/>
        <ant dir="${basedir}/projects/IconsJS" target="clean"/>
        <ant dir="${basedir}/projects/JewelJS" target="clean"/>
        <ant dir="${basedir}/projects/MXRoyaleBaseJS" target="clean"/>
        <ant dir="${basedir}/projects/MXRoyaleJS" target="clean"/>
        <ant dir="${basedir}/projects/CruxJS" target="clean"/>
        <ant dir="${basedir}/projects/SparkRoyaleJS" target="clean"/>
        <ant dir="${basedir}/projects/AceJS" target="clean"/>
        <ant dir="${basedir}/projects/RoyaleSiteJS" target="clean"/>

        <delete dir="${basedir}/libs"/>
        <delete dir="${basedir}/generated-sources"/>
    </target>

    <target name="Binding" description="Clean build of BindingJS.swc">
        <ant dir="${basedir}/projects/BindingJS"/>
    </target>

    <target name="Charts" description="Clean build of ChartsJS.swc">
        <ant dir="${basedir}/projects/ChartsJS"/>
    </target>

    <target name="Core" description="Clean build of CoreJS.swc">
        <ant dir="${basedir}/projects/CoreJS"/>
    </target>

    <target name="Collections" description="Clean build of CollectionsJS.swc">
        <ant dir="${basedir}/projects/CollectionsJS"/>
    </target>

    <target name="CreateJS" description="Clean build of CreateJS.swc">
        <ant dir="${basedir}/projects/CreateJSJS"/>
    </target>

    <target name="DragDrop" description="Clean build of DragDrop.swc">
        <ant dir="${basedir}/projects/DragDropJS"/>
    </target>

    <target name="Effects" description="Clean build of EffectsJS.swc">
        <ant dir="${basedir}/projects/EffectsJS"/>
    </target>

    <target name="Flat" description="Clean build of FlatJS.swc">
        <ant dir="${basedir}/projects/FlatJS"/>
    </target>

    <target name="Formatters" description="Clean build of FormattersJS.swc">
        <ant dir="${basedir}/projects/FormattersJS"/>
    </target>

    <target name="GoogleMaps" description="Clean build of GoogleMapsJS.swc">
        <ant dir="${basedir}/projects/GoogleMapsJS"/>
    </target>

    <target name="Graphics" description="Clean build of GraphicsJS.swc">
        <ant dir="${basedir}/projects/GraphicsJS"/>
    </target>

    <target name="Basic" description="Clean build of BasicJS.swc">
        <ant dir="${basedir}/projects/BasicJS"/>
    </target>

    <target name="HTML" description="Clean build of HTMLJS.swc">
        <ant dir="${basedir}/projects/HTMLJS"/>
    </target>

    <target name="HTML5" description="Clean build of HTML5JS.swc">
        <ant dir="${basedir}/projects/HTML5JS"/>
    </target>

    <target name="JQuery" description="Clean build of JQueryJS.swc">
        <ant dir="${basedir}/projects/JQueryJS"/>
    </target>

    <target name="Language" description="Clean build of LanguageJS.swc">
        <ant dir="${basedir}/projects/LanguageJS"/>
    </target>

	<target name="MaterialDesignLite" description="Clean build of MaterialDesignLiteJS.swc">
        <ant dir="${basedir}/projects/MaterialDesignLiteJS"/>
    </target>

    <target name="Mobile" description="Clean build of MobileJS.swc">
        <ant dir="${basedir}/projects/MobileJS"/>
    </target>

    <target name="Network" description="Clean build of NetworkJS.swc">
        <ant dir="${basedir}/projects/NetworkJS"/>
    </target>

    <target name="Reflection" description="Clean build of ReflectionJS.swc">
        <ant dir="${basedir}/projects/ReflectionJS"/>
    </target>

    <target name="RoyaleUnit" description="Clean build of RoyaleUnitJS.swc">
        <ant dir="${basedir}/projects/RoyaleUnitJS"/>
    </target>

    <target name="Storage" description="Clean build of StorageJS.swc">
        <ant dir="${basedir}/projects/StorageJS"/>
    </target>

    <target name="XML" description="Clean build of XMLJS.swc">
        <ant dir="${basedir}/projects/XMLJS"/>
    </target>

    <target name="Text" description="Clean build of TextJS.swc">
        <ant dir="${basedir}/projects/TextJS"/>
    </target>

    <target name="TLF" description="Clean build of TLFJS.swc">
        <ant dir="${basedir}/projects/TLFJS"/>
    </target>

    <target name="Icons" description="Clean build of IconsJS.swc">
        <ant dir="${basedir}/projects/IconsJS"/>
    </target>

    <target name="Jewel" description="Clean build of JewelJS.swc">
        <ant dir="${basedir}/projects/JewelJS"/>
    </target>

    <target name="MXRoyaleBase" description="Clean build of MXRoyaleBaseJS.swc">
        <ant dir="${basedir}/projects/MXRoyaleBaseJS"/>
    </target>

    <target name="MXRoyale" description="Clean build of MXRoyaleJS.swc">
        <ant dir="${basedir}/projects/MXRoyaleJS"/>
    </target>

    <target name="SparkRoyale" description="Clean build of SparkRoyaleJS.swc">
        <ant dir="${basedir}/projects/SparkRoyaleJS"/>
    </target>

    <target name="Crux" description="Clean build of CruxJS.swc">
        <ant dir="${basedir}/projects/CruxJS"/>
    </target>

    <target name="Ace" description="Clean build of AceJS.swc">
        <ant dir="${basedir}/projects/AceJS"/>
    </target>

    <target name="RoyaleSite" description="Clean build of RoyaleSiteJS.swc">
        <ant dir="${basedir}/projects/RoyaleSiteJS"/>
    </target>

</project>
