LARA

<?xml version="1.0" encoding="UTF-8" ?>
 
<project name="toolc" default="dist" basedir=".">
    <description>
        The toolc project: building a compiler for the Tool programming language.
    </description>
 
    <!-- All settings can be overridden in a file called local.properties. -->
 
    <!-- Scala & Java -->
    <property environment="env" />
    <property name="scala.home" value="${env.SCALA_HOME}" />
    <property name="scala-library.jar" value="${scala.home}/lib/scala-library.jar" />
    <property name="scala-compiler.jar" value="${scala.home}/lib/scala-compiler.jar" />
    <property name="scalac.default.params" value="-deprecation -unchecked" />
 
    <!-- paths -->
    <property name="base.dir" value="${basedir}" />
    <property name="sources.dir" value="${base.dir}/src" />
    <property name="build.dir" value="${base.dir}/bin" />
    <property name="dist.dir" value="${base.dir}/dist" />
    <property name="lib.dir" value="${base.dir}/lib" />
 
    <!-- other properties -->
    <property name="dist.jar" value="${dist.dir}/toolc.jar" />
    <property name="main.class" value="tool.Main" />
    <property name="script.file" value="${base.dir}/toolc" />
    <property name="cafebabe.jar" value="${lib.dir}/cafebabe.jar" />
    <property name="release.jar" value="${release.dir}/toolc-reference.jar" />
 
    <!-- required to use the scalac task -->
    <taskdef resource="scala/tools/ant/antlib.xml">
        <classpath>
            <pathelement location="${scala-compiler.jar}" />
            <pathelement location="${scala-library.jar}" />
        </classpath>
    </taskdef>
    <!-- classpath definition -->
    <path id="scalac.classpath">
        <pathelement location="${scala-library.jar}" />
        <pathelement location="${scala-compiler.jar}" />
    </path>
 
    <path id="build.path">
        <path refid="scalac.classpath" />
        <pathelement location="${build.dir}" />
        <!-- UNCOMMENT THE NEXT LINE ONCE WE GET TO CODE GENERATION. EVERYTHING WILL BE CLEAR THEN :) -->
        <!-- <pathelement location="${cafebabe.jar}" /> -->
    </path>
 
    <target name="compile" description="Compile the toolc source files.">
        <mkdir dir="${build.dir}" />
        <scalac srcdir="${sources.dir}" destdir="${build.dir}" force="changed" addparams="${scalac.default.params}">
            <classpath>
                <path refid="build.path" />
            </classpath>
        </scalac>
    </target>
 
    <target name="dist" depends="compile" description="Build a jar file and a script file for toolc.">
        <mkdir dir="${dist.dir}" />
 
        <manifest file="${dist.dir}/MANIFEST.MF">
            <attribute name="Built-By" value="lara.epfl.ch" />
            <attribute name="Main-Class" value="${main.class}" />
        </manifest>
 
        <jar destfile="${dist.jar}" manifest="${dist.dir}/MANIFEST.MF">
            <fileset dir="${build.dir}" />
        </jar>
 
        <echo file="${script.file}" message="#!/bin/sh${line.separator}scala -classpath .:${dist.jar}:${cafebabe.jar} ${main.class} $@${line.separator}" />
        <chmod file="${script.file}" perm="u+x" />
    </target>
    <target name="clean" description="Clean the project.">
        <delete dir="${build.dir}" includeemptydirs="yes" quiet="yes" failonerror="no" />
        <delete dir="${dist.dir}" includeemptydirs="yes" quiet="yes" failonerror="no" />
        <delete dir="${release.dir}" includeemptydirs="yes" quiet="yes" failonerror="no" />
        <delete file="${script.file}" quiet="yes" failonerror="no" />
    </target>
 
    <target name="new" description="Clean and rebuild." depends="clean,dist" />
</project>