<project name="codemanic" default="dev">

  <!-- set global properties for this build -->

  <property file="build.properties"/>

  <target name="update">
    <cvs command="update -Pd"/>
  </target>
  
  <target name="grammar">
    <mkdir dir="gensrc/org/dojo/jsl/parser"/>
    <mkdir dir="gensrc/org/dojo/jsl/ast"/>
    <mkdir dir="gensrc/org/dojo/jsl/jammer"/>
  	 <!--  <mkdir dir="gensrc/com/quiotix/html/parser"/>  --> 
    <jjtree 
        target="src/org/dojo/jsl/parser/EcmaScript.jjt" 
        outputdirectory="gensrc/org/dojo/jsl/parser"
        javacchome="${javacchome}" 
    />
    <javacc 
        target="gensrc/org/dojo/jsl/parser/EcmaScript.jj" 
        outputdirectory="gensrc/org/dojo/jsl/parser"
        javacchome="${javacchome}" 
    />
    <javacc 
        target="src/org/dojo/jsl/ast/TreePattern.jj" 
        outputdirectory="gensrc/org/dojo/jsl/ast"
        javacchome="${javacchome}" 
    />
 <!-- 
  	     <javacc 
        target="src/org/dojo/jsl/jammer/BlockParams.jj" 
        outputdirectory="gensrc/org/dojo/jsl/jammer"
        javacchome="${javacchome}" 
    />
  <javacc 
        target="src/com/quiotix/html/parser/HtmlParser.jj" 
        outputdirectory="gensrc/com/quiotix/html/parser"
        javacchome="${javacchome}" 
    />    
  -->  
  </target>

  <target name="javadoc">
       <mkdir dir="buildtemp/javadoc" />
       <javadoc
            packagenames="org.dojo.jsl.*"
	    sourcepath="src"
	    doctitle="DOJO Jsl"
	    windowtitle="DOJO Jsl"
	    destdir="buildtemp/javadoc" >
	    <link href="http://java.sun.com/j2se/1.5.0/docs/api/"/>
       </javadoc>
  </target>

  <target name="compile" depends="grammar">
    <mkdir dir="buildtemp/classes"/>
    <delete>
       <fileset dir="buildtemp/classes" includes="**"/>
    </delete>
    <javac destdir="buildtemp/classes" debug="${debug}">
         <src path="."/>
         <include name="gensrc/**"/>
         <include name="src/**"/>
         <exclude name="gensrc/org/dojo/jsl/parser/ASTBlock.java"/>
         <exclude name="gensrc/org/dojo/jsl/parser/ASTCompositeReference.java"/>
         <exclude name="gensrc/org/dojo/jsl/parser/ASTFunctionDeclaration.java"/>
         <exclude name="gensrc/org/dojo/jsl/parser/ASTIdentifier.java"/>
         <exclude name="gensrc/org/dojo/jsl/parser/ASTLiteral.java"/>
         <exclude name="gensrc/org/dojo/jsl/parser/ASTOperator.java"/>
         <exclude name="gensrc/org/dojo/jsl/parser/ASTProgram.java"/>
         <exclude name="gensrc/org/dojo/jsl/parser/SimpleNode.java"/>
        <classpath>
        <pathelement location="lib/bcel/bcel.jar"/>
	    <pathelement location="lib/sisc/sisc.jar"/>
        </classpath>
    </javac>
    <copy file="lib/sisc/sisc.heap" todir="buildtemp/classes/org/dojo/jsl/top/resources/scheme" />
    <copy file="src/org/dojo/jsl/top/version.properties" todir="buildtemp/classes/org/dojo/jsl/top">
        <filterset>
	    <filter token="jsl_build_tag" value="${jsl_build_tag}"/>
	    <filter token="jsl_build_time" value="${TODAY}"/>
        </filterset>
    </copy>
  </target>

  <target name="dev" depends="compile">
    <copy todir="${devclasses}">
       <fileset dir="buildtemp/classes" defaultexcludes="yes">
       </fileset>
    </copy>
  </target>

  <target name="dist" depends="clean,compile">
    <tstamp/>
    <mkdir dir="jsl/docs" />
	<mkdir dir="jsl/docs/css" />
    <mkdir dir="jsl/bin" />

    <jar destfile="jsl/bin/jsl.jar" basedir="buildtemp/classes" />

    <copy file="docs/jsl" todir="jsl/bin"/>

    <copy file="lib/bcel/bcel.jar" todir="jsl/bin"/>
    <copy file="lib/sisc/sisc.jar" todir="jsl/bin"/>

  	<copy file="docs/jsl.prj" todir="jsl/bin"/>
	<copy file="docs/build.xml" todir="jsl/bin"/>

  	<copy todir="jsl/tests">
  	  <fileset dir="tests"
  	           includes="**"
  	  />
  	</copy>
  	
	<copy todir="jsl/docs">
  	  <fileset dir="docs"
  	           includes="**"
  	  />
  	</copy>


    <copy todir="jsl/resources">
       <fileset dir="resources">
       </fileset>
    </copy>

  </target>

  <target name="package" depends="dist">
    <tstamp/>
    <tar destfile="buildtemp/jsl-${jsl_build_tag}.tar">
         <tarfileset dir="buildtemp/dist" mode="755">
                <include name="jsl/bin/*"/>
         </tarfileset>
         <tarfileset dir="buildtemp/dist">
                <include name="**"/>
                <exclude name="jsl/bin/*"/>
         </tarfileset>
   </tar>
   <gzip zipfile="buildtemp/jsl-${jsl_build_tag}.tar.gz" 
         src="buildtemp/jsc-${jsc_build_tag}.tar"/>
  </target>

  <target name="clean">
    <delete dir="buildtemp" />
    <delete dir="gensrc" />
	<delete dir="jsl" />
  </target>


  <target name="cleandev">
    <delete dir="${devclasses}" />
    <mkdir dir="${devclasses}" />
  </target>

<target name="test"
        description="run the test suite" >
   <java classname="org.dojo.jsl.top.Top" fork="true" failonerror="true">
    	<arg value="--verbose"/> 
    	<arg value="--tempdir"/> 
		<arg value="jsl/tmp"/> 
   	    <arg value="--prj"/> 
		<arg value="jsl/bin/jsl.prj"/> 
    	<arg value="--sources"/> 
    	<arg file="jsl/tests/test_Colorspace.html"/> 	
        <classpath>
        <pathelement location="jsl/bin/bcel.jar"/>
	    <pathelement location="jsl/bin/sisc.jar"/>
		<pathelement location="jsl/bin/jsl.jar"/>
        </classpath>
    </java>
</target>

</project>
