16147
|
1 |
<?xml version="1.0" encoding="UTF-8"?>
|
|
2 |
<!--
|
|
3 |
Copyright (c) 2010, 2012, 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 |
</target>
|
|
35 |
|
|
36 |
<target name="prepare" depends="init">
|
|
37 |
<mkdir dir="${build.dir}"/>
|
|
38 |
<mkdir dir="${build.classes.dir}"/>
|
|
39 |
<mkdir dir="${build.classes.dir}/META-INF/services"/>
|
|
40 |
<mkdir dir="${build.test.classes.dir}"/>
|
|
41 |
<mkdir dir="${dist.dir}"/>
|
|
42 |
<mkdir dir="${dist.javadoc.dir}"/>
|
|
43 |
<!-- check if JDK already has ASM classes -->
|
|
44 |
<available property="asm.available" classname="jdk.internal.org.objectweb.asm.Type"/>
|
|
45 |
<!-- check if testng.jar is avaiable -->
|
|
46 |
<available property="testng.available" file="${file.reference.testng.jar}"/>
|
|
47 |
</target>
|
|
48 |
|
|
49 |
<target name="clean" depends="init, clean-nasgen">
|
|
50 |
<delete includeemptydirs="true">
|
|
51 |
<fileset dir="${build.dir}" excludes="${dynalink.dir.name}/**/*" erroronmissingdir="false"/>
|
|
52 |
</delete>
|
|
53 |
<delete dir="${dist.dir}"/>
|
|
54 |
</target>
|
|
55 |
|
|
56 |
<target name="clean-dynalink">
|
|
57 |
<delete dir="${dynalink.dir}"/>
|
|
58 |
</target>
|
|
59 |
|
|
60 |
<target name="clean-all" depends="clean-dynalink, clean">
|
|
61 |
<delete dir="${build.dir}"/>
|
|
62 |
</target>
|
|
63 |
|
|
64 |
<!-- do it only if ASM is not available -->
|
|
65 |
<target name="compile-asm" depends="prepare" unless="asm.available">
|
|
66 |
<javac srcdir="${asm.src.dir}"
|
|
67 |
destdir="${build.classes.dir}"
|
|
68 |
excludes="**/optimizer/* **/xml/* **/attrs/*"
|
|
69 |
source="${javac.source}"
|
|
70 |
target="${javac.target}"
|
|
71 |
debug="${javac.debug}"
|
|
72 |
encoding="${javac.encoding}"
|
|
73 |
includeantruntime="false"/>
|
|
74 |
</target>
|
|
75 |
|
|
76 |
<target name="check-dynalink-uptodate" depends="init">
|
|
77 |
<property name="versioned.dynalink.jar" value="${dynalink.dir}/dynalink-${dynalink.jar.version}.jar"/>
|
|
78 |
<condition property="dynalink.uptodate">
|
|
79 |
<and>
|
|
80 |
<available file="${versioned.dynalink.jar}"/>
|
|
81 |
<filesmatch file1="${versioned.dynalink.jar}" file2="${dynalink.jar}"/>
|
|
82 |
</and>
|
|
83 |
</condition>
|
|
84 |
</target>
|
|
85 |
|
|
86 |
<target name="get-dynalink" depends="check-dynalink-uptodate" unless="dynalink.uptodate">
|
|
87 |
<mkdir dir="${dynalink.dir}"/>
|
|
88 |
<!-- Delete previous snapshots, if any -->
|
|
89 |
<delete>
|
|
90 |
<fileset dir="${dynalink.dir}" includes="*"/>
|
|
91 |
</delete>
|
|
92 |
<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}"/>
|
|
93 |
<get src="${dynalink.download.base.url}.jar" dest="${versioned.dynalink.jar}" usetimestamp="true"/>
|
|
94 |
<get src="${dynalink.download.base.url}-sources.jar" dest="${dynalink.dir}/dynalink-sources.jar" usetimestamp="true"/>
|
|
95 |
<copy file="${versioned.dynalink.jar}" tofile="${dynalink.jar}" overwrite="true"/>
|
|
96 |
</target>
|
|
97 |
|
|
98 |
<target name="compile" depends="compile-asm, get-dynalink" description="Compiles nashorn">
|
|
99 |
<javac srcdir="${src.dir}"
|
|
100 |
destdir="${build.classes.dir}"
|
|
101 |
classpath="${javac.classpath}"
|
|
102 |
source="${javac.source}"
|
|
103 |
target="${javac.target}"
|
|
104 |
debug="${javac.debug}"
|
|
105 |
encoding="${javac.encoding}"
|
|
106 |
includeantruntime="false">
|
|
107 |
<compilerarg value="-Xlint:unchecked"/>
|
|
108 |
<compilerarg value="-Xlint:deprecation"/>
|
|
109 |
<compilerarg value="-XDignore.symbol.file"/>
|
|
110 |
</javac>
|
|
111 |
<copy todir="${build.classes.dir}/META-INF/services">
|
|
112 |
<fileset dir="${meta.inf.dir}/services/"/>
|
|
113 |
</copy>
|
|
114 |
<copy todir="${build.classes.dir}/jdk/nashorn/api/scripting/resources">
|
|
115 |
<fileset dir="${src.dir}/jdk/nashorn/api/scripting/resources/"/>
|
|
116 |
</copy>
|
|
117 |
<copy todir="${build.classes.dir}/jdk/nashorn/internal/runtime/resources">
|
|
118 |
<fileset dir="${src.dir}/jdk/nashorn/internal/runtime/resources/"/>
|
|
119 |
</copy>
|
|
120 |
<copy todir="${build.classes.dir}/jdk/nashorn/tools/resources">
|
|
121 |
<fileset dir="${src.dir}/jdk/nashorn/tools/resources/"/>
|
|
122 |
</copy>
|
|
123 |
<echo message="full=${nashorn.fullversion}" file="${build.classes.dir}/jdk/nashorn/internal/runtime/resources/version.properties"/>
|
|
124 |
<echo file="${build.classes.dir}/jdk/nashorn/internal/runtime/resources/version.properties" append="true">${line.separator}</echo>
|
|
125 |
<echo message="release=${nashorn.version}" file="${build.classes.dir}/jdk/nashorn/internal/runtime/resources/version.properties" append="true"/>
|
|
126 |
</target>
|
|
127 |
|
|
128 |
<target name="jar" depends="compile, run-nasgen" description="Creates nashorn.jar">
|
|
129 |
<jar jarfile="${dist.jar}" manifest="${meta.inf.dir}/MANIFEST.MF" index="true" filesetmanifest="merge">
|
|
130 |
<fileset dir="${build.classes.dir}"/>
|
|
131 |
<zipfileset src="${dynalink.jar}"/>
|
|
132 |
<manifest>
|
|
133 |
<attribute name="Archiver-Version" value="n/a"/>
|
|
134 |
<attribute name="Build-Jdk" value="${java.runtime.version}"/>
|
|
135 |
<attribute name="Built-By" value="n/a"/>
|
|
136 |
<attribute name="Created-By" value="Ant jar task"/>
|
|
137 |
<section name="jdk/nashorn/">
|
|
138 |
<attribute name="Implementation-Title" value="${nashorn.product.name}"/>
|
|
139 |
<attribute name="Implementation-Version" value="${nashorn.version}"/>
|
|
140 |
</section>
|
|
141 |
</manifest>
|
|
142 |
</jar>
|
|
143 |
</target>
|
|
144 |
|
|
145 |
<target name="javadoc" depends="compile-asm">
|
|
146 |
<javadoc destdir="${dist.javadoc.dir}" private="yes" use="yes" overview="src/overview.html" windowtitle="${nashorn.product.name} ${nashorn.version}">
|
|
147 |
<classpath>
|
|
148 |
<pathelement location="${build.classes.dir}"/>
|
|
149 |
<pathelement location="${dynalink.jar}"/>
|
|
150 |
</classpath>
|
|
151 |
<fileset dir="${src.dir}" includes="**/*.java"/>
|
|
152 |
<link href="http://docs.oracle.com/javase/7/docs/api"/>
|
|
153 |
<link href="http://szegedi.github.com/dynalink/0.4/javadoc"/>
|
|
154 |
</javadoc>
|
|
155 |
</target>
|
|
156 |
|
|
157 |
<!-- generate shell.html for shell tool documentation -->
|
|
158 |
<target name="shelldoc" depends="jar">
|
|
159 |
<java classname="${nashorn.shell.tool}" dir="${basedir}" output="${dist.dir}/shell.html" failonerror="true" fork="true">
|
|
160 |
<jvmarg line="${ext.class.path}"/>
|
|
161 |
<arg value="-scripting"/>
|
|
162 |
<arg value="docs/genshelldoc.js"/>
|
|
163 |
</java>
|
|
164 |
</target>
|
|
165 |
|
|
166 |
<!-- generate all docs -->
|
|
167 |
<target name="docs" depends="javadoc, shelldoc"/>
|
|
168 |
|
|
169 |
<!-- create .zip and .tar.gz for nashorn binaries and scripts. -->
|
|
170 |
<target name="dist" depends="jar">
|
|
171 |
<zip destfile="${build.zip}" basedir=".."
|
|
172 |
excludes="nashorn/bin/*.sh" includes="nashorn/bin/** nashorn/dist/**"/>
|
|
173 |
<tar destfile="${build.gzip}" basedir=".." compression="gzip"
|
|
174 |
excludes="nashorn/bin/*.sh" includes="nashorn/bin/** nashorn/dist/**"/>
|
|
175 |
</target>
|
|
176 |
|
|
177 |
<target name="compile-test" depends="compile, run-nasgen" if="testng.available">
|
|
178 |
<!-- testng task -->
|
|
179 |
<taskdef name="testng" classname="org.testng.TestNGAntTask"
|
|
180 |
classpath="${file.reference.testng.jar}"/>
|
|
181 |
|
|
182 |
<javac srcdir="${test.src.dir}"
|
|
183 |
destdir="${build.test.classes.dir}"
|
|
184 |
classpath="${javac.test.classpath}"
|
|
185 |
source="${javac.source}"
|
|
186 |
target="${javac.target}"
|
|
187 |
debug="${javac.debug}"
|
|
188 |
encoding="${javac.encoding}"
|
|
189 |
includeantruntime="false"/>
|
|
190 |
</target>
|
|
191 |
|
|
192 |
<target name="generate-policy-file">
|
|
193 |
<!-- Generating nashorn.policy file -->
|
|
194 |
<echo message="grant codeBase "file:/${basedir}/dist/nashorn.jar" {" file="${build.dir}/nashorn.policy"/>
|
|
195 |
<echo message="" file="${build.dir}/nashorn.policy" append="true"/>
|
|
196 |
<echo message="permission java.security.AllPermission;" file="${build.dir}/nashorn.policy" append="true"/>
|
|
197 |
<echo message="" 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 |
|
|
201 |
<echo message="grant codeBase "file:/${basedir}/build/test/classes" {" file="${build.dir}/nashorn.policy" append="true"/>
|
|
202 |
<echo message="" file="${build.dir}/nashorn.policy" append="true"/>
|
|
203 |
<echo message=" permission java.security.AllPermission;" file="${build.dir}/nashorn.policy" append="true"/>
|
|
204 |
<echo message="" file="${build.dir}/nashorn.policy" append="true"/>
|
|
205 |
<echo message="};" file="${build.dir}/nashorn.policy" append="true"/>
|
|
206 |
<echo message="" file="${build.dir}/nashorn.policy" append="true"/>
|
|
207 |
|
|
208 |
<echo message="grant codeBase "file:/${basedir}/${file.reference.testng.jar}" {" file="${build.dir}/nashorn.policy" append="true"/>
|
|
209 |
<echo message="" file="${build.dir}/nashorn.policy" append="true"/>
|
|
210 |
<echo message=" permission java.security.AllPermission;" file="${build.dir}/nashorn.policy" append="true"/>
|
|
211 |
<echo message="" file="${build.dir}/nashorn.policy" append="true"/>
|
|
212 |
<echo message="};" file="${build.dir}/nashorn.policy" append="true"/>
|
|
213 |
<echo message="" file="${build.dir}/nashorn.policy" append="true"/>
|
|
214 |
|
|
215 |
<echo message="grant codeBase "file:/${basedir}/test/script/basic/*" {" file="${build.dir}/nashorn.policy" append="true"/>
|
|
216 |
<echo message="" file="${build.dir}/nashorn.policy" append="true"/>
|
|
217 |
<echo message=" permission java.security.AllPermission;" 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 |
<echo message="" file="${build.dir}/nashorn.policy" append="true"/>
|
|
221 |
|
|
222 |
<echo message="grant codeBase "file:/${basedir}/test/perf/*" {" file="${build.dir}/nashorn.policy" append="true"/>
|
|
223 |
<echo message="" file="${build.dir}/nashorn.policy" append="true"/>
|
|
224 |
<echo message=" permission java.security.AllPermission;" file="${build.dir}/nashorn.policy" append="true"/>
|
|
225 |
<echo message="" file="${build.dir}/nashorn.policy" append="true"/>
|
|
226 |
<echo message="};" file="${build.dir}/nashorn.policy" append="true"/>
|
|
227 |
<echo message="" file="${build.dir}/nashorn.policy" append="true"/>
|
|
228 |
|
|
229 |
<replace file="${build.dir}/nashorn.policy"><replacetoken>\</replacetoken><replacevalue>/</replacevalue></replace> <!--hack for Windows - to make URLs with normal path separators -->
|
|
230 |
<replace file="${build.dir}/nashorn.policy"><replacetoken>//</replacetoken><replacevalue>/</replacevalue></replace> <!--hack for Unix - to avoid leading // in URLs -->
|
|
231 |
|
|
232 |
</target>
|
|
233 |
|
|
234 |
<target name="check-external-tests">
|
|
235 |
<available file="${test.external.dir}/prototype" property="test-sys-prop.external.prototype"/>
|
|
236 |
<available file="${test.external.dir}/sunspider" property="test-sys-prop.external.sunspider"/>
|
|
237 |
<available file="${test.external.dir}/underscore" property="test-sys-prop.external.underscore"/>
|
|
238 |
<available file="${test.external.dir}/octane" property="test-sys-prop.external.octane"/>
|
|
239 |
<available file="${test.external.dir}/yui" property="test-sys-prop.external.yui"/>
|
|
240 |
<available file="${test.external.dir}/jquery" property="test-sys-prop.external.jquery"/>
|
|
241 |
<available file="${test.external.dir}/test262" property="test-sys-prop.external.test262"/>
|
|
242 |
</target>
|
|
243 |
|
|
244 |
<target name="check-testng" unless="testng.available">
|
|
245 |
<echo message="WARNING: TestNG not available, will not run tests. Please copy testng.jar under test/lib directory."/>
|
|
246 |
</target>
|
|
247 |
|
|
248 |
<target name="test" depends="jar, check-testng, check-external-tests, compile-test, generate-policy-file" if="testng.available">
|
|
249 |
<java classname="${nashorn.shell.tool}" fork="true" dir="${test.script.dir}/representations" output="${build.dir}/output1.log" error="${build.dir}/err.log">
|
|
250 |
<jvmarg line="${ext.class.path}"/>
|
|
251 |
<jvmarg line="-Dnashorn.fields.dual=true"/>
|
|
252 |
<arg value="NASHORN-592a.js"/>
|
|
253 |
</java>
|
|
254 |
<java classname="${nashorn.shell.tool}" fork="true" dir="${test.script.dir}/representations" output="${build.dir}/output2.log" error="${build.dir}/err.log">
|
|
255 |
<jvmarg line="${ext.class.path}"/>
|
|
256 |
<arg value="NASHORN-592a.js"/>
|
|
257 |
</java>
|
|
258 |
<condition property="representation-ok">
|
|
259 |
<filesmatch file1="${build.dir}/output1.log" file2="${build.dir}/output2.log"/>
|
|
260 |
</condition>
|
|
261 |
<fail unless="representation-ok">Representation test failed - output differs!</fail>
|
|
262 |
<fileset id="test.classes" dir="${build.test.classes.dir}">
|
|
263 |
<include name="**/access/*Test.class"/>
|
|
264 |
<include name="**/api/scripting/*Test.class"/>
|
|
265 |
<include name="**/codegen/*Test.class"/>
|
|
266 |
<include name="**/parser/*Test.class"/>
|
|
267 |
<include name="**/runtime/*Test.class"/>
|
|
268 |
<include name="**/framework/*Test.class"/>
|
|
269 |
</fileset>
|
|
270 |
|
|
271 |
<testng outputdir="${build.test.results.dir}" classfilesetref="test.classes"
|
|
272 |
verbose="${testng.verbose}" haltonfailure="true" useDefaultListeners="false" listeners="${testng.listeners}" workingDir="${basedir}">
|
|
273 |
<jvmarg line="${ext.class.path}"/>
|
|
274 |
<jvmarg line="${run.test.jvmargs} ${run.test.jvmsecurityargs}"/>
|
|
275 |
<propertyset>
|
|
276 |
<propertyref prefix="test-sys-prop."/>
|
|
277 |
<mapper from="test-sys-prop.*" to="*" type="glob"/>
|
|
278 |
</propertyset>
|
|
279 |
<classpath>
|
|
280 |
<pathelement path="${run.test.classpath}"/>
|
|
281 |
</classpath>
|
|
282 |
</testng>
|
|
283 |
</target>
|
|
284 |
|
|
285 |
<target name="test-basicparallel" depends="jar, check-testng, check-external-tests, compile-test, generate-policy-file">
|
|
286 |
<!-- use just build.test.classes.dir to avoid referring to TestNG -->
|
|
287 |
<java classname="${parallel.test.runner}" dir="${basedir}" classpath="${build.test.classes.dir}" failonerror="true" fork="true">
|
|
288 |
<jvmarg line="${ext.class.path}"/>
|
|
289 |
<jvmarg line="${run.test.jvmargs} ${run.test.jvmsecurityargs}"/>
|
|
290 |
<syspropertyset>
|
|
291 |
<propertyref prefix="test-sys-prop."/>
|
|
292 |
<mapper type="glob" from="test-sys-prop.*" to="*"/>
|
|
293 |
</syspropertyset>
|
|
294 |
</java>
|
|
295 |
</target>
|
|
296 |
|
|
297 |
<target name="test262" depends="jar, check-testng, check-external-tests, compile-test" if="testng.available">
|
|
298 |
<fileset id="test.classes" dir="${build.test.classes.dir}">
|
|
299 |
<include name="**/framework/*Test.class"/>
|
|
300 |
</fileset>
|
|
301 |
|
|
302 |
<testng outputdir="${build.test.results.dir}" classfilesetref="test.classes"
|
|
303 |
verbose="${testng.verbose}" haltonfailure="true" useDefaultListeners="false" listeners="${testng.listeners}" workingDir="${basedir}">
|
|
304 |
<jvmarg line="${ext.class.path}"/>
|
|
305 |
<jvmarg line="${run.test.jvmargs}"/>
|
|
306 |
<propertyset>
|
|
307 |
<propertyref prefix="test262-test-sys-prop."/>
|
|
308 |
<mapper from="test262-test-sys-prop.*" to="*" type="glob"/>
|
|
309 |
</propertyset>
|
|
310 |
<classpath>
|
|
311 |
<pathelement path="${run.test.classpath}"/>
|
|
312 |
</classpath>
|
|
313 |
</testng>
|
|
314 |
</target>
|
|
315 |
|
|
316 |
<target name="test262parallel" depends="test262-parallel"/>
|
|
317 |
|
|
318 |
<target name="test262-parallel" depends="jar, check-testng, check-external-tests, compile-test" if="testng.available">
|
|
319 |
<!-- use just build.test.classes.dir to avoid referring to TestNG -->
|
|
320 |
<java classname="${parallel.test.runner}" dir="${basedir}" classpath="${build.test.classes.dir}" fork="true">
|
|
321 |
<jvmarg line="${ext.class.path}"/>
|
|
322 |
<jvmarg line="${run.test.jvmargs}"/>
|
|
323 |
<syspropertyset>
|
|
324 |
<propertyref prefix="test262-test-sys-prop."/>
|
|
325 |
<mapper type="glob" from="test262-test-sys-prop.*" to="*"/>
|
|
326 |
</syspropertyset>
|
|
327 |
</java>
|
|
328 |
</target>
|
|
329 |
|
|
330 |
<target name="all" depends="test, docs"
|
|
331 |
description="Build, test and generate docs for nashorn"/>
|
|
332 |
|
|
333 |
<target name="run" depends="jar"
|
|
334 |
description="Run the shell with a sample script">
|
|
335 |
<java classname="${nashorn.shell.tool}" fork="true" dir="samples">
|
|
336 |
<jvmarg line="${ext.class.path}"/>
|
|
337 |
<jvmarg line="${run.test.jvmargs}"/>
|
|
338 |
<arg value="-dump-on-error"/>
|
|
339 |
<arg value="test.js"/>
|
|
340 |
</java>
|
|
341 |
</target>
|
|
342 |
|
|
343 |
<target name="debug" depends="jar"
|
|
344 |
description="Debug the shell with a sample script">
|
|
345 |
<java classname="${nashorn.shell.tool}" fork="true" dir="samples">
|
|
346 |
<jvmarg line="${ext.class.path}"/>
|
|
347 |
<jvmarg line="${run.test.jvmargs}"/>
|
|
348 |
<arg value="--print-code"/>
|
|
349 |
<arg value="--verify-code"/>
|
|
350 |
<arg value="--print-symbols"/>
|
|
351 |
<jvmarg value="-Dnashorn.codegen.debug=true"/>
|
|
352 |
<arg value="test.js"/>
|
|
353 |
</java>
|
|
354 |
</target>
|
|
355 |
</project>
|