build.xml revision 91:3df0a0d62d60
1<?xml version="1.0" encoding="UTF-8"?> 2<!-- 3 Copyright (c) 2010, 2013, 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. 9 10 This code is distributed in the hope that it will be useful, but WITHOUT 11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 version 2 for more details (a copy is included in the LICENSE file that 14 accompanied this code). 15 16 You should have received a copy of the GNU General Public License version 17 2 along with this work; if not, write to the Free Software Foundation, 18 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 19 20 Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 21 or visit www.oracle.com if you need additional information or have any 22 questions. 23--> 24<project name="nashorn" default="all" basedir=".."> 25 <import file="build-nasgen.xml"/> 26 <import file="build-benchmark.xml"/> 27 28 <target name="init"> 29 <loadproperties srcFile="make/project.properties"/> 30 <path id="nashorn.ext.path"> 31 <pathelement location="${dist.dir}"/> 32 </path> 33 <property name="ext.class.path" value="-Djava.ext.dirs="${toString:nashorn.ext.path}""/> 34 <condition property="svn.executable" value="/usr/local/bin/svn" else="svn"> 35 <available file="/usr/local/bin/svn"/> 36 </condition> 37 <condition property="hg.executable" value="/usr/local/bin/hg" else="hg"> 38 <available file="/usr/local/bin/hg"/> 39 </condition> 40 <!-- check if JDK already has ASM classes --> 41 <available property="asm.available" classname="jdk.internal.org.objectweb.asm.Type"/> 42 <!-- check if testng.jar is avaiable --> 43 <available property="testng.available" file="${file.reference.testng.jar}"/> 44 </target> 45 46 <target name="prepare" depends="init"> 47 <mkdir dir="${build.dir}"/> 48 <mkdir dir="${build.classes.dir}"/> 49 <mkdir dir="${build.classes.dir}/META-INF/services"/> 50 <mkdir dir="${build.test.classes.dir}"/> 51 <mkdir dir="${dist.dir}"/> 52 <mkdir dir="${dist.javadoc.dir}"/> 53 </target> 54 55 <target name="clean" depends="init, clean-nasgen"> 56 <delete includeemptydirs="true"> 57 <fileset dir="${build.dir}" erroronmissingdir="false"/> 58 </delete> 59 <delete dir="${dist.dir}"/> 60 </target> 61 62 <!-- do it only if ASM is not available --> 63 <target name="compile-asm" depends="prepare" unless="asm.available"> 64 <javac srcdir="${jdk.asm.src.dir}" 65 destdir="${build.classes.dir}" 66 excludes="**/optimizer/* **/xml/* **/attrs/*" 67 source="${javac.source}" 68 target="${javac.target}" 69 debug="${javac.debug}" 70 encoding="${javac.encoding}" 71 includeantruntime="false"/> 72 </target> 73 74 <target name="compile" depends="compile-asm" description="Compiles nashorn"> 75 <javac srcdir="${src.dir}" 76 destdir="${build.classes.dir}" 77 classpath="${javac.classpath}" 78 source="${javac.source}" 79 target="${javac.target}" 80 debug="${javac.debug}" 81 encoding="${javac.encoding}" 82 includeantruntime="false"> 83 <compilerarg value="-Xlint:unchecked"/> 84 <compilerarg value="-Xlint:deprecation"/> 85 <compilerarg value="-XDignore.symbol.file"/> 86 </javac> 87 <copy todir="${build.classes.dir}/META-INF/services"> 88 <fileset dir="${meta.inf.dir}/services/"/> 89 </copy> 90 <copy todir="${build.classes.dir}/jdk/nashorn/api/scripting/resources"> 91 <fileset dir="${src.dir}/jdk/nashorn/api/scripting/resources/"/> 92 </copy> 93 <copy todir="${build.classes.dir}/jdk/nashorn/internal/runtime/resources"> 94 <fileset dir="${src.dir}/jdk/nashorn/internal/runtime/resources/"/> 95 </copy> 96 <copy todir="${build.classes.dir}/jdk/nashorn/tools/resources"> 97 <fileset dir="${src.dir}/jdk/nashorn/tools/resources/"/> 98 </copy> 99 <copy file="${src.dir}/jdk/internal/dynalink/support/messages.properties" todir="${build.classes.dir}/jdk/internal/dynalink/support"/> 100 101 <echo message="full=${nashorn.fullversion}" file="${build.classes.dir}/jdk/nashorn/internal/runtime/resources/version.properties"/> 102 <echo file="${build.classes.dir}/jdk/nashorn/internal/runtime/resources/version.properties" append="true">${line.separator}</echo> 103 <echo message="release=${nashorn.version}" file="${build.classes.dir}/jdk/nashorn/internal/runtime/resources/version.properties" append="true"/> 104 </target> 105 106 <target name="jar" depends="compile, run-nasgen" description="Creates nashorn.jar"> 107 <jar jarfile="${dist.jar}" manifest="${meta.inf.dir}/MANIFEST.MF" index="true" filesetmanifest="merge"> 108 <fileset dir="${build.classes.dir}"/> 109 <manifest> 110 <attribute name="Archiver-Version" value="n/a"/> 111 <attribute name="Build-Jdk" value="${java.runtime.version}"/> 112 <attribute name="Built-By" value="n/a"/> 113 <attribute name="Created-By" value="Ant jar task"/> 114 <section name="jdk/nashorn/"> 115 <attribute name="Implementation-Title" value="${nashorn.product.name}"/> 116 <attribute name="Implementation-Version" value="${nashorn.version}"/> 117 </section> 118 </manifest> 119 </jar> 120 </target> 121 122 <target name="javadoc" depends="prepare"> 123 <javadoc destdir="${dist.javadoc.dir}" use="yes" overview="src/overview.html" windowtitle="${nashorn.product.name} ${nashorn.version}" additionalparam="-quiet" failonerror="true"> 124 <classpath> 125 <pathelement location="${build.classes.dir}"/> 126 </classpath> 127 <fileset dir="${src.dir}" includes="**/*.java"/> 128 <fileset dir="${jdk.asm.src.dir}" includes="**/*.java"/> 129 <link href="http://docs.oracle.com/javase/7/docs/api/"/> 130 <!-- The following tags are used only in ASM sources - just ignore these --> 131 <tag name="label" description="label tag in ASM sources" enabled="false"/> 132 <tag name="linked" description="linked tag in ASM sources" enabled="false"/> 133 <tag name="associates" description="associates tag in ASM sources" enabled="false"/> 134 </javadoc> 135 </target> 136 137 <!-- generate shell.html for shell tool documentation --> 138 <target name="shelldoc" depends="jar"> 139 <java classname="${nashorn.shell.tool}" dir="${basedir}" output="${dist.dir}/shell.html" failonerror="true" fork="true"> 140 <jvmarg line="${ext.class.path}"/> 141 <arg value="-scripting"/> 142 <arg value="docs/genshelldoc.js"/> 143 </java> 144 </target> 145 146 <!-- generate all docs --> 147 <target name="docs" depends="javadoc, shelldoc"/> 148 149 <!-- create .zip and .tar.gz for nashorn binaries and scripts. --> 150 <target name="dist" depends="jar"> 151 <zip destfile="${build.zip}" basedir=".." 152 excludes="nashorn/bin/*.sh" includes="nashorn/bin/** nashorn/dist/**"/> 153 <tar destfile="${build.gzip}" basedir=".." compression="gzip" 154 excludes="nashorn/bin/*.sh" includes="nashorn/bin/** nashorn/dist/**"/> 155 </target> 156 157 <target name="compile-test" depends="compile, run-nasgen" if="testng.available"> 158 <!-- testng task --> 159 <taskdef name="testng" classname="org.testng.TestNGAntTask" 160 classpath="${file.reference.testng.jar}"/> 161 162 <javac srcdir="${test.src.dir}" 163 destdir="${build.test.classes.dir}" 164 classpath="${javac.test.classpath}" 165 source="${javac.source}" 166 target="${javac.target}" 167 debug="${javac.debug}" 168 encoding="${javac.encoding}" 169 includeantruntime="false"/> 170 171 <!-- tests that check nashorn internals and internal API --> 172 <jar jarfile="${nashorn.internal.tests.jar}"> 173 <fileset dir="${build.test.classes.dir}" excludes="**/api/*"/> 174 </jar> 175 176 <!-- tests that check nashorn script engine (jsr-223) API --> 177 <jar jarfile="${nashorn.api.tests.jar}"> 178 <fileset dir="${build.test.classes.dir}" includes="**/api/*"/> 179 </jar> 180 181 </target> 182 183 <target name="generate-policy-file" depends="prepare"> 184 <!-- Generating nashorn.policy file --> 185 186 <!-- nashorn internal tests jar requires AllPermission --> 187 <echo message="grant codeBase "file:/${basedir}/${nashorn.internal.tests.jar}" {" file="${build.dir}/nashorn.policy"/> 188 <echo message="" file="${build.dir}/nashorn.policy" append="true"/> 189 <echo message=" permission java.security.AllPermission;" file="${build.dir}/nashorn.policy" append="true"/> 190 <echo message="" file="${build.dir}/nashorn.policy" append="true"/> 191 <echo message="};" file="${build.dir}/nashorn.policy" append="true"/> 192 <echo message="" file="${build.dir}/nashorn.policy" append="true"/> 193 194 <!-- TestNG framework jar needs AllPermission --> 195 <echo message="grant codeBase "file:/${basedir}/${file.reference.testng.jar}" {" file="${build.dir}/nashorn.policy" append="true"/> 196 <echo message="" file="${build.dir}/nashorn.policy" append="true"/> 197 <echo message=" permission java.security.AllPermission;" file="${build.dir}/nashorn.policy" append="true"/> 198 <echo message="" file="${build.dir}/nashorn.policy" append="true"/> 199 <echo message="};" file="${build.dir}/nashorn.policy" append="true"/> 200 <echo message="" file="${build.dir}/nashorn.policy" append="true"/> 201 202 <!-- AllPermission to test/script/trusted tests --> 203 <echo message="grant codeBase "file:/${basedir}/test/script/trusted/*" {" file="${build.dir}/nashorn.policy" append="true"/> 204 <echo message="" file="${build.dir}/nashorn.policy" append="true"/> 205 <echo message=" permission java.security.AllPermission;" file="${build.dir}/nashorn.policy" append="true"/> 206 <echo message="" file="${build.dir}/nashorn.policy" append="true"/> 207 <echo message="};" file="${build.dir}/nashorn.policy" append="true"/> 208 <echo message="" file="${build.dir}/nashorn.policy" append="true"/> 209 210 <echo message="grant codeBase "file:/${basedir}/test/script/basic/*" {" file="${build.dir}/nashorn.policy" append="true"/> 211 <echo message="" file="${build.dir}/nashorn.policy" append="true"/> 212 <!-- test/script/basic .js scripts load other script tests --> 213 <echo message=" permission java.io.FilePermission "${basedir}/test/script/-", "read";" file="${build.dir}/nashorn.policy" append="true"/> 214 <echo message="" file="${build.dir}/nashorn.policy" append="true"/> 215 <!-- test/script/basic .js scripts can read nashorn.test.* properties --> 216 <echo message=" permission java.util.PropertyPermission "nashorn.test.*", "read";" file="${build.dir}/nashorn.policy" append="true"/> 217 <echo message="" file="${build.dir}/nashorn.policy" append="true"/> 218 <echo message="};" file="${build.dir}/nashorn.policy" append="true"/> 219 <echo message="" file="${build.dir}/nashorn.policy" append="true"/> 220 221 <replace file="${build.dir}/nashorn.policy"><replacetoken>\</replacetoken><replacevalue>/</replacevalue></replace> <!--hack for Windows - to make URLs with normal path separators --> 222 <replace file="${build.dir}/nashorn.policy"><replacetoken>//</replacetoken><replacevalue>/</replacevalue></replace> <!--hack for Unix - to avoid leading // in URLs --> 223 224 </target> 225 226 <target name="check-external-tests"> 227 <available file="${test.external.dir}/prototype" property="test-sys-prop.external.prototype"/> 228 <available file="${test.external.dir}/sunspider" property="test-sys-prop.external.sunspider"/> 229 <available file="${test.external.dir}/underscore" property="test-sys-prop.external.underscore"/> 230 <available file="${test.external.dir}/octane" property="test-sys-prop.external.octane"/> 231 <available file="${test.external.dir}/yui" property="test-sys-prop.external.yui"/> 232 <available file="${test.external.dir}/jquery" property="test-sys-prop.external.jquery"/> 233 <available file="${test.external.dir}/test262" property="test-sys-prop.external.test262"/> 234 </target> 235 236 <target name="check-testng" unless="testng.available"> 237 <echo message="WARNING: TestNG not available, will not run tests. Please copy testng.jar under test/lib directory."/> 238 </target> 239 240 <target name="test" depends="jar, check-testng, check-external-tests, compile-test, generate-policy-file" if="testng.available"> 241 <java classname="${nashorn.shell.tool}" fork="true" dir="${test.script.dir}/representations" output="${build.dir}/output1.log" error="${build.dir}/err.log"> 242 <jvmarg line="${ext.class.path}"/> 243 <jvmarg line="-Dnashorn.fields.dual=true"/> 244 <arg value="NASHORN-592a.js"/> 245 </java> 246 <java classname="${nashorn.shell.tool}" fork="true" dir="${test.script.dir}/representations" output="${build.dir}/output2.log" error="${build.dir}/err.log"> 247 <jvmarg line="${ext.class.path}"/> 248 <arg value="NASHORN-592a.js"/> 249 </java> 250 <condition property="representation-ok"> 251 <filesmatch file1="${build.dir}/output1.log" file2="${build.dir}/output2.log"/> 252 </condition> 253 <fail unless="representation-ok">Representation test failed - output differs!</fail> 254 <fileset id="test.classes" dir="${build.test.classes.dir}"> 255 <include name="**/access/*Test.class"/> 256 <include name="**/api/scripting/*Test.class"/> 257 <include name="**/codegen/*Test.class"/> 258 <include name="**/parser/*Test.class"/> 259 <include name="**/runtime/*Test.class"/> 260 <include name="**/framework/*Test.class"/> 261 </fileset> 262 263 <testng outputdir="${build.test.results.dir}" classfilesetref="test.classes" 264 verbose="${testng.verbose}" haltonfailure="true" useDefaultListeners="false" listeners="${testng.listeners}" workingDir="${basedir}"> 265 <jvmarg line="${ext.class.path}"/> 266 <jvmarg line="${run.test.jvmargs} ${run.test.jvmsecurityargs}"/> 267 <propertyset> 268 <propertyref prefix="test-sys-prop."/> 269 <mapper from="test-sys-prop.*" to="*" type="glob"/> 270 </propertyset> 271 <classpath> 272 <pathelement path="${run.test.classpath}"/> 273 </classpath> 274 </testng> 275 </target> 276 277 <target name="test-basicparallel" depends="jar, check-testng, check-external-tests, compile-test, generate-policy-file"> 278 <!-- use just build.test.classes.dir to avoid referring to TestNG --> 279 <java classname="${parallel.test.runner}" dir="${basedir}" classpath="${build.test.classes.dir}" failonerror="true" fork="true"> 280 <jvmarg line="${ext.class.path}"/> 281 <jvmarg line="${run.test.jvmargs} ${run.test.jvmsecurityargs}"/> 282 <syspropertyset> 283 <propertyref prefix="test-sys-prop."/> 284 <mapper type="glob" from="test-sys-prop.*" to="*"/> 285 </syspropertyset> 286 </java> 287 </target> 288 289 <target name="test262" depends="jar, check-testng, check-external-tests, compile-test, generate-policy-file" if="testng.available"> 290 <fileset id="test.classes" dir="${build.test.classes.dir}"> 291 <include name="**/framework/*Test.class"/> 292 </fileset> 293 294 <testng outputdir="${build.test.results.dir}" classfilesetref="test.classes" 295 verbose="${testng.verbose}" haltonfailure="true" useDefaultListeners="false" listeners="${testng.listeners}" workingDir="${basedir}"> 296 <jvmarg line="${ext.class.path}"/> 297 <jvmarg line="${run.test.jvmargs} ${run.test.jvmsecurityargs}"/> 298 <propertyset> 299 <propertyref prefix="test262-test-sys-prop."/> 300 <mapper from="test262-test-sys-prop.*" to="*" type="glob"/> 301 </propertyset> 302 <classpath> 303 <pathelement path="${run.test.classpath}"/> 304 </classpath> 305 </testng> 306 </target> 307 308 <target name="test262parallel" depends="test262-parallel"/> 309 310 <target name="test262-parallel" depends="jar, check-testng, check-external-tests, compile-test, generate-policy-file" if="testng.available"> 311 <!-- use just build.test.classes.dir to avoid referring to TestNG --> 312 <java classname="${parallel.test.runner}" dir="${basedir}" fork="true"> 313 <jvmarg line="${ext.class.path}"/> 314 <jvmarg line="${run.test.jvmargs} ${run.test.jvmsecurityargs}"/> 315 <classpath> 316 <pathelement path="${run.test.classpath}"/> 317 </classpath> 318 <syspropertyset> 319 <propertyref prefix="test262-test-sys-prop."/> 320 <mapper type="glob" from="test262-test-sys-prop.*" to="*"/> 321 </syspropertyset> 322 </java> 323 </target> 324 325 <target name="all" depends="test, docs" 326 description="Build, test and generate docs for nashorn"/> 327 328 <target name="run" depends="jar" 329 description="Run the shell with a sample script"> 330 <java classname="${nashorn.shell.tool}" fork="true" dir="samples"> 331 <jvmarg line="${ext.class.path}"/> 332 <jvmarg line="${run.test.jvmargs}"/> 333 <arg value="-dump-on-error"/> 334 <arg value="test.js"/> 335 </java> 336 </target> 337 338 <target name="debug" depends="jar" 339 description="Debug the shell with a sample script"> 340 <java classname="${nashorn.shell.tool}" fork="true" dir="samples"> 341 <jvmarg line="${ext.class.path}"/> 342 <jvmarg line="${run.test.jvmargs}"/> 343 <arg value="--print-code"/> 344 <arg value="--verify-code"/> 345 <arg value="--print-symbols"/> 346 <jvmarg value="-Dnashorn.codegen.debug=true"/> 347 <arg value="test.js"/> 348 </java> 349 </target> 350 351 <!-- targets to get external script tests --> 352 353 <!-- test262 test suite --> 354 <target name="get-test262" depends="init" unless="${test-sys-prop.external.test262}"> 355 <!-- clone test262 mercurial repo --> 356 <exec executable="${hg.executable}"> 357 <arg value="clone"/> 358 <arg value="http://hg.ecmascript.org/tests/test262"/> 359 <arg value="${test.external.dir}/test262"/> 360 </exec> 361 </target> 362 <target name="update-test262" depends="init" if="${test-sys-prop.external.test262}"> 363 <!-- update test262 mercurial repo --> 364 <exec executable="${hg.executable}" dir="${test.external.dir}/test262"> 365 <arg value="pull"/> 366 <arg value="-u"/> 367 </exec> 368 </target> 369 370 <!-- octane benchmark --> 371 <target name="get-octane" depends="init" unless="${test-sys-prop.external.octane}"> 372 <!-- checkout octane benchmarks --> 373 <exec executable="${svn.executable}"> 374 <arg value="--non-interactive"/> 375 <arg value="--trust-server-cert"/> 376 <arg value="checkout"/> 377 <arg value="http://octane-benchmark.googlecode.com/svn/trunk/"/> 378 <arg value="${test.external.dir}/octane"/> 379 </exec> 380 </target> 381 <target name="update-octane" depends="init" if="${test-sys-prop.external.octane}"> 382 <!-- update octane benchmarks --> 383 <exec executable="${svn.executable}" dir="${test.external.dir}/octane"> 384 <arg value="--non-interactive"/> 385 <arg value="--trust-server-cert"/> 386 <arg value="update"/> 387 </exec> 388 </target> 389 390 <!-- sunspider benchmark --> 391 <target name="get-sunspider" depends="init" unless="${test-sys-prop.external.sunspider}"> 392 <!-- checkout sunspider --> 393 <exec executable="${svn.executable}"> 394 <arg value="--non-interactive"/> 395 <arg value="--trust-server-cert"/> 396 <arg value="checkout"/> 397 <arg value="http://svn.webkit.org/repository/webkit/trunk/PerformanceTests/SunSpider"/> 398 <arg value="${test.external.dir}/sunspider"/> 399 </exec> 400 </target> 401 <target name="update-sunspider" depends="init" if="${test-sys-prop.external.sunspider}"> 402 <!-- update sunspider --> 403 <exec executable="${svn.executable}" dir="${test.external.dir}/sunspider"> 404 <arg value="--non-interactive"/> 405 <arg value="--trust-server-cert"/> 406 <arg value="update"/> 407 </exec> 408 </target> 409 410 <!-- get all external test scripts --> 411 <target name="externals" depends="init, check-external-tests, get-test262, get-octane, get-sunspider"> 412 <!-- make external test dir --> 413 <mkdir dir="${test.external.dir}"/> 414 415 <!-- jquery --> 416 <mkdir dir="${test.external.dir}/jquery"/> 417 <get src="http://code.jquery.com/jquery-1.7.2.js" dest="${test.external.dir}/jquery" skipexisting="true" ignoreerrors="true"/> 418 <get src="http://code.jquery.com/jquery-1.7.2.min.js" dest="${test.external.dir}/jquery" skipexisting="true" ignoreerrors="true"/> 419 420 <!-- prototype --> 421 <mkdir dir="${test.external.dir}/prototype"/> 422 <get src="http://ajax.googleapis.com/ajax/libs/prototype/1.7.0/prototype.js" dest="${test.external.dir}/prototype" usetimestamp="true" skipexisting="true" ignoreerrors="true"/> 423 424 <!-- underscorejs --> 425 <mkdir dir="${test.external.dir}/underscore"/> 426 <get src="http://underscorejs.org/underscore.js" dest="${test.external.dir}/underscore" skipexisting="true" ignoreerrors="true"/> 427 <get src="http://underscorejs.org/underscore-min.js" dest="${test.external.dir}/underscore" skipexisting="true" ignoreerrors="true"/> 428 429 <!-- yui --> 430 <mkdir dir="${test.external.dir}/yui"/> 431 <get src="http://yui.yahooapis.com/3.5.1/build/yui/yui.js" dest="${test.external.dir}/yui" skipexisting="true" ignoreerrors="true"/> 432 <get src="http://yui.yahooapis.com/3.5.1/build/yui/yui-min.js" dest="${test.external.dir}/yui" skipexisting="true" ignoreerrors="true"/> 433 434 </target> 435 436 <!-- update external test suites that are pulled from source control systems --> 437 <target name="update-externals" depends="init, check-external-tests, update-test262, update-octane, update-sunspider"/> 438 439 <!-- run all perf tests --> 440 <target name="perf" depends="externals, update-externals, sunspider, octane"/> 441 442 <!-- run all tests --> 443 <target name="exit-if-no-testng" depends="init, check-testng" unless="${testng.available}"> 444 <fail message="Exiting.."/> 445 </target> 446 447 <target name="alltests" depends="exit-if-no-testng, externals, update-externals, test, test262parallel, perf"/> 448 449</project> 450