view langtools/make/build.xml @ 39177:9d13e7c2d65e

8159834: Add some support for jtreg test headers in IntelliJ langtools project Summary: Add live templates to help creation of jtreg tests Reviewed-by: jlahoda
author mcimadamore
date Tue, 21 Jun 2016 15:31:08 +0100
parents a1c0c73078b3
children 722c82994682
line wrap: on
line source
<?xml version="1.0" encoding="UTF-8"?>
  ~ Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
  ~ 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.  Oracle designates this
  ~ particular file as subject to the "Classpath" exception as provided
  ~ by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  ~ or visit if you need additional information or have any
  ~ questions.

 This is a convenience build file supporting development in the langtools
 repository. It can be run either standalone, or from IDEs. This build script
 is for a developer use only, it is not used to build the production version
 of javac or other langtools tools.

 External dependencies are specified via properties. These can be given
 on the command line, or by providing a local file.
 (They can also be edited into make/, although that is not
 recommended.)  At a minimum, langtools.jdk.home must be set to the installed
 location of the version of JDK used to build this repository. Additional
 properties may be required, depending on the targets that are built.
 For example, to run any of the jtreg tests you must set jtreg.home.

 The output of the build is as follows:

   |-bin (scripts to invoke various tools, javac, javah etc.)
   |-genrsc (generated sources - i.e. properties)
   |-modules (compiled classes in a modular layout)
   |-jtreg (test work/results)
   |-toolclasses (tools used for building - like the property compiler)

 This file is organized into sections as follows:
 - global property definitions
 - primary top level targets (cleaning, building)
 - utility definitions

<project name="langtools" default="build" basedir="..">
    **** Global property definitions.

    <!-- The following locations can be used to override default property values. -->

    <!-- Use this location for customizations specific to this instance of this workspace -->
    <property file=""/>

    <!-- Use this location for customizations common to all OpenJDK langtools workspaces -->
    <property file="${user.home}/.openjdk/${}"/>

    <!-- Use this location for customizations common to all OpenJDK workspaces -->
    <property file="${user.home}/.openjdk/"/>

    <!-- Convenient shorthands for standard locations within the workspace. -->
    <property name="src.dir" location="src"/>
    <property name="test.dir" location="test"/>
    <property name="make.dir" location="make"/>
    <property name="make.conf.dir" location="${make.dir}/conf"/>
    <property name="" location="${make.dir}/tools"/>
    <property name="build.dir" location="build"/>
    <property name="build.modules" location="${build.dir}/modules"/>
    <property name="build.gensrc" location="${build.dir}/gensrc"/>
    <property name="" location="${build.dir}/toolclasses"/>
    <property name="build.bin" location="${build.dir}/bin"/>
    <property name="build.jtreg" location="${build.dir}/jtreg"/>
    <property name="build.prevsrc" location="${build.dir}/prevsrc"/>

    <pathconvert property="modules.names" pathsep=",">
        <globmapper from="${src.dir}/*" to="*" />
        <dirset dir="${src.dir}" includes="*.*"/>

    <pathconvert property="" pathsep=" -Xpatch:">
        <regexpmapper from="${file.separator}([^${file.separator}]+)$" to='\1="${build.modules}${file.separator}\1"' />
        <dirset dir="${src.dir}" includes="*.*"/>

    <pathconvert property="" pathsep=" -Xpatch:">
        <regexpmapper from="${file.separator}([^${file.separator}]+)$" to="\1=${build.modules}${file.separator}\1" />
        <dirset dir="${src.dir}" includes="*.*"/>

    <property name="xpatch.cmd" value="-Xpatch:${}"/>
    <property name="xpatch.noquotes.cmd" value="-Xpatch:${}"/>

    <!-- java.marker is set to a marker file to check for within a Java install dir.
         The best file to check for across Solaris/Linux/Windows/MacOS is one of the
         executables; regrettably, that is OS-specific. -->
    <condition property="java.marker" value="bin/java">
        <os family="unix"/>
    <condition property="java.marker" value="bin/java.exe">
        <os family="windows"/>

    <!-- Standard property values, if not overriden by earlier settings. -->
    <property file="${make.dir}/"/>

    <condition property="langtools.jdk.home" value="${jdk.home}">
        <isset property="jdk.home" />

    <!-- is used in the launcher scripts provided to run
        the tools' jar files.  If it has not already been set, then
        default it to use ${langtools.jdk.home}, if available, otherwise
        quietly default to simply use "java". -->
    <condition property=""
        value="${langtools.jdk.home}/bin/java" else="java">
        <isset property="langtools.jdk.home"/>

        **** Check targets

    <target name="-def-check">
      <macrodef name="check">
          <attribute name="name"/>
          <attribute name="property"/>
          <attribute name="marker" default=""/>
                <fail message="Cannot locate @{name}: please set @{property} to its location">
                            <isset property="@{property}"/>
                <fail message="@{name} is not installed in ${@{property}}">
                                <equals arg1="@{marker}" arg2=""/>
                                <available file="${@{property}}/@{marker}"/>

    <target name="-check-langtools.jdk.home" depends="-def-check">
        <check name="target java" property="langtools.jdk.home" marker="${java.marker}"/>

    <target name="-check-jtreg.home" depends="-def-check">
        <check name="jtreg" property="jtreg.home" marker="lib/jtreg.jar"/>

        **** Primary targets

    <target name="clean" description="Delete all generated files">
        <delete dir="${build.dir}"/>

    <target name="build" depends="build-all-tools"/>

    <target name="-prepare-build" depends="-check-langtools.jdk.home">
        <mkdir dir="${build.modules}"/>
        <mkdir dir="${}"/>
        <mkdir dir="${build.gensrc}"/>
        <mkdir dir="${build.bin}"/>
        <mkdir dir="${build.prevsrc}"/>

    <target name="generate-sources-internal">
        <basename property="" file="${basedir}"/>
        <pparse destdir="${build.gensrc}/${}" includes="${langtools.resource.includes}">
            <src path="./share/classes"/>
        <pcompile destdir="${build.gensrc}/${}" includes="**/*.properties">
            <src path="./share/classes"/>

    <target name="generate-sources"  depends="-prepare-build,-def-pparse,-def-pcompile">
        <subant inheritall="true" target="generate-sources-internal" genericantfile="${make.dir}/build.xml">
              <dirset dir="${src.dir}" includes="*.*"/>

    <target name="build-all-classes" depends="generate-sources">
        <exec executable="${langtools.jdk.home}/bin/javac" failonerror="true">
            <arg line="-source ${javac.source} -target ${}" />
            <arg value="-d" />
            <arg value="${build.modules}" />
            <arg line="${javac.opts} -modulesourcepath ${src.dir}${file.separator}*${file.separator}share${file.separator}classes:${build.gensrc} -m ${modules.names}" />
            <fileset dir="${build.modules}" includes="**/module-info.class"/>

    <target name="build-all-tools" depends="build-all-classes, -def-build-tool">
        <build-tool name="javac"/>
        <build-tool name="javadoc"/>
        <build-tool name="javap"/>
        <build-tool name="javah"/>
        <build-tool name="jdeps"/>
        <build-tool name="sjavac"/>
        <build-tool name="jshell"/>

    <target name="jtreg" depends="build-all-tools,-def-jtreg">
        <jtreg-tool name="all" tests="${jtreg.tests}"/>

    **** IDE support

    <target name="idea" depends="-check-langtools.jdk.home">
        <mkdir dir=".idea"/>
        <copy todir=".idea" >
            <fileset dir="make/intellij">
               <exclude name="**/src/**"/>
               <exclude name="**/utils/**"/>
        <condition property="idea.jtreg.home" value="${jtreg.home}" else = "[jtreg.home]">
            <isset property="jtreg.home"/>
        <condition property="" value="${langtools.jdk.home}" else = "$JDKPath$">
            <isset property="langtools.jdk.home"/>
        <replace file=".idea/ant.xml" token="@IDEA_JTREG_HOME@" value="${idea.jtreg.home}"/>
        <replace file=".idea/ant.xml" token="@IDEA_TARGET_JDK@" value="${}"/>
        <replace dir=".idea/runConfigurations" token="@IDEA_TARGET_JDK@" value="${}"/>
        <replace dir=".idea/runConfigurations" token="@XPATCH@" value="${xpatch.cmd}"/>
        <mkdir dir=".idea/classes"/>
        <javac source="${}"

        **** Utility definitions

    <target name="-def-pparse">
        <copy todir="${}/propertiesparser" >
            <fileset dir="${}/propertiesparser" includes="**/resources/**"/>
        <javac source="${}"
               includes="propertiesparser/* anttasks/PropertiesParser* anttasks/PathFileSet*"
            <compilerarg line="${javac.opts} -XDstringConcat=inline"/>
        <taskdef name="pparse"

     <target name="-def-pcompile">
               includes="compileproperties/* anttasks/CompileProperties* anttasks/PathFileSet*"
            <compilerarg line="${javac.opts} -XDstringConcat=inline"/>
        <taskdef name="pcompile"

    <target name="-def-build-tool">
        <macrodef name="build-tool">
            <attribute name="name"/>
            <attribute name="compilation.kind" default=""/>
            <attribute name="bin.dir" default="${build.bin}"/>
            <attribute name="java" default="${}"/>
            <attribute name="main.class" default="${tool.@{name}.main.class}"/>
            <attribute name="xpatch" default="${xpatch.cmd}"/>
                <mkdir dir="@{bin.dir}"/>
                <copy file="${make.dir}/" tofile="@{bin.dir}/@{name}">
                    <filterset begintoken="#" endtoken="#">
                        <filter token="PROGRAM" value="@{main.class}"/>
                        <filter token="TARGET_JAVA" value="@{java}"/>
                        <filter token="PS" value="${path.separator}"/>
                        <filter token="XPATCH" value="${xpatch.cmd}"/>
                <chmod file="@{bin.dir}/@{name}" perm="ugo+rx"/>

    <target name="-def-jtreg" unless="jtreg.defined" depends="-check-jtreg.home,-check-langtools.jdk.home">
        <taskdef name="jtreg" classname="com.sun.javatest.regtest.Main$$Ant">
                <pathelement location="${jtreg.home}/lib/jtreg.jar"/>
                <pathelement location="${jtreg.home}/lib/javatest.jar"/>
        <macrodef name="jtreg-tool">
            <attribute name="name"/>
            <attribute name="tests"/>
            <attribute name="jdk" default="${langtools.jdk.home}"/>
            <attribute name="agentvm" default="true"/>
            <attribute name="verbose" default="${default.jtreg.verbose}"/>
            <attribute name="options" default="${other.jtreg.options}"/>
            <attribute name="keywords" default="-keywords:!ignore"/>
            <attribute name="jpda.jvmargs" default=""/>
            <attribute name="extra.jvmargs" default=""/>
            <attribute name="build.modules" default="${build.modules}"/>
                <property name="coverage.options" value=""/>              <!-- default -->
                <property name="coverage.classpath" value=""/>            <!-- default -->
                <property name="default.jtreg.verbose" value="summary"/>  <!-- default -->
                <property name="other.jtreg.options" value=""/>           <!-- default -->
                <property name="" value="@{agentvm}"/>
                    agentvm="@{agentvm}" verbose="@{verbose}"
                    failonerror="false" resultproperty="jtreg.@{name}.result"
                    vmoptions="${coverage.options} @{extra.jvmargs} ${xpatch.noquotes.cmd}">
                    <arg value="-debug:@{jpda.jvmargs}"/>
                    <arg line="@{keywords}"/>
                    <arg line="@{options}"/>
                    <arg line="@{tests}"/>
                <!-- the next two properties are for convenience, when only
                     a single instance of jtreg will be invoked. -->
                <condition property="jtreg.passed">
                    <equals arg1="${jtreg.@{name}.result}" arg2="0"/>
                <property name="" value="${build.jtreg}/@{name}/report"/>
        <property name="jtreg.defined" value="true"/>