1 <?xml version="1.0" encoding="UTF-8"?>
   2 
   3 <!--
   4  Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
   5 
   6  Redistribution and use in source and binary forms, with or without
   7  modification, are permitted provided that the following conditions
   8  are met:
   9 
  10    - Redistributions of source code must retain the above copyright
  11      notice, this list of conditions and the following disclaimer.
  12 
  13    - Redistributions in binary form must reproduce the above copyright
  14      notice, this list of conditions and the following disclaimer in the
  15      documentation and/or other materials provided with the distribution.
  16 
  17    - Neither the name of Oracle nor the names of its
  18      contributors may be used to endorse or promote products derived
  19      from this software without specific prior written permission.
  20 
  21  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
  22  IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
  23  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  24  PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  25  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  26  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  27  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  28  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  29  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  30  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  31  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32 -->
  33 
  34 <project name="shared" basedir="..">
  35 
  36     <import file="make.xml"/>
  37 
  38     <target name="-tstamp">
  39         <tstamp>
  40             <format property="build.time" pattern="MM/dd/yyyy hh:mm aa"/>
  41             <format property="build.fullversion.time" pattern="MM/dd/yyyy_HH_mm"/>
  42         </tstamp>
  43     </target>
  44 
  45     <target name="-first-init" depends="-tstamp">
  46         <mkdir dir="${user.home}/.openjdk"/>
  47         <property name="workspace-user-build.properties" location="nbproject/private/build.properties"/>
  48         <property file="${workspace-user-build.properties}"/>
  49         <property file="${user.home}/.openjdk/${ant.project.name}-build.properties"/>
  50         <property name="user-build.properties" location="${user.home}/.openjdk/build.properties"/>
  51         <property file="${user-build.properties}"/>
  52         <property file="${basedir}/build.properties"/>
  53         <property environment="env."/>
  54     </target>
  55     <target name="-warn-about-bootstrap.jdk" depends="-first-init" unless="bootstrap.jdk">
  56         <property name="fallback.jdk" location="${java.home}/.."/>
  57         <echo level="warning">Warning: falling back to building against ${fallback.jdk}</echo>
  58         <echo level="warning">Please define bootstrap.jdk=.../recent/jdk7/snapshot in ${user-build.properties} or ${workspace-user-build.properties}</echo>
  59     </target>
  60     <target name="-pre-init">
  61         <!-- Invoked before -first-init. -->
  62         <!-- Empty placeholder for easier customization. -->
  63         <!-- You can override this target in the ../build.xml file. -->
  64     </target>
  65     <target name="-post-init">
  66         <!-- Invoked after -project-init. -->
  67         <!-- Empty placeholder for easier customization. -->
  68         <!-- You can override this target in the ../build.xml file. -->
  69     </target>
  70     <target name="-init" description="Initial configuration used by everything else." depends="-pre-init,-first-init,-project-init,-post-init"/>
  71     <target name="-project-init" depends="-warn-about-bootstrap.jdk">
  72         <property name="root" location="../../.."/>
  73         <property file="../common/architectures/name-${os.name}.properties"/>
  74         <property name="platform" value="windows"/>
  75         <property file="../common/architectures/arch-${os.arch}.properties"/>
  76         <property name="arch" value="${os.arch}"/>
  77         <echo level="verbose">System configuration claims architecture is ${platform}-${arch}</echo>
  78         <property name="build.dir" location="${root}/build/${platform}-${arch}"/>
  79         <property name="bin.dir" location="${build.dir}/bin"/>
  80         <property name="make.dir" location="${root}/make"/> <!-- this is old build make files! -->
  81         <property name="gensrc.dir" location="${build.dir}/gensrc"/>
  82         <property name="classes.dir" location="${build.dir}/classes"/>
  83         <property name="jtreg.dir" location="${build.dir}/jtreg/${ant.project.name}"/>
  84         <property name="dist.dir" value="${root}/dist"/>
  85         <property name="includes" value="(nothing)"/>
  86         <property name="excludes" value=""/>
  87         <property name="javadoc.dir" location="${build.dir}/javadoc/${ant.project.name}"/>
  88         <condition property="os.macosx">
  89             <os family="mac"/>
  90         </condition>
  91         <condition property="os.linux">
  92             <os name="linux"/>
  93         </condition>
  94         <condition property="os.solaris">
  95             <os name="SunOS"/>
  96         </condition>
  97         <condition property="osfamily.unix">
  98             <os family="unix"/>
  99         </condition>
 100         <condition property="os.windows">
 101             <os family="windows"/>
 102         </condition>
 103         <condition property="platform.src.dir" value="${root}/src/solaris/classes">
 104             <os family="unix"/>
 105         </condition>
 106         <condition property="platform.src.dir" value="${root}/src/windows/classes">
 107             <os family="windows"/>
 108         </condition>
 109         <property name="share.src.dir" value="${root}/src/share/classes"/>
 110         <property name="bootstrap.jdk" location="${fallback.jdk}"/>
 111         <!-- XXX ensure that bootstrap.jdk meets some minimum version requirements (TBD) -->
 112         <condition property="bootstrap.javac" value="${bootstrap.jdk}/bin/javac">
 113             <available file="${bootstrap.jdk}/bin/javac"/>
 114         </condition>
 115         <condition property="bootstrap.javac" value="${bootstrap.jdk}\bin\javac.exe">
 116             <available file="${bootstrap.jdk}\bin\javac.exe"/>
 117         </condition>
 118         <fail unless="bootstrap.javac">${bootstrap.jdk} does not appear to be a functional JDK; no javac found.</fail>
 119         <property name="javac.options" value="-Xlint"/> <!-- default, can be overridden per user or per project -->
 120         <property name="javac.debug" value="true"/>  <!-- default, can be overridden per user or per project -->
 121         <property name="javac.debuglevel" value="lines,vars,source"/>  <!-- default, can be overridden per user or per project -->
 122         <macrodef name="jdk-javac">
 123             <attribute name="srcdir"/>
 124             <attribute name="includes" default="${includes}"/>
 125             <attribute name="excludes" default="${excludes}"/>
 126             <attribute name="classesdir" default="${classes.dir}"/>
 127             <sequential>
 128                 <mkdir dir="@{classesdir}"/>
 129                 <javac srcdir="@{srcdir}" includes="@{includes}" excludes="@{excludes}" sourcepath=""
 130                     destdir="@{classesdir}" fork="true" executable="${bootstrap.javac}"
 131                     debug="${javac.debug}" debuglevel="${javac.debuglevel}">
 132                     <!-- Mandatory for compiling partial JDK sources against a snapshot; should NEVER be used for any other purpose: -->
 133                     <compilerarg value="-XDignore.symbol.file=true"/>
 134                     <compilerarg line="${javac.options}"/>
 135                 </javac>
 136             </sequential>
 137         </macrodef>
 138         <available property="have.closed.src" file="${root}/src/closed/share/classes" type="dir"/>
 139     </target>
 140 
 141     <target name="-pre-compile">
 142         <!-- Empty placeholder for easier customization. -->
 143         <!-- You can override this target in the ../build.xml file. -->
 144     </target>
 145     <target name="-post-compile">
 146         <!-- Empty placeholder for easier customization. -->
 147         <!-- You can override this target in the ../build.xml file. -->
 148     </target>
 149 
 150     <target name="build" depends="-init,-pre-compile,-build-ant,-build-make,-post-compile" description="Build sources."/>
 151     <target name="-do-build-ant">
 152         <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}"/>
 153         <mkdir dir="${gensrc.dir}"/>
 154         <jdk-javac srcdir="${share.src.dir}:${platform.src.dir}:${gensrc.dir}"/>
 155         <property name="copy.excludes" value="**/*.java,**/package.html,**/doc-files/"/>
 156         <copy todir="${classes.dir}">
 157             <fileset dir="${share.src.dir}" includes="${includes}" excludes="${excludes},${copy.excludes}"/>
 158             <fileset dir="${platform.src.dir}" includes="${includes}" excludes="${excludes},${copy.excludes}"/>
 159         </copy>
 160         <antcall target="-maybe-do-build-ant-closed"/>
 161     </target>
 162     <target name="-maybe-do-build-ant-closed" if="have.closed.src">
 163         <jdk-javac srcdir="${root}/src/closed/share/classes"/>
 164         <copy todir="${classes.dir}">
 165             <fileset dir="${root}/src/closed/share/classes" includes="${includes}" excludes="${excludes},${copy.excludes}"/>
 166         </copy>
 167     </target>
 168     <target name="-build-ant" depends="-init" unless="use.make">
 169         <antcall target="-do-build-ant"/>
 170     </target>
 171     <target name="-build-make" depends="-init" if="use.make"> <!-- override me to call <make-run> -->
 172         <echo level="info">No make target defined for this project; falling back to simple Java build</echo>
 173         <antcall target="-do-build-ant"/>
 174     </target>
 175 
 176     <target name="clean" depends="-init,-clean-docs-tests,-clean-ant,-clean-make" description="Clean build products."/>
 177     <target name="-do-clean-ant">
 178         <!-- XXX first s/\.java/.class/g in includes and excludes! -->
 179         <delete dir="${classes.dir}" includes="${includes}" excludes="${excludes}" includeemptydirs="true"/>
 180         <delete dir="${gensrc.dir}" includes="${includes}" excludes="${excludes}" includeemptydirs="true"/>
 181         <delete dir="${build.dir}/depcache"/>
 182     </target>
 183     <target name="-clean-docs-tests">
 184         <delete dir="${javadoc.dir}" includeemptydirs="true"/>
 185         <delete dir="${jtreg.dir}" includeemptydirs="true"/>
 186     </target>
 187     <target name="-clean-ant" depends="-init" unless="use.make">
 188         <antcall target="-do-clean-ant"/>
 189     </target>
 190     <target name="-clean-make" depends="-init" if="use.make"> <!-- override me to call <make-run> -->
 191         <echo level="info">No make clean target defined for this project; falling back to simple Java clean</echo>
 192         <antcall target="-do-clean-ant"/>
 193     </target>
 194 
 195     <target name="compile-single" depends="-init">
 196         <fail unless="srcdir">Must set property 'srcdir'</fail>
 197         <fail unless="includes">Must set property 'includes'</fail>
 198         <jdk-javac srcdir="${srcdir}" includes="${includes}" excludes=""/>
 199     </target>
 200     <target name="debug-fix" depends="-init" if="netbeans.home">
 201         <fail unless="class">Must set property 'class'</fail>
 202         <antcall target="compile-single">
 203             <param name="includes" value="${class}.java"/>
 204         </antcall>
 205         <nbjpdareload>
 206             <fileset dir="${classes.dir}">
 207                 <include name="${class}.class"/>
 208             </fileset>
 209         </nbjpdareload>
 210     </target>
 211 
 212     <target name="-taskdef-jtreg" depends="-init" unless="jtreg.defined">
 213         <fail message="Cannot locate jtreg: please set jtreg.home to its location">
 214             <condition>
 215                 <not>
 216                     <isset property="jtreg.home"/>
 217                 </not>
 218             </condition>
 219         </fail>
 220         <fail message="jtreg is not installed in ${jtreg.home}">
 221             <condition>
 222                 <not>
 223                     <and>
 224                         <available file="${jtreg.home}/lib/jtreg.jar"/>
 225                         <available file="${jtreg.home}/lib/javatest.jar"/>
 226                     </and>
 227                 </not>
 228             </condition>
 229         </fail>
 230         <taskdef name="jtreg" classname="com.sun.javatest.regtest.Main$$Ant">
 231             <classpath>
 232                 <pathelement location="${jtreg.home}/lib/jtreg.jar"/>
 233                 <pathelement location="${jtreg.home}/lib/javatest.jar"/>
 234             </classpath>
 235         </taskdef>
 236         <property name="jtreg.defined" value="true"/>
 237     </target>
 238     <target name="-check-tests-defined" unless="jtreg.tests">
 239         <fail>You must define jtreg.tests to select some tests to run.</fail>
 240     </target>
 241     <target name="-jtreg-setup">
 242         <property name="jtreg.vm.options" value=""/> <!-- default, can be overridden per user or per project -->
 243         <property name="jtreg.options" value=""/> <!-- default, can be overridden per user or per project -->
 244         <property name="jtreg.samevm" value="false"/>  <!-- default, can be overridden per user or per project -->
 245     </target>
 246     <target name="-jtreg-ant" unless="use.make">
 247         <jtreg dir="${root}/test" samevm="${jtreg.samevm}" verbose="summary"
 248                jdk="${bootstrap.jdk}"
 249                failonerror="false" resultproperty="jtreg.result"
 250                javacoptions="-g"
 251                vmoptions="-Xbootclasspath/p:${classes.dir} ${jtreg.vm.options}"
 252                reportDir="${jtreg.dir}/JTreport"
 253                workDir="${jtreg.dir}/JTwork"
 254                includes="${jtreg.tests}">
 255             <arg line="${jtreg.options}"/>
 256         </jtreg>
 257     </target>
 258     <target name="-jtreg-make" if="use.make">
 259         <jtreg dir="${root}/test" samevm="${jtreg.samevm}" verbose="summary"
 260                failonerror="false" resultproperty="jtreg.result"
 261                jdk="${build.dir}"
 262                vmoptions="${jtreg.vm.options}"
 263                javacoptions="-g"
 264                reportDir="${jtreg.dir}/JTreport"
 265                workDir="${jtreg.dir}/JTwork"
 266                includes="${jtreg.tests}">
 267             <arg line="${jtreg.options}"/>
 268         </jtreg>
 269     </target>
 270     <target name="-pre-jtreg">
 271         <!-- Empty placeholder for easier customization. -->
 272         <!-- You can override this target in the ../build.xml file. -->
 273     </target>
 274     <target name="-post-jtreg">
 275         <!-- Empty placeholder for easier customization. -->
 276         <!-- You can override this target in the ../build.xml file. -->
 277     </target>
 278     <target name="-jtreg" depends="-init,-pre-jtreg,-taskdef-jtreg,-check-tests-defined,-jtreg-setup,-jtreg-make,-jtreg-ant,-post-jtreg">
 279         <property name="jtreg.report" location="${jtreg.dir}/JTreport/html/report.html"/>
 280         <condition property="jtreg.passed">
 281             <equals arg1="${jtreg.result}" arg2="0"/>
 282         </condition>
 283     </target>
 284     <target name="test" depends="jtreg"/> <!-- Allow use of existing finger muscle memory from command line. -->
 285     <target name="jtreg" depends="-jtreg" description="Run jtreg-based tests." unless="jtreg.passed">
 286         <fail>${jtreg.report}: some tests failed.</fail>
 287     </target>
 288     <target name="jtreg-nb" depends="-jtreg" if="netbeans.home" unless="jtreg.passed">
 289         <makeurl file="${jtreg.report}" property="jtreg.report.url"/>
 290         <nbbrowse url="${jtreg.report.url}#Results"/>
 291         <fail>Some tests failed; see report for details.</fail>
 292     </target>
 293     <target name="jtreg-debug-nb" depends="-init" if="netbeans.home">
 294         <!-- No package decls -> "source root" is immediately containing dir -->
 295         <dirname file="${root}/test/${jtreg.tests}" property="test.dir"/>
 296         <nbjpdastart addressproperty="jpda.address" name="${ant.project.name}" transport="dt_socket">
 297             <bootclasspath>
 298                 <pathelement location="${classes.dir}"/>
 299                 <pathelement location="${bootstrap.jdk}/jre/lib/rt.jar"/>
 300             </bootclasspath>
 301             <classpath>
 302                 <pathelement location="${jtreg.dir}/JTwork/classes"/>
 303             </classpath>
 304             <sourcepath>
 305                 <pathelement location="${share.src.dir}"/>
 306                 <pathelement location="${platform.src.dir}"/>
 307                 <pathelement location="${root}/src/closed/share/classes"/>
 308                 <pathelement location="${test.dir}"/>
 309             </sourcepath>
 310         </nbjpdastart>
 311         <antcall target="-jtreg">
 312             <param name="jtreg.vm.options" value="-Xdebug -Xrunjdwp:transport=dt_socket,address=${jpda.address}"/>
 313         </antcall>
 314     </target>
 315 
 316     <target name="debug" depends="-init" if="netbeans.home">
 317         <!-- No package decls -> "source root" is immediately containing dir -->
 318         <dirname file="${root}/test/${jtreg.tests}" property="test.dir"/>
 319         <nbjpdastart addressproperty="jpda.address" name="${ant.project.name}" transport="dt_socket">
 320             <bootclasspath>
 321                 <pathelement location="${classes.dir}"/>
 322                 <pathelement location="${bootstrap.jdk}/jre/lib/rt.jar"/>
 323             </bootclasspath>
 324             <sourcepath>
 325                 <pathelement location="${share.src.dir}"/>
 326                 <pathelement location="${platform.src.dir}"/>
 327                 <pathelement location="${root}/src/closed/share/classes"/>
 328                 <pathelement location="${test.dir}"/>
 329             </sourcepath>
 330         </nbjpdastart>
 331         <antcall target="run">
 332             <param name="jvm.args" value="-Xdebug -Xrunjdwp:transport=dt_socket,address=${jpda.address}"/>
 333         </antcall>
 334     </target>
 335 
 336     <target name="javadoc" depends="-init" description="Build basic Javadoc for public packages.">
 337         <property name="javadoc.options" value=""/> <!-- default, can be overridden per user or per project -->
 338         <!-- Note: even with this default value, includes/excludes
 339          from share.src.dir get javadoc'd; see packageset below -->
 340         <property name="javadoc.packagenames" value="none"/> <!-- default, can be overridden per user or per project -->
 341         <javadoc destdir="${javadoc.dir}" source="1.8"
 342             windowtitle="UNOFFICIAL" failonerror="true" use="true"
 343             author="false" version="false"
 344             packagenames="${javadoc.packagenames}">
 345             <header><![CDATA[<strong>Unofficial Javadoc</strong> generated from developer sources for preview purposes only]]></header>
 346             <arg line="${javadoc.options}"/>
 347             <bootclasspath>
 348                 <path location="${bootstrap.jdk}/jre/lib/rt.jar"/>
 349                 <path location="${classes.dir}"/>
 350             </bootclasspath>
 351             <sourcepath>
 352                 <pathelement location="${share.src.dir}"/>
 353                 <pathelement location="${platform.src.dir}"/>
 354                 <pathelement location="${root}/src/closed/share/classes"/>
 355                 <pathelement location="${root}/src/share/doc/stub"/>
 356             </sourcepath>
 357             <!-- XXX just <fileset> (restricted further to **/*.java) and no <packageset> -->
 358             <!-- means that {@link some.package} will not work, which is no good. -->
 359             <!-- (It correctly skips excluded single classes, but not if packageset is also included, -->
 360             <!-- which also causes duplicates in the class index for included files.) -->
 361             <packageset dir="${share.src.dir}" includes="${includes}" excludes="${excludes}">
 362                 <or>
 363                     <filename name="java/"/>
 364                     <filename name="javax/"/>
 365                     <filename name="org/ietf/jgss/"/>
 366                     <filename name="org/omg/"/>
 367                     <filename name="org/w3c/"/>
 368                     <filename name="org/xml/sax/"/>
 369                 </or>
 370             </packageset>
 371         </javadoc>
 372     </target>
 373     <target name="javadoc-nb" depends="javadoc" if="netbeans.home">
 374         <nbbrowse file="${javadoc.dir}/index.html"/>
 375     </target>
 376 
 377 </project>