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