build.xml revision 3437:4344c9ad3c9d
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="*" /> 88 <dirset dir="${src.dir}" includes="*.*"/> 89 </pathconvert> 90 91 <pathconvert property="xpatch.rest" pathsep=" -Xpatch:"> 92 <regexpmapper from="${file.separator}([^${file.separator}]+)$" to='\1="${build.modules}${file.separator}\1"' /> 93 <dirset dir="${src.dir}" includes="*.*"/> 94 </pathconvert> 95 96 <pathconvert property="xpatch.noquotes.rest" pathsep=" -Xpatch:"> 97 <regexpmapper from="${file.separator}([^${file.separator}]+)$" to="\1=${build.modules}${file.separator}\1" /> 98 <dirset dir="${src.dir}" includes="*.*"/> 99 </pathconvert> 100 101 <property name="xpatch.cmd" value="-Xpatch:${xpatch.rest}"/> 102 <property name="xpatch.noquotes.cmd" value="-Xpatch:${xpatch.noquotes.rest}"/> 103 104 <!-- java.marker is set to a marker file to check for within a Java install dir. 105 The best file to check for across Solaris/Linux/Windows/MacOS is one of the 106 executables; regrettably, that is OS-specific. --> 107 <condition property="java.marker" value="bin/java"> 108 <os family="unix"/> 109 </condition> 110 <condition property="java.marker" value="bin/java.exe"> 111 <os family="windows"/> 112 </condition> 113 114 <!-- Standard property values, if not overriden by earlier settings. --> 115 <property file="${make.dir}/build.properties"/> 116 117 <condition property="langtools.jdk.home" value="${jdk.home}"> 118 <isset property="jdk.home" /> 119 </condition> 120 121 <!-- launcher.java is used in the launcher scripts provided to run 122 the tools' jar files. If it has not already been set, then 123 default it to use ${langtools.jdk.home}, if available, otherwise 124 quietly default to simply use "java". --> 125 <condition property="launcher.java" 126 value="${langtools.jdk.home}/bin/java" else="java"> 127 <isset property="langtools.jdk.home"/> 128 </condition> 129 130 <!-- 131 **** Check targets 132 --> 133 134 <target name="-def-check"> 135 <macrodef name="check"> 136 <attribute name="name"/> 137 <attribute name="property"/> 138 <attribute name="marker" default=""/> 139 <sequential> 140 <fail message="Cannot locate @{name}: please set @{property} to its location"> 141 <condition> 142 <not> 143 <isset property="@{property}"/> 144 </not> 145 </condition> 146 </fail> 147 <fail message="@{name} is not installed in ${@{property}}"> 148 <condition> 149 <and> 150 <not> 151 <equals arg1="@{marker}" arg2=""/> 152 </not> 153 <not> 154 <available file="${@{property}}/@{marker}"/> 155 </not> 156 </and> 157 </condition> 158 </fail> 159 </sequential> 160 </macrodef> 161 </target> 162 163 <target name="-check-langtools.jdk.home" depends="-def-check"> 164 <check name="target java" property="langtools.jdk.home" marker="${java.marker}"/> 165 </target> 166 167 <target name="-check-jtreg.home" depends="-def-check"> 168 <check name="jtreg" property="jtreg.home" marker="lib/jtreg.jar"/> 169 </target> 170 171 <!-- 172 **** Primary targets 173 --> 174 175 <target name="clean" description="Delete all generated files"> 176 <delete dir="${build.dir}"/> 177 </target> 178 179 <target name="build" depends="build-all-tools"/> 180 181 <target name="-prepare-build" depends="-check-langtools.jdk.home"> 182 <mkdir dir="${build.modules}"/> 183 <mkdir dir="${build.tools}"/> 184 <mkdir dir="${build.gensrc}"/> 185 <mkdir dir="${build.bin}"/> 186 <mkdir dir="${build.prevsrc}"/> 187 </target> 188 189 <target name="generate-sources-internal"> 190 <basename property="module.name" file="${basedir}"/> 191 <pparse destdir="${build.gensrc}/${module.name}" includes="${langtools.resource.includes}"> 192 <src path="./share/classes"/> 193 </pparse> 194 <pcompile destdir="${build.gensrc}/${module.name}" includes="**/*.properties"> 195 <src path="./share/classes"/> 196 </pcompile> 197 </target> 198 199 <target name="generate-sources" depends="-prepare-build,-def-pparse,-def-pcompile"> 200 <subant inheritall="true" target="generate-sources-internal" genericantfile="${make.dir}/build.xml"> 201 <dirset dir="${src.dir}" includes="*.*"/> 202 </subant> 203 </target> 204 205 <target name="build-all-classes" depends="generate-sources"> 206 <exec executable="${langtools.jdk.home}/bin/javac" failonerror="true"> 207 <arg line="-source ${javac.source} -target ${javac.target}" /> 208 <arg value="-d" /> 209 <arg value="${build.modules}" /> 210 <arg line="${javac.opts} -modulesourcepath ${src.dir}${file.separator}*${file.separator}share${file.separator}classes:${build.gensrc} -m ${modules.names}" /> 211 </exec> 212 <delete> 213 <fileset dir="${build.modules}" includes="**/module-info.class"/> 214 </delete> 215 </target> 216 217 <target name="build-all-tools" depends="build-all-classes, -def-build-tool"> 218 <build-tool name="javac"/> 219 <build-tool name="javadoc"/> 220 <build-tool name="javap"/> 221 <build-tool name="javah"/> 222 <build-tool name="jdeps"/> 223 <build-tool name="sjavac"/> 224 <build-tool name="jshell"/> 225 </target> 226 227 <target name="jtreg" depends="build-all-tools,-def-jtreg"> 228 <jtreg-tool name="all" tests="${jtreg.tests}"/> 229 </target> 230 231 <!-- 232 **** IDE support 233 --> 234 235 <target name="idea" depends="-check-langtools.jdk.home"> 236 <mkdir dir=".idea"/> 237 <copy todir=".idea" > 238 <fileset dir="make/intellij" excludes="**/src/**"/> 239 </copy> 240 <condition property="idea.jtreg.home" value="${jtreg.home}" else = "[jtreg.home]"> 241 <isset property="jtreg.home"/> 242 </condition> 243 <condition property="idea.target.jdk" value="${langtools.jdk.home}" else = "$JDKPath$"> 244 <isset property="langtools.jdk.home"/> 245 </condition> 246 <replace file=".idea/ant.xml" token="@IDEA_JTREG_HOME@" value="${idea.jtreg.home}"/> 247 <replace file=".idea/ant.xml" token="@IDEA_TARGET_JDK@" value="${idea.target.jdk}"/> 248 <replace dir=".idea/runConfigurations" token="@IDEA_TARGET_JDK@" value="${idea.target.jdk}"/> 249 <replace dir=".idea/runConfigurations" token="@XPATCH@" value="${xpatch.cmd}"/> 250 <mkdir dir=".idea/classes"/> 251 <javac source="${javac.build.source}" 252 target="${javac.build.target}" 253 srcdir="make/intellij/src" 254 destdir=".idea/classes"/> 255 </target> 256 257 <!-- 258 **** Utility definitions 259 --> 260 261 <target name="-def-pparse"> 262 <copy todir="${build.tools}/propertiesparser" > 263 <fileset dir="${make.tools.dir}/propertiesparser" includes="**/resources/**"/> 264 </copy> 265 <javac source="${javac.build.source}" 266 target="${javac.build.target}" 267 srcdir="${make.tools.dir}" 268 includes="propertiesparser/* anttasks/PropertiesParser* anttasks/PathFileSet*" 269 destdir="${build.tools}" 270 classpath="${ant.core.lib}" 271 bootclasspath="${langtools.jdk.home}/jre/lib/rt.jar" 272 includeantruntime="false"> 273 <compilerarg line="${javac.opts} -XDstringConcat=inline"/> 274 </javac> 275 <taskdef name="pparse" 276 classname="anttasks.PropertiesParserTask" 277 classpath="${build.tools}"/> 278 </target> 279 280 <target name="-def-pcompile"> 281 <javac 282 source="${javac.build.source}" 283 target="${javac.build.target}" 284 srcdir="${make.tools.dir}" 285 includes="compileproperties/* anttasks/CompileProperties* anttasks/PathFileSet*" 286 destdir="${build.dir}/toolclasses/" 287 classpath="${ant.core.lib}" 288 includeantruntime="false"> 289 <compilerarg line="${javac.opts} -XDstringConcat=inline"/> 290 </javac> 291 <taskdef name="pcompile" 292 classname="anttasks.CompilePropertiesTask" 293 classpath="${build.tools}"/> 294 </target> 295 296 <target name="-def-build-tool"> 297 <macrodef name="build-tool"> 298 <attribute name="name"/> 299 <attribute name="compilation.kind" default=""/> 300 <attribute name="bin.dir" default="${build.bin}"/> 301 <attribute name="java" default="${launcher.java}"/> 302 <attribute name="main.class" default="${tool.@{name}.main.class}"/> 303 <attribute name="xpatch" default="${xpatch.cmd}"/> 304 <sequential> 305 <mkdir dir="@{bin.dir}"/> 306 <copy file="${make.dir}/launcher.sh-template" tofile="@{bin.dir}/@{name}"> 307 <filterset begintoken="#" endtoken="#"> 308 <filter token="PROGRAM" value="@{main.class}"/> 309 <filter token="TARGET_JAVA" value="@{java}"/> 310 <filter token="PS" value="${path.separator}"/> 311 <filter token="XPATCH" value="${xpatch.cmd}"/> 312 </filterset> 313 </copy> 314 <chmod file="@{bin.dir}/@{name}" perm="ugo+rx"/> 315 </sequential> 316 </macrodef> 317 </target> 318 319 <target name="-def-jtreg" unless="jtreg.defined" depends="-check-jtreg.home,-check-langtools.jdk.home"> 320 <taskdef name="jtreg" classname="com.sun.javatest.regtest.Main$$Ant"> 321 <classpath> 322 <pathelement location="${jtreg.home}/lib/jtreg.jar"/> 323 <pathelement location="${jtreg.home}/lib/javatest.jar"/> 324 </classpath> 325 </taskdef> 326 <macrodef name="jtreg-tool"> 327 <attribute name="name"/> 328 <attribute name="tests"/> 329 <attribute name="jdk" default="${langtools.jdk.home}"/> 330 <attribute name="agentvm" default="true"/> 331 <attribute name="verbose" default="${default.jtreg.verbose}"/> 332 <attribute name="options" default="${other.jtreg.options}"/> 333 <attribute name="keywords" default="-keywords:!ignore"/> 334 <attribute name="jpda.jvmargs" default=""/> 335 <attribute name="extra.jvmargs" default=""/> 336 <attribute name="build.modules" default="${build.modules}"/> 337 <sequential> 338 <property name="coverage.options" value=""/> <!-- default --> 339 <property name="coverage.classpath" value=""/> <!-- default --> 340 <property name="default.jtreg.verbose" value="summary"/> <!-- default --> 341 <property name="other.jtreg.options" value=""/> <!-- default --> 342 <property name="jtreg.classfiles.to.modules" value="@{agentvm}"/> 343 <jtreg 344 dir="${test.dir}" 345 workDir="${build.jtreg}/@{name}/work" 346 reportDir="${build.jtreg}/@{name}/report" 347 jdk="@{jdk}" 348 agentvm="@{agentvm}" verbose="@{verbose}" 349 failonerror="false" resultproperty="jtreg.@{name}.result" 350 vmoptions="${coverage.options} @{extra.jvmargs} ${xpatch.noquotes.cmd}"> 351 <arg value="-debug:@{jpda.jvmargs}"/> 352 <arg line="@{keywords}"/> 353 <arg line="@{options}"/> 354 <arg line="@{tests}"/> 355 </jtreg> 356 <!-- the next two properties are for convenience, when only 357 a single instance of jtreg will be invoked. --> 358 <condition property="jtreg.passed"> 359 <equals arg1="${jtreg.@{name}.result}" arg2="0"/> 360 </condition> 361 <property name="jtreg.report" value="${build.jtreg}/@{name}/report"/> 362 </sequential> 363 </macrodef> 364 <property name="jtreg.defined" value="true"/> 365 </target> 366</project> 367