jdk/make/netbeans/common/shared.xml
author lana
Wed, 11 Apr 2012 18:44:33 -0700
changeset 12408 8e95f7b85140
parent 5506 202f599c92aa
child 15517 588eec59872b
permissions -rw-r--r--
Merge

<?xml version="1.0" encoding="UTF-8"?>

<!--
 Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.

 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions
 are met:

   - Redistributions of source code must retain the above copyright
     notice, this list of conditions and the following disclaimer.

   - Redistributions in binary form must reproduce the above copyright
     notice, this list of conditions and the following disclaimer in the
     documentation and/or other materials provided with the distribution.

   - Neither the name of Oracle nor the names of its
     contributors may be used to endorse or promote products derived
     from this software without specific prior written permission.

 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
 IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->

<project name="shared" basedir="..">

    <import file="make.xml"/>

    <target name="-tstamp">
        <tstamp>
            <format property="build.time" pattern="MM/dd/yyyy hh:mm aa"/>
            <format property="build.fullversion.time" pattern="MM/dd/yyyy_HH_mm"/>
        </tstamp>
    </target>

    <target name="-first-init" depends="-tstamp">
        <mkdir dir="${user.home}/.openjdk"/>
        <property name="workspace-user-build.properties" location="nbproject/private/build.properties"/>
        <property file="${workspace-user-build.properties}"/>
        <property file="${user.home}/.openjdk/${ant.project.name}-build.properties"/>
        <property name="user-build.properties" location="${user.home}/.openjdk/build.properties"/>
        <property file="${user-build.properties}"/>
        <property file="${basedir}/build.properties"/>
        <property environment="env."/>
    </target>
    <target name="-warn-about-bootstrap.jdk" depends="-first-init" unless="bootstrap.jdk">
        <property name="fallback.jdk" location="${java.home}/.."/>
        <echo level="warning">Warning: falling back to building against ${fallback.jdk}</echo>
        <echo level="warning">Please define bootstrap.jdk=.../recent/jdk7/snapshot in ${user-build.properties} or ${workspace-user-build.properties}</echo>
    </target>
    <target name="-pre-init">
        <!-- Invoked before -first-init. -->
        <!-- Empty placeholder for easier customization. -->
        <!-- You can override this target in the ../build.xml file. -->
    </target>
    <target name="-post-init">
        <!-- Invoked after -project-init. -->
        <!-- Empty placeholder for easier customization. -->
        <!-- You can override this target in the ../build.xml file. -->
    </target>
    <target name="-init" description="Initial configuration used by everything else." depends="-pre-init,-first-init,-project-init,-post-init"/>
    <target name="-project-init" depends="-warn-about-bootstrap.jdk">
        <property name="root" location="../../.."/>
        <property file="../common/architectures/name-${os.name}.properties"/>
        <property name="platform" value="windows"/>
        <property file="../common/architectures/arch-${os.arch}.properties"/>
        <property name="arch" value="${os.arch}"/>
        <echo level="verbose">System configuration claims architecture is ${platform}-${arch}</echo>
        <property name="build.dir" location="${root}/build/${platform}-${arch}"/>
        <property name="bin.dir" location="${build.dir}/bin"/>
        <property name="make.dir" location="${root}/make"/>
        <property name="gensrc.dir" location="${build.dir}/gensrc"/>
        <property name="classes.dir" location="${build.dir}/classes"/>
        <property name="jtreg.dir" location="${build.dir}/jtreg/${ant.project.name}"/>
        <property name="dist.dir" value="${root}/dist"/>
        <property name="includes" value="(nothing)"/>
        <property name="excludes" value=""/>
        <property name="javadoc.dir" location="${build.dir}/javadoc/${ant.project.name}"/>
        <condition property="os.linux">
            <os name="linux"/>
        </condition>
        <condition property="os.solaris">
            <os name="SunOS"/>
        </condition>
        <condition property="osfamily.unix">
            <os family="unix"/>
        </condition>
        <condition property="os.windows">
            <os family="windows"/>
        </condition>
        <condition property="platform.src.dir" value="${root}/src/solaris/classes">
            <os family="unix"/>
        </condition>
        <condition property="platform.src.dir" value="${root}/src/windows/classes">
            <os family="windows"/>
        </condition>
        <property name="share.src.dir" value="${root}/src/share/classes"/>
        <property name="bootstrap.jdk" location="${fallback.jdk}"/>
        <!-- XXX ensure that bootstrap.jdk meets some minimum version requirements (TBD) -->
        <condition property="bootstrap.javac" value="${bootstrap.jdk}/bin/javac">
            <available file="${bootstrap.jdk}/bin/javac"/>
        </condition>
        <condition property="bootstrap.javac" value="${bootstrap.jdk}\bin\javac.exe">
            <available file="${bootstrap.jdk}\bin\javac.exe"/>
        </condition>
        <fail unless="bootstrap.javac">${bootstrap.jdk} does not appear to be a functional JDK; no javac found.</fail>
        <property name="javac.options" value="-Xlint"/> <!-- default, can be overridden per user or per project -->
        <property name="javac.debug" value="true"/>  <!-- default, can be overridden per user or per project -->
        <property name="javac.debuglevel" value="lines,vars,source"/>  <!-- default, can be overridden per user or per project -->
        <macrodef name="jdk-javac">
            <attribute name="srcdir"/>
            <attribute name="includes" default="${includes}"/>
            <attribute name="excludes" default="${excludes}"/>
            <attribute name="classesdir" default="${classes.dir}"/>
            <sequential>
                <mkdir dir="@{classesdir}"/>
                <javac srcdir="@{srcdir}" includes="@{includes}" excludes="@{excludes}" sourcepath="" 
                    destdir="@{classesdir}" fork="true" executable="${bootstrap.javac}"
                    debug="${javac.debug}" debuglevel="${javac.debuglevel}">
                    <compilerarg value="-source"/>
                    <compilerarg value="1.5"/>
                    <compilerarg value="-target"/>
                    <compilerarg value="1.6"/> <!-- for usability of JDK 6 as snapshot; change to 1.7 when JSR 294 put back -->
                    <!-- Mandatory for compiling partial JDK sources against a snapshot; should NEVER be used for any other purpose: -->
                    <compilerarg value="-XDignore.symbol.file=true"/>
                    <compilerarg line="${javac.options}"/>
                </javac>
            </sequential>
        </macrodef>
        <available property="have.closed.src" file="${root}/src/closed/share/classes" type="dir"/>
    </target>

    <target name="-pre-compile">
        <!-- Empty placeholder for easier customization. -->
        <!-- You can override this target in the ../build.xml file. -->
    </target>
    <target name="-post-compile">
        <!-- Empty placeholder for easier customization. -->
        <!-- You can override this target in the ../build.xml file. -->
    </target>
    
    <target name="build" depends="-init,-pre-compile,-build-ant,-build-make,-post-compile" description="Build sources."/>
    <target name="-do-build-ant">
        <depend srcdir="${share.src.dir}:${platform.src.dir}:${root}/src/closed/share/classes:${gensrc.dir}" destdir="${classes.dir}" cache="${build.dir}/depcache" includes="${includes}" excludes="${excludes}"/>
        <mkdir dir="${gensrc.dir}"/>
        <jdk-javac srcdir="${share.src.dir}:${platform.src.dir}:${gensrc.dir}"/>
        <property name="copy.excludes" value="**/*.java,**/package.html,**/doc-files/"/>
        <copy todir="${classes.dir}">
            <fileset dir="${share.src.dir}" includes="${includes}" excludes="${excludes},${copy.excludes}"/>
            <fileset dir="${platform.src.dir}" includes="${includes}" excludes="${excludes},${copy.excludes}"/>
        </copy>
        <antcall target="-maybe-do-build-ant-closed"/>
    </target>
    <target name="-maybe-do-build-ant-closed" if="have.closed.src">
        <jdk-javac srcdir="${root}/src/closed/share/classes"/>
        <copy todir="${classes.dir}">
            <fileset dir="${root}/src/closed/share/classes" includes="${includes}" excludes="${excludes},${copy.excludes}"/>
        </copy>
    </target>
    <target name="-build-ant" depends="-init" unless="use.make">
        <antcall target="-do-build-ant"/>
    </target>
    <target name="-build-make" depends="-init" if="use.make"> <!-- override me to call <make-run> -->
        <echo level="info">No make target defined for this project; falling back to simple Java build</echo>
        <antcall target="-do-build-ant"/>
    </target>

    <target name="clean" depends="-init,-clean-docs-tests,-clean-ant,-clean-make" description="Clean build products."/>
    <target name="-do-clean-ant">
        <!-- XXX first s/\.java/.class/g in includes and excludes! -->
        <delete dir="${classes.dir}" includes="${includes}" excludes="${excludes}" includeemptydirs="true"/>
        <delete dir="${gensrc.dir}" includes="${includes}" excludes="${excludes}" includeemptydirs="true"/>
        <delete dir="${build.dir}/depcache"/>
    </target>
    <target name="-clean-docs-tests">
        <delete dir="${javadoc.dir}" includeemptydirs="true"/>
        <delete dir="${jtreg.dir}" includeemptydirs="true"/>
    </target>
    <target name="-clean-ant" depends="-init" unless="use.make">
        <antcall target="-do-clean-ant"/>
    </target>
    <target name="-clean-make" depends="-init" if="use.make"> <!-- override me to call <make-run> -->
        <echo level="info">No make clean target defined for this project; falling back to simple Java clean</echo>
        <antcall target="-do-clean-ant"/>
    </target>

    <target name="compile-single" depends="-init">
        <fail unless="srcdir">Must set property 'srcdir'</fail>
        <fail unless="includes">Must set property 'includes'</fail>
        <jdk-javac srcdir="${srcdir}" includes="${includes}" excludes=""/>
    </target>
    <target name="debug-fix" depends="-init" if="netbeans.home">
        <fail unless="class">Must set property 'class'</fail>
        <antcall target="compile-single">
            <param name="includes" value="${class}.java"/>
        </antcall>
        <nbjpdareload>
            <fileset dir="${classes.dir}">
                <include name="${class}.class"/>
            </fileset>
        </nbjpdareload>
    </target>

    <target name="-taskdef-jtreg" depends="-init" unless="jtreg.defined">
        <fail message="Cannot locate jtreg: please set jtreg.home to its location">
            <condition>
                <not>
                    <isset property="jtreg.home"/>
                </not>
            </condition>
        </fail>
        <fail message="jtreg is not installed in ${jtreg.home}">
            <condition>
                <not>
                    <and>
                        <available file="${jtreg.home}/lib/jtreg.jar"/>
                        <available file="${jtreg.home}/lib/javatest.jar"/>
                    </and>
                </not>
            </condition>
        </fail>
        <taskdef name="jtreg" classname="com.sun.javatest.regtest.Main$$Ant">
            <classpath>
                <pathelement location="${jtreg.home}/lib/jtreg.jar"/>
                <pathelement location="${jtreg.home}/lib/javatest.jar"/>
            </classpath>
        </taskdef>
        <property name="jtreg.defined" value="true"/>
    </target>
    <target name="-check-tests-defined" unless="jtreg.tests">
        <fail>You must define jtreg.tests to select some tests to run.</fail>
    </target>
    <target name="-jtreg-setup">
        <property name="jtreg.vm.options" value=""/> <!-- default, can be overridden per user or per project -->
        <property name="jtreg.options" value=""/> <!-- default, can be overridden per user or per project -->
        <property name="jtreg.samevm" value="false"/>  <!-- default, can be overridden per user or per project -->
    </target>
    <target name="-jtreg-ant" unless="use.make">
        <jtreg dir="${root}/test" samevm="${jtreg.samevm}" verbose="summary"
               jdk="${bootstrap.jdk}"
               failonerror="false" resultproperty="jtreg.result"
               javacoptions="-g"
               vmoptions="-Xbootclasspath/p:${classes.dir} ${jtreg.vm.options}"
               reportDir="${jtreg.dir}/JTreport"
               workDir="${jtreg.dir}/JTwork"
               includes="${jtreg.tests}">
            <arg line="${jtreg.options}"/>
        </jtreg>
    </target>
    <target name="-jtreg-make" if="use.make">
        <jtreg dir="${root}/test" samevm="${jtreg.samevm}" verbose="summary"
               failonerror="false" resultproperty="jtreg.result"
               jdk="${build.dir}"
               vmoptions="${jtreg.vm.options}"
               javacoptions="-g"
               reportDir="${jtreg.dir}/JTreport"
               workDir="${jtreg.dir}/JTwork"
               includes="${jtreg.tests}">
            <arg line="${jtreg.options}"/>
        </jtreg>
    </target>
    <target name="-pre-jtreg">
        <!-- Empty placeholder for easier customization. -->
        <!-- You can override this target in the ../build.xml file. -->
    </target>
    <target name="-post-jtreg">
        <!-- Empty placeholder for easier customization. -->
        <!-- You can override this target in the ../build.xml file. -->
    </target>
    <target name="-jtreg" depends="-init,-pre-jtreg,-taskdef-jtreg,-check-tests-defined,-jtreg-setup,-jtreg-make,-jtreg-ant,-post-jtreg">
        <property name="jtreg.report" location="${jtreg.dir}/JTreport/report.html"/>
        <condition property="jtreg.passed">
            <equals arg1="${jtreg.result}" arg2="0"/>
        </condition>
    </target>
    <target name="test" depends="jtreg"/> <!-- Allow use of existing finger muscle memory from command line. -->
    <target name="jtreg" depends="-jtreg" description="Run jtreg-based tests." unless="jtreg.passed">
        <fail>${jtreg.report}: some tests failed.</fail>
    </target>
    <target name="jtreg-nb" depends="-jtreg" if="netbeans.home" unless="jtreg.passed">
        <makeurl file="${jtreg.report}" property="jtreg.report.url"/>
        <nbbrowse url="${jtreg.report.url}#Results"/>
        <fail>Some tests failed; see report for details.</fail>
    </target>
    <target name="jtreg-debug-nb" depends="-init" if="netbeans.home">
        <!-- No package decls -> "source root" is immediately containing dir -->
        <dirname file="${root}/test/${jtreg.tests}" property="test.dir"/>
        <nbjpdastart addressproperty="jpda.address" name="${ant.project.name}" transport="dt_socket">
            <bootclasspath>
                <pathelement location="${classes.dir}"/>
                <pathelement location="${bootstrap.jdk}/jre/lib/rt.jar"/>
            </bootclasspath>
            <classpath>
                <pathelement location="${jtreg.dir}/JTwork/classes"/>
            </classpath>
            <sourcepath>
                <pathelement location="${share.src.dir}"/>
                <pathelement location="${platform.src.dir}"/>
                <pathelement location="${root}/src/closed/share/classes"/>
                <pathelement location="${test.dir}"/>
            </sourcepath>
        </nbjpdastart>
        <antcall target="-jtreg">
            <param name="jtreg.vm.options" value="-Xdebug -Xrunjdwp:transport=dt_socket,address=${jpda.address}"/>
        </antcall>
    </target>
    
    <target name="debug" depends="-init" if="netbeans.home">
        <!-- No package decls -> "source root" is immediately containing dir -->
        <dirname file="${root}/test/${jtreg.tests}" property="test.dir"/>
        <nbjpdastart addressproperty="jpda.address" name="${ant.project.name}" transport="dt_socket">
            <bootclasspath>
                <pathelement location="${classes.dir}"/>
                <pathelement location="${bootstrap.jdk}/jre/lib/rt.jar"/>
            </bootclasspath>
            <sourcepath>
                <pathelement location="${share.src.dir}"/>
                <pathelement location="${platform.src.dir}"/>
                <pathelement location="${root}/src/closed/share/classes"/>
                <pathelement location="${test.dir}"/>
            </sourcepath>
        </nbjpdastart>
        <antcall target="run">
            <param name="jvm.args" value="-Xdebug -Xrunjdwp:transport=dt_socket,address=${jpda.address}"/>
        </antcall>
    </target>

    <target name="javadoc" depends="-init" description="Build basic Javadoc for public packages.">
        <property name="javadoc.options" value=""/> <!-- default, can be overridden per user or per project -->
        <!-- Note: even with this default value, includes/excludes
         from share.src.dir get javadoc'd; see packageset below -->
        <property name="javadoc.packagenames" value="none"/> <!-- default, can be overridden per user or per project -->
        <javadoc destdir="${javadoc.dir}" source="1.5"
            windowtitle="UNOFFICIAL" failonerror="true" use="true"
            author="false" version="false"
            packagenames="${javadoc.packagenames}">
            <header><![CDATA[<strong>Unofficial Javadoc</strong> generated from developer sources for preview purposes only]]></header>
            <arg line="${javadoc.options}"/>
            <bootclasspath>
                <path location="${bootstrap.jdk}/jre/lib/rt.jar"/>
                <path location="${classes.dir}"/>
            </bootclasspath>
            <sourcepath>
                <pathelement location="${share.src.dir}"/>
                <pathelement location="${platform.src.dir}"/>
                <pathelement location="${root}/src/closed/share/classes"/>
                <pathelement location="${root}/src/share/doc/stub"/>
            </sourcepath>
            <!-- XXX just <fileset> (restricted further to **/*.java) and no <packageset> -->
            <!-- means that {@link some.package} will not work, which is no good. -->
            <!-- (It correctly skips excluded single classes, but not if packageset is also included, -->
            <!-- which also causes duplicates in the class index for included files.) -->
            <packageset dir="${share.src.dir}" includes="${includes}" excludes="${excludes}">
                <or>
                    <filename name="java/"/>
                    <filename name="javax/"/>
                    <filename name="org/ietf/jgss/"/>
                    <filename name="org/omg/"/>
                    <filename name="org/w3c/"/>
                    <filename name="org/xml/sax/"/>
                </or>
            </packageset>
        </javadoc>
    </target>
    <target name="javadoc-nb" depends="javadoc" if="netbeans.home">
        <nbbrowse file="${javadoc.dir}/index.html"/>
    </target>

</project>