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