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