langtools/src/share/opensource/javac/build.xml
author lmalvent
Mon, 10 Mar 2008 23:51:13 +0100
changeset 54 a007508f7193
parent 10 06bc494ca11e
permissions -rw-r--r--
Merge

<!--
 Copyright 2006 Sun Microsystems, Inc.  All Rights Reserved.
 DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.

 This code is free software; you can redistribute it and/or modify it
 under the terms of the GNU General Public License version 2 only, as
 published by the Free Software Foundation.  Sun designates this
 particular file as subject to the "Classpath" exception as provided
 by Sun in the LICENSE file that accompanied this code.

 This code is distributed in the hope that it will be useful, but WITHOUT
 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 version 2 for more details (a copy is included in the LICENSE file that
 accompanied this code).

 You should have received a copy of the GNU General Public License version
 2 along with this work; if not, write to the Free Software Foundation,
 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.

 Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
 CA 95054 USA or visit www.sun.com if you need additional information or
 have any questions.
-->

<project name="os-javac" default="build" basedir=".">
    <property name="src" value="src"/>
    <property name="src.bin" value="${src}/bin"/>
    <property name="src.classes" value="${src}/share/classes"/>
    <property name="build" value ="build"/>
    <property name="build.bootclasses" value="${build}/bootclasses"/>
    <property name="build.classes" value="${build}/classes"/>
    <property name="build.jtreg" value="${build}/jtreg"/>
    <property name="dist" value="dist"/>
    <property name="dist.javac" value="${dist}"/>
    
    <patternset id="src.javac">
        <include name="javax/annotation/processing/**/*.java"/>
        <include name="javax/lang/model/**/*.java"/>
        <include name="javax/tools/**/*.java"/>
        <include name="com/sun/source/**/*.java"/>
        <include name="com/sun/tools/javac/**/*.java"/>
    </patternset>

    <fileset id="javac.resources" dir="${src.classes}">
        <include name="com/sun/tools/javac/resources/*.properties"/>
        <exclude name="**/*-template.*"/>
    </fileset>
    
    <target name="prep">
        <mkdir dir="${build.bootclasses}"/>
        <mkdir dir="${build.classes}"/>
        <mkdir dir="${dist.javac}/bin"/>
        <mkdir dir="${dist.javac}/lib"/>
        <tstamp>
            <format property="build.time" pattern="MM/dd/yyyy hh:mm aa"/>
            <format property="build.fullversion.time" pattern="MM/dd/yyyy_HH_mm"/>
        </tstamp>
        <property file="build.properties"/>
    </target>
    
    <target name="check-javac.isuptodate">
        <uptodate targetfile="${dist.javac}/lib/javac.jar" property="javac.is.uptodate">
            <srcfiles dir="${src.classes}">
                <patternset refid="src.javac"/>
                <include name="${src.classes}/com/sun/tools/javac/resources/*.properties"/>
            </srcfiles>
        </uptodate>
    </target>
    
    <target name="build" depends="prep,build-lib.javac.jar,build-bin.javac"/>

    <target name="build-lib.javac.jar" depends="check-javac.isuptodate" unless="javac.is.uptodate">
        <!-- to compile javac, set includeAntRuntime=no to prevent javac's 
        own tools.jar incorrectly appearing on the classpath -->
        <javac srcdir="${src.classes}" destdir="${build.bootclasses}"
            source="${compiler.source.level}"  debug="true" debuglevel="source,lines"
            includeAntRuntime="no">
            <patternset refid="src.javac"/>
        </javac>
        <copy todir="${build.bootclasses}">
            <fileset refid="javac.resources"/>
        </copy>
        <echo message="recompiling compiler with itself"/>
        <pathconvert pathsep=" " property="src.javac.files">
            <path>
                <fileset dir="${src.classes}">
                    <patternset refid="src.javac"/>
                </fileset>
            </path>
        </pathconvert>
        <java fork="true" classpath="${build.bootclasses}" classname="com.sun.tools.javac.Main">
            <arg value="-sourcepath"/>
            <arg value=""/>
            <arg value="-d"/>
            <arg file="${build.classes}"/>
            <arg value="-g:source,lines"/>
            <arg line="${src.javac.files}"/>
        </java>
        <copy todir="${build.classes}">
            <fileset refid="javac.resources"/>
        </copy>
        <copy file="${src.classes}/com/sun/tools/javac/resources/version-template.properties"
            tofile="${build.classes}/com/sun/tools/javac/resources/version.properties">
            <filterset begintoken="$(" endtoken=")">
                <filter token="JDK_VERSION"  value="${build.jdk.version}"/>
                <filter token="RELEASE"      value="${build.release}"/>
                <filter token="FULL_VERSION" value="${build.full.version}"/>
            </filterset>
        </copy>
        <jar destfile="${dist.javac}/lib/javac.jar" basedir="${build.classes}">
            <manifest>
                <attribute name="Built-By" value="${user.name}"/>
                <attribute name="Built-At" value="${build.time}"/>
                <attribute name="Main-Class" value="com.sun.tools.javac.Main"/>
            </manifest>
        </jar>
    </target>
    
    <target name="build-bin.javac">
        <copy tofile="${dist.javac}/bin/javac" file="${src.bin}/javac.sh"/>
        <chmod file="${dist.javac}/bin/javac" perm="+x"/>
    </target>
    
    <property name="javadoc.jls3.url" value="http://java.sun.com/docs/books/jls/"/>
    <property name="javadoc.jls3.cite" value="&lt;a href=&quot;${javadoc.jls3.url}&quot;&gt;The Java Language Specification, Third Edition&lt;/a&gt;"/>
    
    <target name="docs" depends="prep">
        <javadoc sourcepath="${src.classes}" destdir="${dist}/doc/api"
            bootclasspath="${java.home}/lib/rt.jar" classpath="">
            <package name="javax.annotation.processing.*"/>
            <package name="javax.lang.model.*"/>
            <package name="javax.tools.*"/>
            <package name="com.sun.source.*"/>
            <package name="com.sun.tools.javac.*"/>
            <arg value="-tag"/>
            <arg value="jls3:a:See &lt;cite&gt;${javadoc.jls3.cite}&lt;/cite&gt;:"/>
        </javadoc>
    </target>
    
    <target name="test" depends="xtest" />

    <!-- can't call it test, because NetBeans associates that with JUnit -->
    <target name="xtest" depends="build">
        <fail unless="jtreg.home" message="Property 'jtreg.home' needs to be set to the jtreg installation directory."/>
        <taskdef name="jtreg" classpath="${jtreg.home}/lib/jtreg.jar" classname="com.sun.javatest.regtest.Main$$Ant"/>
        <fail unless="test.jdk.home" message="Property 'test.jdk.home' needs to be set to the baseline JDK to be used to run the tests"/>
        <jtreg dir="test" samevm="true" verbose="summary"
                jdk="${test.jdk.home}"
                workDir="${build.jtreg}/work" 
                reportDir="${build.jtreg}/report">
            <arg value="-noshell"/>
            <arg value="-Xbootclasspath/p:${dist.javac}/lib/javac.jar"/>
            <include name="tools/javac"/>
        </jtreg>
    </target>
    
    <target name="clean">
        <delete dir="${build}"/>
        <delete dir="${dist}"/>
    </target>
   
</project>