make/langtools/build.xml
changeset 47216 71c04702a3d5
parent 44461 8e5061e5b34b
child 47217 72e3ae9a25eb
equal deleted inserted replaced
47215:4ebc2e2fb97c 47216:71c04702a3d5
       
     1 <?xml version="1.0" encoding="UTF-8"?>
       
     2 <!--
       
     3   ~ Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
       
     4   ~ DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       
     5   ~
       
     6   ~ This code is free software; you can redistribute it and/or modify it
       
     7   ~ under the terms of the GNU General Public License version 2 only, as
       
     8   ~ published by the Free Software Foundation.  Oracle designates this
       
     9   ~ particular file as subject to the "Classpath" exception as provided
       
    10   ~ by Oracle in the LICENSE file that accompanied this code.
       
    11   ~
       
    12   ~ This code is distributed in the hope that it will be useful, but WITHOUT
       
    13   ~ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
       
    14   ~ FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
       
    15   ~ version 2 for more details (a copy is included in the LICENSE file that
       
    16   ~ accompanied this code).
       
    17   ~
       
    18   ~ You should have received a copy of the GNU General Public License version
       
    19   ~ 2 along with this work; if not, write to the Free Software Foundation,
       
    20   ~ Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
       
    21   ~
       
    22   ~ Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
       
    23   ~ or visit www.oracle.com if you need additional information or have any
       
    24   ~ questions.
       
    25   -->
       
    26 
       
    27 <!--
       
    28  This is a convenience build file supporting development in the langtools
       
    29  repository. It can be run either standalone, or from IDEs. This build script
       
    30  is for a developer use only, it is not used to build the production version
       
    31  of javac or other langtools tools.
       
    32 
       
    33  External dependencies are specified via properties. These can be given
       
    34  on the command line, or by providing a local build.properties file.
       
    35  (They can also be edited into make/build.properties, although that is not
       
    36  recommended.)  At a minimum, langtools.jdk.home must be set to the installed
       
    37  location of the version of JDK used to build this repository. Additional
       
    38  properties may be required, depending on the targets that are built.
       
    39  For example, to run any of the jtreg tests you must set jtreg.home.
       
    40 
       
    41  The output of the build is as follows:
       
    42 
       
    43  build
       
    44    |-bin (scripts to invoke various tools, javac, javah etc.)
       
    45    |-genrsc (generated sources - i.e. properties)
       
    46    |-modules (compiled classes in a modular layout)
       
    47    |-jtreg (test work/results)
       
    48    |-toolclasses (tools used for building - like the property compiler)
       
    49 
       
    50  This file is organized into sections as follows:
       
    51  - global property definitions
       
    52  - primary top level targets (cleaning, building)
       
    53  - utility definitions
       
    54  -->
       
    55 
       
    56 <project name="langtools" default="build" basedir="..">
       
    57     <!--
       
    58     **** Global property definitions.
       
    59     -->
       
    60 
       
    61     <!-- The following locations can be used to override default property values. -->
       
    62 
       
    63     <!-- Use this location for customizations specific to this instance of this workspace -->
       
    64     <property file="build.properties"/>
       
    65 
       
    66     <!-- Use this location for customizations common to all OpenJDK langtools workspaces -->
       
    67     <property file="${user.home}/.openjdk/${ant.project.name}-build.properties"/>
       
    68 
       
    69     <!-- Use this location for customizations common to all OpenJDK workspaces -->
       
    70     <property file="${user.home}/.openjdk/build.properties"/>
       
    71 
       
    72     <!-- Convenient shorthands for standard locations within the workspace. -->
       
    73     <property name="src.dir" location="src"/>
       
    74     <property name="test.dir" location="test"/>
       
    75     <property name="make.dir" location="make"/>
       
    76     <property name="make.conf.dir" location="${make.dir}/conf"/>
       
    77     <property name="make.tools.dir" location="${make.dir}/tools"/>
       
    78     <property name="build.dir" location="build"/>
       
    79     <property name="build.modules" location="${build.dir}/modules"/>
       
    80     <property name="build.gensrc" location="${build.dir}/gensrc"/>
       
    81     <property name="build.tools" location="${build.dir}/toolclasses"/>
       
    82     <property name="build.bin" location="${build.dir}/bin"/>
       
    83     <property name="build.jtreg" location="${build.dir}/jtreg"/>
       
    84     <property name="build.prevsrc" location="${build.dir}/prevsrc"/>
       
    85 
       
    86     <pathconvert property="modules.names" pathsep=",">
       
    87         <globmapper from="${src.dir}/*" to="*" handledirsep="yes"/>
       
    88         <dirset dir="${src.dir}" includes="*.*"/>
       
    89     </pathconvert>
       
    90 
       
    91     <pathconvert property="xpatch.rest" pathsep=" --patch-module=">
       
    92         <scriptmapper language="javascript">
       
    93             fs = project.getProperty("file.separator");
       
    94             path = project.getProperty("build.modules");
       
    95             mod = source.substr(source.lastIndexOf(fs)+1);
       
    96             self.addMappedName(mod + "=\"" + path + fs + mod + "\"");
       
    97         </scriptmapper>
       
    98         <dirset dir="${src.dir}" includes="*.*"/>
       
    99     </pathconvert>
       
   100 
       
   101     <pathconvert property="xpatch.noquotes.rest" pathsep=" --patch-module=">
       
   102         <scriptmapper language="javascript">
       
   103             fs = project.getProperty("file.separator");
       
   104             path = project.getProperty("build.modules");
       
   105             mod = source.substr(source.lastIndexOf(fs)+1);
       
   106             self.addMappedName(mod + "=" + path + fs + mod);
       
   107         </scriptmapper>
       
   108         <dirset dir="${src.dir}" includes="*.*"/>
       
   109     </pathconvert>
       
   110 
       
   111     <property name="xpatch.cmd" value="--patch-module=${xpatch.rest}"/>
       
   112     <property name="xpatch.noquotes.cmd" value="--patch-module=${xpatch.noquotes.rest}"/>
       
   113 
       
   114     <!-- java.marker is set to a marker file to check for within a Java install dir.
       
   115          The best file to check for across Solaris/Linux/Windows/MacOS is one of the
       
   116          executables; regrettably, that is OS-specific. -->
       
   117     <condition property="java.marker" value="bin/java">
       
   118         <os family="unix"/>
       
   119     </condition>
       
   120     <condition property="java.marker" value="bin/java.exe">
       
   121         <os family="windows"/>
       
   122     </condition>
       
   123 
       
   124     <!-- Standard property values, if not overriden by earlier settings. -->
       
   125     <property file="${make.dir}/build.properties"/>
       
   126 
       
   127     <condition property="langtools.jdk.home" value="${jdk.home}">
       
   128         <isset property="jdk.home" />
       
   129     </condition>
       
   130 
       
   131     <!-- launcher.java is used in the launcher scripts provided to run
       
   132         the tools' jar files.  If it has not already been set, then
       
   133         default it to use ${langtools.jdk.home}, if available, otherwise
       
   134         quietly default to simply use "java". -->
       
   135     <condition property="launcher.java"
       
   136         value="${langtools.jdk.home}/bin/java" else="java">
       
   137         <isset property="langtools.jdk.home"/>
       
   138     </condition>
       
   139 
       
   140     <!--
       
   141         **** Check targets
       
   142     -->
       
   143 
       
   144     <target name="-def-check">
       
   145       <macrodef name="check">
       
   146           <attribute name="name"/>
       
   147           <attribute name="property"/>
       
   148           <attribute name="marker" default=""/>
       
   149             <sequential>
       
   150                 <fail message="Cannot locate @{name}: please set @{property} to its location">
       
   151                     <condition>
       
   152                         <not>
       
   153                             <isset property="@{property}"/>
       
   154                         </not>
       
   155                     </condition>
       
   156                 </fail>
       
   157                 <fail message="@{name} is not installed in ${@{property}}">
       
   158                     <condition>
       
   159                         <and>
       
   160                             <not>
       
   161                                 <equals arg1="@{marker}" arg2=""/>
       
   162                             </not>
       
   163                             <not>
       
   164                                 <available file="${@{property}}/@{marker}"/>
       
   165                             </not>
       
   166                         </and>
       
   167                     </condition>
       
   168                 </fail>
       
   169             </sequential>
       
   170         </macrodef>
       
   171     </target>
       
   172 
       
   173     <target name="-check-langtools.jdk.home" depends="-def-check">
       
   174         <check name="target java" property="langtools.jdk.home" marker="${java.marker}"/>
       
   175     </target>
       
   176 
       
   177     <target name="-check-jtreg.home" depends="-def-check">
       
   178         <check name="jtreg" property="jtreg.home" marker="lib/jtreg.jar"/>
       
   179     </target>
       
   180 
       
   181     <!--
       
   182         **** Primary targets
       
   183     -->
       
   184 
       
   185     <target name="clean" description="Delete all generated files">
       
   186         <delete dir="${build.dir}"/>
       
   187     </target>
       
   188 
       
   189     <target name="build" depends="build-all-tools"/>
       
   190 
       
   191     <target name="-prepare-build" depends="-check-langtools.jdk.home">
       
   192         <mkdir dir="${build.modules}"/>
       
   193         <mkdir dir="${build.tools}"/>
       
   194         <mkdir dir="${build.gensrc}"/>
       
   195         <mkdir dir="${build.bin}"/>
       
   196         <mkdir dir="${build.prevsrc}"/>
       
   197     </target>
       
   198 
       
   199     <target name="generate-sources-internal">
       
   200         <basename property="module.name" file="${basedir}"/>
       
   201         <pparse destdir="${build.gensrc}/${module.name}" includes="${langtools.resource.includes}">
       
   202             <src path="./share/classes"/>
       
   203         </pparse>
       
   204         <pcompile destdir="${build.gensrc}/${module.name}" includes="**/*.properties">
       
   205             <src path="./share/classes"/>
       
   206         </pcompile>
       
   207     </target>
       
   208 
       
   209     <target name="generate-sources"  depends="-prepare-build,-def-pparse,-def-pcompile">
       
   210         <subant inheritall="true" target="generate-sources-internal" genericantfile="${make.dir}/build.xml">
       
   211               <dirset dir="${src.dir}" includes="*.*"/>
       
   212         </subant>
       
   213     </target>
       
   214 
       
   215     <target name="build-all-classes" depends="generate-sources">
       
   216         <exec executable="${langtools.jdk.home}/bin/javac" failonerror="true">
       
   217             <arg line="-source ${javac.source} -target ${javac.target}" />
       
   218             <arg value="-d" />
       
   219             <arg value="${build.modules}" />
       
   220             <arg line="${javac.opts}" />
       
   221             <arg line="--module-source-path ${src.dir}${file.separator}*${file.separator}share${file.separator}classes${path.separator}${build.gensrc}" />
       
   222             <arg line="-m ${modules.names}" />
       
   223         </exec>
       
   224         <delete>
       
   225             <fileset dir="${build.modules}" includes="**/module-info.class"/>
       
   226         </delete>
       
   227     </target>
       
   228 
       
   229     <target name="build-all-tools" depends="build-all-classes, -def-build-tool">
       
   230         <build-tool name="javac"/>
       
   231         <build-tool name="javadoc"/>
       
   232         <build-tool name="javap"/>
       
   233         <build-tool name="javah"/>
       
   234         <build-tool name="jdeps"/>
       
   235         <build-tool name="sjavac"/>
       
   236         <build-tool name="jshell"/>
       
   237     </target>
       
   238 
       
   239     <target name="jtreg" depends="build-all-tools,-def-jtreg">
       
   240         <jtreg-tool name="all" tests="${jtreg.tests}"/>
       
   241     </target>
       
   242 
       
   243     <!--
       
   244     **** IDE support
       
   245     -->
       
   246 
       
   247     <target name="idea" depends="-check-langtools.jdk.home">
       
   248         <mkdir dir=".idea"/>
       
   249         <copy todir=".idea" >
       
   250             <fileset dir="make/intellij">
       
   251                <exclude name="**/src/**"/>
       
   252                <exclude name="**/utils/**"/>
       
   253             </fileset>
       
   254         </copy>
       
   255         <condition property="idea.jtreg.home" value="${jtreg.home}" else = "[jtreg.home]">
       
   256             <isset property="jtreg.home"/>
       
   257         </condition>
       
   258         <condition property="idea.target.jdk" value="${langtools.jdk.home}" else = "$JDKPath$">
       
   259             <isset property="langtools.jdk.home"/>
       
   260         </condition>
       
   261         <replace file=".idea/ant.xml" token="@IDEA_TARGET_JDK@" value="${idea.target.jdk}"/>
       
   262         <replace dir=".idea/runConfigurations" token="@IDEA_TARGET_JDK@" value="${idea.target.jdk}"/>
       
   263         <replace dir=".idea/runConfigurations" token="@XPATCH@" value="${xpatch.cmd}"/>
       
   264         <replace file=".idea/misc.xml" token="@IDEA_JTREG_HOME@" value="${idea.jtreg.home}"/>
       
   265         <replace file=".idea/misc.xml" token="@IDEA_TARGET_JDK@" value="${idea.target.jdk}"/>
       
   266         <replace file=".idea/misc.xml" token="@XPATCH@" value="${xpatch.cmd}"/>
       
   267         <mkdir dir=".idea/classes"/>
       
   268         <javac source="${javac.build.source}"
       
   269                target="${javac.build.target}"
       
   270                srcdir="make/intellij/src"
       
   271                destdir=".idea/classes"/>
       
   272     </target>
       
   273 
       
   274     <!--
       
   275         **** Utility definitions
       
   276     -->
       
   277 
       
   278     <target name="-def-pparse">
       
   279         <copy todir="${build.tools}/propertiesparser" >
       
   280             <fileset dir="${make.tools.dir}/propertiesparser" includes="**/resources/**"/>
       
   281         </copy>
       
   282         <javac source="${javac.build.source}"
       
   283                target="${javac.build.target}"
       
   284                srcdir="${make.tools.dir}"
       
   285                includes="propertiesparser/* anttasks/PropertiesParser* anttasks/PathFileSet*"
       
   286                destdir="${build.tools}"
       
   287                classpath="${ant.core.lib}"
       
   288                bootclasspath="${langtools.jdk.home}/jre/lib/rt.jar"
       
   289                includeantruntime="false">
       
   290             <compilerarg line="${javac.build.opts} -XDstringConcat=inline"/>
       
   291         </javac>
       
   292         <taskdef name="pparse"
       
   293                  classname="anttasks.PropertiesParserTask"
       
   294                  classpath="${build.tools}"/>
       
   295     </target>
       
   296 
       
   297      <target name="-def-pcompile">
       
   298         <javac
       
   299                source="${javac.build.source}"
       
   300                target="${javac.build.target}"
       
   301                srcdir="${make.tools.dir}"
       
   302                includes="compileproperties/* anttasks/CompileProperties* anttasks/PathFileSet*"
       
   303                destdir="${build.dir}/toolclasses/"
       
   304                classpath="${ant.core.lib}"
       
   305                includeantruntime="false">
       
   306             <compilerarg line="${javac.build.opts} -XDstringConcat=inline"/>
       
   307         </javac>
       
   308         <taskdef name="pcompile"
       
   309                  classname="anttasks.CompilePropertiesTask"
       
   310                  classpath="${build.tools}"/>
       
   311     </target>
       
   312 
       
   313     <target name="-def-build-tool">
       
   314         <macrodef name="build-tool">
       
   315             <attribute name="name"/>
       
   316             <attribute name="compilation.kind" default=""/>
       
   317             <attribute name="bin.dir" default="${build.bin}"/>
       
   318             <attribute name="java" default="${launcher.java}"/>
       
   319             <attribute name="main.class" default="${tool.@{name}.main.class}"/>
       
   320             <attribute name="xpatch" default="${xpatch.cmd}"/>
       
   321             <sequential>
       
   322                 <mkdir dir="@{bin.dir}"/>
       
   323                 <copy file="${make.dir}/launcher.sh-template" tofile="@{bin.dir}/@{name}">
       
   324                     <filterset begintoken="#" endtoken="#">
       
   325                         <filter token="PROGRAM" value="@{main.class}"/>
       
   326                         <filter token="TARGET_JAVA" value="@{java}"/>
       
   327                         <filter token="PS" value="${path.separator}"/>
       
   328                         <filter token="XPATCH" value="${xpatch.cmd}"/>
       
   329                     </filterset>
       
   330                 </copy>
       
   331                 <chmod file="@{bin.dir}/@{name}" perm="ugo+rx"/>
       
   332             </sequential>
       
   333         </macrodef>
       
   334     </target>
       
   335 
       
   336     <target name="-def-jtreg" unless="jtreg.defined" depends="-check-jtreg.home,-check-langtools.jdk.home">
       
   337         <taskdef name="jtreg" classname="com.sun.javatest.regtest.Main$$Ant">
       
   338             <classpath>
       
   339                 <pathelement location="${jtreg.home}/lib/jtreg.jar"/>
       
   340                 <pathelement location="${jtreg.home}/lib/javatest.jar"/>
       
   341             </classpath>
       
   342         </taskdef>
       
   343         <macrodef name="jtreg-tool">
       
   344             <attribute name="name"/>
       
   345             <attribute name="tests"/>
       
   346             <attribute name="jdk" default="${langtools.jdk.home}"/>
       
   347             <attribute name="agentvm" default="true"/>
       
   348             <attribute name="verbose" default="${default.jtreg.verbose}"/>
       
   349             <attribute name="options" default="${other.jtreg.options}"/>
       
   350             <attribute name="ignore" default="-keywords:!ignore -exclude:${test.dir}/ProblemList.txt"/>
       
   351             <attribute name="jpda.jvmargs" default=""/>
       
   352             <attribute name="extra.jvmargs" default=""/>
       
   353             <attribute name="build.modules" default="${build.modules}"/>
       
   354             <sequential>
       
   355                 <property name="coverage.options" value=""/>              <!-- default -->
       
   356                 <property name="coverage.classpath" value=""/>            <!-- default -->
       
   357                 <property name="default.jtreg.verbose" value="summary"/>  <!-- default -->
       
   358                 <property name="other.jtreg.options" value=""/>           <!-- default -->
       
   359                 <property name="jtreg.classfiles.to.modules" value="@{agentvm}"/>
       
   360                 <jtreg
       
   361                     dir="${test.dir}"
       
   362                     workDir="${build.jtreg}/@{name}/work"
       
   363                     reportDir="${build.jtreg}/@{name}/report"
       
   364                     jdk="@{jdk}"
       
   365                     agentvm="@{agentvm}" verbose="@{verbose}"
       
   366                     failonerror="false" resultproperty="jtreg.@{name}.result"
       
   367                     vmoptions="${coverage.options} @{extra.jvmargs} ${xpatch.noquotes.cmd}">
       
   368                     <arg value="-debug:@{jpda.jvmargs}"/>
       
   369                     <arg line="@{ignore}"/>
       
   370                     <arg line="@{options}"/>
       
   371                     <arg line="@{tests}"/>
       
   372                 </jtreg>
       
   373                 <!-- the next two properties are for convenience, when only
       
   374                      a single instance of jtreg will be invoked. -->
       
   375                 <condition property="jtreg.passed">
       
   376                     <equals arg1="${jtreg.@{name}.result}" arg2="0"/>
       
   377                 </condition>
       
   378                 <property name="jtreg.report" value="${build.jtreg}/@{name}/report"/>
       
   379             </sequential>
       
   380         </macrodef>
       
   381         <property name="jtreg.defined" value="true"/>
       
   382     </target>
       
   383 </project>