1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/make/build.xml Fri Dec 21 16:36:24 2012 -0400 1.3 @@ -0,0 +1,355 @@ 1.4 +<?xml version="1.0" encoding="UTF-8"?> 1.5 +<!-- 1.6 + Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved. 1.7 + DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.8 + 1.9 + This code is free software; you can redistribute it and/or modify it 1.10 + under the terms of the GNU General Public License version 2 only, as 1.11 + published by the Free Software Foundation. 1.12 + 1.13 + This code is distributed in the hope that it will be useful, but WITHOUT 1.14 + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.15 + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.16 + version 2 for more details (a copy is included in the LICENSE file that 1.17 + accompanied this code). 1.18 + 1.19 + You should have received a copy of the GNU General Public License version 1.20 + 2 along with this work; if not, write to the Free Software Foundation, 1.21 + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.22 + 1.23 + Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 1.24 + or visit www.oracle.com if you need additional information or have any 1.25 + questions. 1.26 +--> 1.27 +<project name="nashorn" default="all" basedir=".."> 1.28 + <import file="build-nasgen.xml"/> 1.29 + <import file="build-benchmark.xml"/> 1.30 + 1.31 + <target name="init"> 1.32 + <loadproperties srcFile="make/project.properties"/> 1.33 + <path id="nashorn.ext.path"> 1.34 + <pathelement location="${dist.dir}"/> 1.35 + </path> 1.36 + <property name="ext.class.path" value="-Djava.ext.dirs="${toString:nashorn.ext.path}""/> 1.37 + </target> 1.38 + 1.39 + <target name="prepare" depends="init"> 1.40 + <mkdir dir="${build.dir}"/> 1.41 + <mkdir dir="${build.classes.dir}"/> 1.42 + <mkdir dir="${build.classes.dir}/META-INF/services"/> 1.43 + <mkdir dir="${build.test.classes.dir}"/> 1.44 + <mkdir dir="${dist.dir}"/> 1.45 + <mkdir dir="${dist.javadoc.dir}"/> 1.46 + <!-- check if JDK already has ASM classes --> 1.47 + <available property="asm.available" classname="jdk.internal.org.objectweb.asm.Type"/> 1.48 + <!-- check if testng.jar is avaiable --> 1.49 + <available property="testng.available" file="${file.reference.testng.jar}"/> 1.50 + </target> 1.51 + 1.52 + <target name="clean" depends="init, clean-nasgen"> 1.53 + <delete includeemptydirs="true"> 1.54 + <fileset dir="${build.dir}" excludes="${dynalink.dir.name}/**/*" erroronmissingdir="false"/> 1.55 + </delete> 1.56 + <delete dir="${dist.dir}"/> 1.57 + </target> 1.58 + 1.59 + <target name="clean-dynalink"> 1.60 + <delete dir="${dynalink.dir}"/> 1.61 + </target> 1.62 + 1.63 + <target name="clean-all" depends="clean-dynalink, clean"> 1.64 + <delete dir="${build.dir}"/> 1.65 + </target> 1.66 + 1.67 + <!-- do it only if ASM is not available --> 1.68 + <target name="compile-asm" depends="prepare" unless="asm.available"> 1.69 + <javac srcdir="${asm.src.dir}" 1.70 + destdir="${build.classes.dir}" 1.71 + excludes="**/optimizer/* **/xml/* **/attrs/*" 1.72 + source="${javac.source}" 1.73 + target="${javac.target}" 1.74 + debug="${javac.debug}" 1.75 + encoding="${javac.encoding}" 1.76 + includeantruntime="false"/> 1.77 + </target> 1.78 + 1.79 + <target name="check-dynalink-uptodate" depends="init"> 1.80 + <property name="versioned.dynalink.jar" value="${dynalink.dir}/dynalink-${dynalink.jar.version}.jar"/> 1.81 + <condition property="dynalink.uptodate"> 1.82 + <and> 1.83 + <available file="${versioned.dynalink.jar}"/> 1.84 + <filesmatch file1="${versioned.dynalink.jar}" file2="${dynalink.jar}"/> 1.85 + </and> 1.86 + </condition> 1.87 + </target> 1.88 + 1.89 + <target name="get-dynalink" depends="check-dynalink-uptodate" unless="dynalink.uptodate"> 1.90 + <mkdir dir="${dynalink.dir}"/> 1.91 + <!-- Delete previous snapshots, if any --> 1.92 + <delete> 1.93 + <fileset dir="${dynalink.dir}" includes="*"/> 1.94 + </delete> 1.95 + <property name="dynalink.download.base.url" value="http://oss.sonatype.org/content/repositories/${dynalink.version.type}s/org/dynalang/dynalink/${dynalink.version}/dynalink-${dynalink.jar.version}"/> 1.96 + <get src="${dynalink.download.base.url}.jar" dest="${versioned.dynalink.jar}" usetimestamp="true"/> 1.97 + <get src="${dynalink.download.base.url}-sources.jar" dest="${dynalink.dir}/dynalink-sources.jar" usetimestamp="true"/> 1.98 + <copy file="${versioned.dynalink.jar}" tofile="${dynalink.jar}" overwrite="true"/> 1.99 + </target> 1.100 + 1.101 + <target name="compile" depends="compile-asm, get-dynalink" description="Compiles nashorn"> 1.102 + <javac srcdir="${src.dir}" 1.103 + destdir="${build.classes.dir}" 1.104 + classpath="${javac.classpath}" 1.105 + source="${javac.source}" 1.106 + target="${javac.target}" 1.107 + debug="${javac.debug}" 1.108 + encoding="${javac.encoding}" 1.109 + includeantruntime="false"> 1.110 + <compilerarg value="-Xlint:unchecked"/> 1.111 + <compilerarg value="-Xlint:deprecation"/> 1.112 + <compilerarg value="-XDignore.symbol.file"/> 1.113 + </javac> 1.114 + <copy todir="${build.classes.dir}/META-INF/services"> 1.115 + <fileset dir="${meta.inf.dir}/services/"/> 1.116 + </copy> 1.117 + <copy todir="${build.classes.dir}/jdk/nashorn/api/scripting/resources"> 1.118 + <fileset dir="${src.dir}/jdk/nashorn/api/scripting/resources/"/> 1.119 + </copy> 1.120 + <copy todir="${build.classes.dir}/jdk/nashorn/internal/runtime/resources"> 1.121 + <fileset dir="${src.dir}/jdk/nashorn/internal/runtime/resources/"/> 1.122 + </copy> 1.123 + <copy todir="${build.classes.dir}/jdk/nashorn/tools/resources"> 1.124 + <fileset dir="${src.dir}/jdk/nashorn/tools/resources/"/> 1.125 + </copy> 1.126 + <echo message="full=${nashorn.fullversion}" file="${build.classes.dir}/jdk/nashorn/internal/runtime/resources/version.properties"/> 1.127 + <echo file="${build.classes.dir}/jdk/nashorn/internal/runtime/resources/version.properties" append="true">${line.separator}</echo> 1.128 + <echo message="release=${nashorn.version}" file="${build.classes.dir}/jdk/nashorn/internal/runtime/resources/version.properties" append="true"/> 1.129 + </target> 1.130 + 1.131 + <target name="jar" depends="compile, run-nasgen" description="Creates nashorn.jar"> 1.132 + <jar jarfile="${dist.jar}" manifest="${meta.inf.dir}/MANIFEST.MF" index="true" filesetmanifest="merge"> 1.133 + <fileset dir="${build.classes.dir}"/> 1.134 + <zipfileset src="${dynalink.jar}"/> 1.135 + <manifest> 1.136 + <attribute name="Archiver-Version" value="n/a"/> 1.137 + <attribute name="Build-Jdk" value="${java.runtime.version}"/> 1.138 + <attribute name="Built-By" value="n/a"/> 1.139 + <attribute name="Created-By" value="Ant jar task"/> 1.140 + <section name="jdk/nashorn/"> 1.141 + <attribute name="Implementation-Title" value="${nashorn.product.name}"/> 1.142 + <attribute name="Implementation-Version" value="${nashorn.version}"/> 1.143 + </section> 1.144 + </manifest> 1.145 + </jar> 1.146 + </target> 1.147 + 1.148 + <target name="javadoc" depends="compile-asm"> 1.149 + <javadoc destdir="${dist.javadoc.dir}" private="yes" use="yes" overview="src/overview.html" windowtitle="${nashorn.product.name} ${nashorn.version}"> 1.150 + <classpath> 1.151 + <pathelement location="${build.classes.dir}"/> 1.152 + <pathelement location="${dynalink.jar}"/> 1.153 + </classpath> 1.154 + <fileset dir="${src.dir}" includes="**/*.java"/> 1.155 + <link href="http://docs.oracle.com/javase/7/docs/api"/> 1.156 + <link href="http://szegedi.github.com/dynalink/0.4/javadoc"/> 1.157 + </javadoc> 1.158 + </target> 1.159 + 1.160 + <!-- generate shell.html for shell tool documentation --> 1.161 + <target name="shelldoc" depends="jar"> 1.162 + <java classname="${nashorn.shell.tool}" dir="${basedir}" output="${dist.dir}/shell.html" failonerror="true" fork="true"> 1.163 + <jvmarg line="${ext.class.path}"/> 1.164 + <arg value="-scripting"/> 1.165 + <arg value="docs/genshelldoc.js"/> 1.166 + </java> 1.167 + </target> 1.168 + 1.169 + <!-- generate all docs --> 1.170 + <target name="docs" depends="javadoc, shelldoc"/> 1.171 + 1.172 + <!-- create .zip and .tar.gz for nashorn binaries and scripts. --> 1.173 + <target name="dist" depends="jar"> 1.174 + <zip destfile="${build.zip}" basedir=".." 1.175 + excludes="nashorn/bin/*.sh" includes="nashorn/bin/** nashorn/dist/**"/> 1.176 + <tar destfile="${build.gzip}" basedir=".." compression="gzip" 1.177 + excludes="nashorn/bin/*.sh" includes="nashorn/bin/** nashorn/dist/**"/> 1.178 + </target> 1.179 + 1.180 + <target name="compile-test" depends="compile, run-nasgen" if="testng.available"> 1.181 + <!-- testng task --> 1.182 + <taskdef name="testng" classname="org.testng.TestNGAntTask" 1.183 + classpath="${file.reference.testng.jar}"/> 1.184 + 1.185 + <javac srcdir="${test.src.dir}" 1.186 + destdir="${build.test.classes.dir}" 1.187 + classpath="${javac.test.classpath}" 1.188 + source="${javac.source}" 1.189 + target="${javac.target}" 1.190 + debug="${javac.debug}" 1.191 + encoding="${javac.encoding}" 1.192 + includeantruntime="false"/> 1.193 + </target> 1.194 + 1.195 + <target name="generate-policy-file"> 1.196 + <!-- Generating nashorn.policy file --> 1.197 + <echo message="grant codeBase "file:/${basedir}/dist/nashorn.jar" {" file="${build.dir}/nashorn.policy"/> 1.198 + <echo message="" file="${build.dir}/nashorn.policy" append="true"/> 1.199 + <echo message="permission java.security.AllPermission;" file="${build.dir}/nashorn.policy" append="true"/> 1.200 + <echo message="" file="${build.dir}/nashorn.policy" append="true"/> 1.201 + <echo message="};" file="${build.dir}/nashorn.policy" append="true"/> 1.202 + <echo message="" file="${build.dir}/nashorn.policy" append="true"/> 1.203 + 1.204 + <echo message="grant codeBase "file:/${basedir}/build/test/classes" {" file="${build.dir}/nashorn.policy" append="true"/> 1.205 + <echo message="" file="${build.dir}/nashorn.policy" append="true"/> 1.206 + <echo message=" permission java.security.AllPermission;" file="${build.dir}/nashorn.policy" append="true"/> 1.207 + <echo message="" file="${build.dir}/nashorn.policy" append="true"/> 1.208 + <echo message="};" file="${build.dir}/nashorn.policy" append="true"/> 1.209 + <echo message="" file="${build.dir}/nashorn.policy" append="true"/> 1.210 + 1.211 + <echo message="grant codeBase "file:/${basedir}/${file.reference.testng.jar}" {" file="${build.dir}/nashorn.policy" append="true"/> 1.212 + <echo message="" file="${build.dir}/nashorn.policy" append="true"/> 1.213 + <echo message=" permission java.security.AllPermission;" file="${build.dir}/nashorn.policy" append="true"/> 1.214 + <echo message="" file="${build.dir}/nashorn.policy" append="true"/> 1.215 + <echo message="};" file="${build.dir}/nashorn.policy" append="true"/> 1.216 + <echo message="" file="${build.dir}/nashorn.policy" append="true"/> 1.217 + 1.218 + <echo message="grant codeBase "file:/${basedir}/test/script/basic/*" {" file="${build.dir}/nashorn.policy" append="true"/> 1.219 + <echo message="" file="${build.dir}/nashorn.policy" append="true"/> 1.220 + <echo message=" permission java.security.AllPermission;" file="${build.dir}/nashorn.policy" append="true"/> 1.221 + <echo message="" file="${build.dir}/nashorn.policy" append="true"/> 1.222 + <echo message="};" file="${build.dir}/nashorn.policy" append="true"/> 1.223 + <echo message="" file="${build.dir}/nashorn.policy" append="true"/> 1.224 + 1.225 + <echo message="grant codeBase "file:/${basedir}/test/perf/*" {" file="${build.dir}/nashorn.policy" append="true"/> 1.226 + <echo message="" file="${build.dir}/nashorn.policy" append="true"/> 1.227 + <echo message=" permission java.security.AllPermission;" file="${build.dir}/nashorn.policy" append="true"/> 1.228 + <echo message="" file="${build.dir}/nashorn.policy" append="true"/> 1.229 + <echo message="};" file="${build.dir}/nashorn.policy" append="true"/> 1.230 + <echo message="" file="${build.dir}/nashorn.policy" append="true"/> 1.231 + 1.232 + <replace file="${build.dir}/nashorn.policy"><replacetoken>\</replacetoken><replacevalue>/</replacevalue></replace> <!--hack for Windows - to make URLs with normal path separators --> 1.233 + <replace file="${build.dir}/nashorn.policy"><replacetoken>//</replacetoken><replacevalue>/</replacevalue></replace> <!--hack for Unix - to avoid leading // in URLs --> 1.234 + 1.235 + </target> 1.236 + 1.237 + <target name="check-external-tests"> 1.238 + <available file="${test.external.dir}/prototype" property="test-sys-prop.external.prototype"/> 1.239 + <available file="${test.external.dir}/sunspider" property="test-sys-prop.external.sunspider"/> 1.240 + <available file="${test.external.dir}/underscore" property="test-sys-prop.external.underscore"/> 1.241 + <available file="${test.external.dir}/octane" property="test-sys-prop.external.octane"/> 1.242 + <available file="${test.external.dir}/yui" property="test-sys-prop.external.yui"/> 1.243 + <available file="${test.external.dir}/jquery" property="test-sys-prop.external.jquery"/> 1.244 + <available file="${test.external.dir}/test262" property="test-sys-prop.external.test262"/> 1.245 + </target> 1.246 + 1.247 + <target name="check-testng" unless="testng.available"> 1.248 + <echo message="WARNING: TestNG not available, will not run tests. Please copy testng.jar under test/lib directory."/> 1.249 + </target> 1.250 + 1.251 + <target name="test" depends="jar, check-testng, check-external-tests, compile-test, generate-policy-file" if="testng.available"> 1.252 + <java classname="${nashorn.shell.tool}" fork="true" dir="${test.script.dir}/representations" output="${build.dir}/output1.log" error="${build.dir}/err.log"> 1.253 + <jvmarg line="${ext.class.path}"/> 1.254 + <jvmarg line="-Dnashorn.fields.dual=true"/> 1.255 + <arg value="NASHORN-592a.js"/> 1.256 + </java> 1.257 + <java classname="${nashorn.shell.tool}" fork="true" dir="${test.script.dir}/representations" output="${build.dir}/output2.log" error="${build.dir}/err.log"> 1.258 + <jvmarg line="${ext.class.path}"/> 1.259 + <arg value="NASHORN-592a.js"/> 1.260 + </java> 1.261 + <condition property="representation-ok"> 1.262 + <filesmatch file1="${build.dir}/output1.log" file2="${build.dir}/output2.log"/> 1.263 + </condition> 1.264 + <fail unless="representation-ok">Representation test failed - output differs!</fail> 1.265 + <fileset id="test.classes" dir="${build.test.classes.dir}"> 1.266 + <include name="**/access/*Test.class"/> 1.267 + <include name="**/api/scripting/*Test.class"/> 1.268 + <include name="**/codegen/*Test.class"/> 1.269 + <include name="**/parser/*Test.class"/> 1.270 + <include name="**/runtime/*Test.class"/> 1.271 + <include name="**/framework/*Test.class"/> 1.272 + </fileset> 1.273 + 1.274 + <testng outputdir="${build.test.results.dir}" classfilesetref="test.classes" 1.275 + verbose="${testng.verbose}" haltonfailure="true" useDefaultListeners="false" listeners="${testng.listeners}" workingDir="${basedir}"> 1.276 + <jvmarg line="${ext.class.path}"/> 1.277 + <jvmarg line="${run.test.jvmargs} ${run.test.jvmsecurityargs}"/> 1.278 + <propertyset> 1.279 + <propertyref prefix="test-sys-prop."/> 1.280 + <mapper from="test-sys-prop.*" to="*" type="glob"/> 1.281 + </propertyset> 1.282 + <classpath> 1.283 + <pathelement path="${run.test.classpath}"/> 1.284 + </classpath> 1.285 + </testng> 1.286 + </target> 1.287 + 1.288 + <target name="test-basicparallel" depends="jar, check-testng, check-external-tests, compile-test, generate-policy-file"> 1.289 + <!-- use just build.test.classes.dir to avoid referring to TestNG --> 1.290 + <java classname="${parallel.test.runner}" dir="${basedir}" classpath="${build.test.classes.dir}" failonerror="true" fork="true"> 1.291 + <jvmarg line="${ext.class.path}"/> 1.292 + <jvmarg line="${run.test.jvmargs} ${run.test.jvmsecurityargs}"/> 1.293 + <syspropertyset> 1.294 + <propertyref prefix="test-sys-prop."/> 1.295 + <mapper type="glob" from="test-sys-prop.*" to="*"/> 1.296 + </syspropertyset> 1.297 + </java> 1.298 + </target> 1.299 + 1.300 + <target name="test262" depends="jar, check-testng, check-external-tests, compile-test" if="testng.available"> 1.301 + <fileset id="test.classes" dir="${build.test.classes.dir}"> 1.302 + <include name="**/framework/*Test.class"/> 1.303 + </fileset> 1.304 + 1.305 + <testng outputdir="${build.test.results.dir}" classfilesetref="test.classes" 1.306 + verbose="${testng.verbose}" haltonfailure="true" useDefaultListeners="false" listeners="${testng.listeners}" workingDir="${basedir}"> 1.307 + <jvmarg line="${ext.class.path}"/> 1.308 + <jvmarg line="${run.test.jvmargs}"/> 1.309 + <propertyset> 1.310 + <propertyref prefix="test262-test-sys-prop."/> 1.311 + <mapper from="test262-test-sys-prop.*" to="*" type="glob"/> 1.312 + </propertyset> 1.313 + <classpath> 1.314 + <pathelement path="${run.test.classpath}"/> 1.315 + </classpath> 1.316 + </testng> 1.317 + </target> 1.318 + 1.319 + <target name="test262parallel" depends="test262-parallel"/> 1.320 + 1.321 + <target name="test262-parallel" depends="jar, check-testng, check-external-tests, compile-test" if="testng.available"> 1.322 + <!-- use just build.test.classes.dir to avoid referring to TestNG --> 1.323 + <java classname="${parallel.test.runner}" dir="${basedir}" classpath="${build.test.classes.dir}" fork="true"> 1.324 + <jvmarg line="${ext.class.path}"/> 1.325 + <jvmarg line="${run.test.jvmargs}"/> 1.326 + <syspropertyset> 1.327 + <propertyref prefix="test262-test-sys-prop."/> 1.328 + <mapper type="glob" from="test262-test-sys-prop.*" to="*"/> 1.329 + </syspropertyset> 1.330 + </java> 1.331 + </target> 1.332 + 1.333 + <target name="all" depends="test, docs" 1.334 + description="Build, test and generate docs for nashorn"/> 1.335 + 1.336 + <target name="run" depends="jar" 1.337 + description="Run the shell with a sample script"> 1.338 + <java classname="${nashorn.shell.tool}" fork="true" dir="samples"> 1.339 + <jvmarg line="${ext.class.path}"/> 1.340 + <jvmarg line="${run.test.jvmargs}"/> 1.341 + <arg value="-dump-on-error"/> 1.342 + <arg value="test.js"/> 1.343 + </java> 1.344 + </target> 1.345 + 1.346 + <target name="debug" depends="jar" 1.347 + description="Debug the shell with a sample script"> 1.348 + <java classname="${nashorn.shell.tool}" fork="true" dir="samples"> 1.349 + <jvmarg line="${ext.class.path}"/> 1.350 + <jvmarg line="${run.test.jvmargs}"/> 1.351 + <arg value="--print-code"/> 1.352 + <arg value="--verify-code"/> 1.353 + <arg value="--print-symbols"/> 1.354 + <jvmarg value="-Dnashorn.codegen.debug=true"/> 1.355 + <arg value="test.js"/> 1.356 + </java> 1.357 + </target> 1.358 +</project>