1<?xml version="1.0" encoding="utf-8"?> 2<!-- This Source Code Form is subject to the terms of the Mozilla Public 3 - License, v. 2.0. If a copy of the MPL was not distributed with this 4 - file, You can obtain one at http://mozilla.org/MPL/2.0/. --> 5 6 7<!-- 8 Build file for Rhino using Ant (see http://jakarta.apache.org/ant/index.html) 9 Requires Ant version 1.2 or later 10 11 Compilation currently requires JDK 1.5 or later. Can cross-compile to 12 support JDK 1.4. 13--> 14 15<project name="Rhino" default="help" basedir="."> 16 17 <target name="properties"> 18 <!-- Allow user to override default settings from build.properties --> 19 <property file="build.local.properties" /> 20 <tstamp> 21 <!-- Specify date part of Context#getImplementationVersion() --> 22 <format property="implementation.date" pattern="yyyy MM dd"/> 23 </tstamp> 24 <property file="build.properties"/> 25 26 <property name="dist.file" value="rhino${version}.zip"/> 27 <property name="dist.source-only-zip" value="rhino${version}-sources.zip"/> 28 29 <property file="apiClasses.properties"/> 30 <property name="xmlimplsrc-build-file" 31 location="xmlimplsrc/build.xml"/> 32 33 <available property="xmlimplsrc-present?" 34 file="${xmlimplsrc-build-file}" /> 35 36 </target> 37 38 <target name="init" depends="properties"> 39 <mkdir dir="${build.dir}"/> 40 <mkdir dir="${classes}"/> 41 <mkdir dir="${dist.dir}"/> 42 </target> 43 44 <target name="compile" depends="init"> 45 <ant antfile="src/build.xml" target="compile"/> 46 <ant antfile="toolsrc/build.xml" target="compile"/> 47 <antcall target="xmlimplsrc-compile" /> 48 </target> 49 50 <target name="compile-all" depends="compile"> 51 <ant antfile="deprecatedsrc/build.xml" target="compile"/> 52 </target> 53 54 <target name="graph" depends="init"> 55 <ant antfile="src/build.xml" target="graph"/> 56 </target> 57 58 <target name="shell" depends="compile"> 59 <ant antfile="src/build.xml" target="shell"/> 60 </target> 61 62 <target name="copy-source" depends="init"> 63 <ant antfile="src/build.xml" target="copy-source"/> 64 <ant antfile="toolsrc/build.xml" target="copy-source"/> 65 <ant antfile="testsrc/build.xml" target="copy-source"/> 66 <antcall target="xmlimplsrc-copy-source" /> 67 <ant antfile="deprecatedsrc/build.xml" target="copy-source"/> 68 <copy todir="${dist.dir}" file="build.xml"/> 69 <copy todir="${dist.dir}" file="build.properties"/> 70 <copy todir="${dist.dir}" file="apiClasses.properties"/> 71 <copy todir="${dist.dir}" file="LICENSE.txt"/> 72 </target> 73 74 <target name="xmlimplsrc-compile" if="xmlimplsrc-present?"> 75 <echo>Calling ${xmlimplsrc-build-file}</echo> 76 <!-- Ignore compilation errors under JDK less then 1.4 --> 77 <property name="xmlimpl.compile.failonerror" value="no"/> 78 <ant antfile="${xmlimplsrc-build-file}" target="compile"/> 79 </target> 80 81 <target name="xmlimplsrc-copy-source" if="xmlimplsrc-present?"> 82 <echo>Calling ${xmlimplsrc-build-file}</echo> 83 <ant antfile="${xmlimplsrc-build-file}" target="copy-source"/> 84 </target> 85 86 <target name="jar" depends="compile-all"> 87 <copy todir="${classes}" file="LICENSE.txt"/> 88 <property name="jarfile" location="${dist.dir}/${rhino.jar}"/> 89 <jar jarfile="${jarfile}" 90 basedir="${classes}" 91 manifest="src/manifest" 92 compress="${jar-compression}" 93 /> 94 </target> 95 96 <target name="console" depends="jar"> 97 <property name="jarfile" location="${dist.dir}/${rhino.jar}"/> 98 <java jar="${jarfile}" 99 fork="true"> 100 <arg line="-version 170"/> 101 </java> 102 </target> 103 104 <target name="retrotranslator" depends="retrotranslator-check,retrotranslator-download"> 105 <taskdef name="retrotranslator" classpath="build/download/Retrotranslator-1.2.8-bin/retrotranslator-transformer-1.2.8.jar" 106 classname="net.sf.retrotranslator.transformer.RetrotranslatorTask"/> 107 </target> 108 109 110 <target name="retrotranslator-check"> 111 <condition property="retrotranslator.available"> 112 <and> 113 <available file="build/download/Retrotranslator-1.2.8-bin/retrotranslator-transformer-1.2.8.jar"/> 114 <available file="build/download/Retrotranslator-1.2.8-bin/retrotranslator-runtime-1.2.8.jar"/> 115 <available file="build/download/Retrotranslator-1.2.8-bin/backport-util-concurrent-3.1.jar"/> 116 </and> 117 </condition> 118 </target> 119 120 <target name="retrotranslator-download" unless="retrotranslator.available"> 121 <mkdir dir="build/download"/> 122 <get src="http://downloads.sourceforge.net/retrotranslator/Retrotranslator-1.2.8-bin.zip" dest="build/download/Retrotranslator-1.2.8-bin.zip" usetimestamp="true"/> 123 <unzip src="build/download/Retrotranslator-1.2.8-bin.zip" dest="build/download"/> 124 </target> 125 126 <target name="retrojar" depends="jar,retrotranslator"> 127 <retrotranslator 128 srcjar="${jarfile}" 129 destjar="${dist.dir}/${rhino-14.jar}" 130 embed="org.mozilla.javascript" 131 /> 132 </target> 133 134 <target name="smalljar" depends="compile"> 135 <property name="smalljarfile" location="${dist.dir}/${small-rhino.jar}"/> 136 <jar basedir="${classes}" destfile="${smalljarfile}" 137 compress="${jar-compression}"> 138 <include name="org/mozilla/javascript/*.class"/> 139 140 <include name="org/mozilla/javascript/debug/*.class"/> 141 <include name="org/mozilla/javascript/resources/*.properties"/> 142 <include name="org/mozilla/javascript/xml/*.class"/> 143 <include name="org/mozilla/javascript/continuations/*.class"/> 144 <include name="org/mozilla/javascript/jdk13/*.class"/> 145 <include name="org/mozilla/javascript/ast/*.class"/> 146 <include name="org/mozilla/javascript/json/*.class"/> 147 <include name="org/mozilla/javascript/annotations/*.class"/> 148 <include name="org/mozilla/javascript/v8dtoa/*.class"/> 149 150 <!-- exclude classes that uses class generation library --> 151 <exclude name="org/mozilla/javascript/JavaAdapter*.class"/> 152 153 <include name="org/mozilla/javascript/regexp/*.class" 154 unless="no-regexp"/> 155 </jar> 156 157 </target> 158 159 <target name="retrosmalljar" depends="smalljar,retrotranslator"> 160 <retrotranslator 161 srcjar="${smalljarfile}" 162 destjar="${dist.dir}/${small-rhino-14.jar}" 163 embed="org.mozilla.javascript" 164 /> 165 </target> 166 167 <target name="copy-examples" depends="init"> 168 <mkdir dir="${dist.dir}/examples"/> 169 <copy todir="${dist.dir}/examples"> 170 <fileset dir="examples" includes="**/*.java,**/*.js,**/*.html" /> 171 </copy> 172 </target> 173 174 <target name="copy-misc" depends="init"> 175 <filter token="datestamp" value="${TODAY}"/> 176 <copy todir="${dist.dir}" filtering="yes"> 177 <fileset dir="."> 178 <patternset> 179 <include name="build-date"/> 180 </patternset> 181 </fileset> 182 </copy> 183 </target> 184 185 <target name="copy-all" depends="copy-source,copy-examples,copy-misc"> 186 </target> 187 188 <target name="javadoc" depends="init"> 189 <mkdir dir="${dist.dir}/javadoc"/> 190 <javadoc sourcefiles="${apiClasses}" 191 sourcepath="src" 192 destdir="${dist.dir}/javadoc" 193 version="true" 194 author="true" 195 windowtitle="${Name}" /> 196 </target> 197 198 <target name="dev-javadoc" depends="init"> 199 <mkdir dir="${dist.dir}/javadoc"/> 200 <javadoc sourcepath="src" 201 destdir="${dist.dir}/javadoc" 202 version="true" 203 package="true" 204 author="true" 205 windowtitle="${Name}"> 206 <fileset 207 dir="." 208 includes="**/*.java" 209 excludes="**/deprecatedsrc/**/*.java,**/testsrc/**/*.java" 210 /> 211 </javadoc> 212 </target> 213 214 <!-- 215 Compiles and tests all sources and then creates the distribution file 216 --> 217 <target name="all" depends="deepclean,compile-all,junit-all,dist"> 218 </target> 219 220 <target name="dist" depends="deepclean,jar,retrojar,copy-all,javadoc"> 221 <delete file="${dist.file}" /> 222 <zip destfile="${dist.file}"> 223 <fileset dir="${build.dir}" includes="${dist.name}/**"/> 224 </zip> 225 </target> 226 227 <target name="source-zip" depends="copy-source,copy-examples,javadoc"> 228 <delete file="${dist.source-only-zip}" /> 229 <zip destfile="${dist.source-only-zip}"> 230 <zipfileset prefix="${dist.name}" dir="${dist.dir}"> 231 <include name="*src/**"/> 232 <include name="build.xml"/> 233 <include name="*.properties"/> 234 <include name="examples/**"/> 235 </zipfileset> 236 </zip> 237 </target> 238 239 <target name="compile-debugger"> 240 <ant antfile="toolsrc/build.xml" target="compile-debugger"/> 241 </target> 242 243 <target name="clean" depends="properties"> 244 <delete quiet="true" file="${dist.dir}/${rhino.jar}"/> 245 <delete quiet="true" file="${dist.dir}/${small-rhino.jar}"/> 246 <delete quiet="true" dir="${build.dir}"/> 247 </target> 248 249 <target name="deepclean" depends="properties"> 250 <delete quiet="true" dir="${build.dir}"/> 251 <delete quiet="true" file="${dist.file}"/> 252 <delete quiet="true" file="${dist.source-only-zip}"/> 253 </target> 254 255 <!-- 256 The next two targets run the JavaScript Test Library tests. Note that these tests are quite extensive and take a long time 257 to run. They are not documented in the 'help' target for now. 258 --> 259 260 <!-- 261 Run the tests using JUnit. Beware that if you are using Ant from the command-line, there are some difficulties you may 262 encounter setting this up correctly; see http://ant.apache.org/faq.html#delegating-classloader 263 264 IDEs that use Ant as the build system probably handle this fine. 265 --> 266 <target name="junit-all" depends="compile"> 267 <ant antfile="testsrc/build.xml" target="junit-coveragereport"/> 268 </target> 269 270 <!-- 271 Run the tests using the Java port of jsdriver.pl. Note that running this port 272 from the command-line may be more useful running this Ant target, as running 273 from the command line allows configuration options, such as running with a 274 non-default optimization level, or running only a subset of the tests. 275 --> 276 <target name="jsdriver-run" depends="compile"> 277 <ant antfile="testsrc/build.xml" target="jsdriver" /> 278 </target> 279 280 <!-- 281 Compile the JsDriver test driver. 282 --> 283 <target name="jsdriver" depends="compile"> 284 <ant antfile="testsrc/build.xml" target="clean" /> 285 <ant antfile="testsrc/build.xml" target="compile" /> 286 </target> 287 288 <target name="benchmark-v8-opt-1" depends="jar"> 289 <property name="jarfile" location="${dist.dir}/${rhino.jar}"/> 290 <java jar="${jarfile}" dir="testsrc/benchmarks/v8-benchmarks-v5" fork="true"> 291 <jvmarg value="-server"/> 292 <arg line="-opt -1 run.js"/> 293 </java> 294 </target> 295 296 <target name="benchmark-v8-opt0" depends="jar"> 297 <property name="jarfile" location="${dist.dir}/${rhino.jar}"/> 298 <java jar="${jarfile}" dir="testsrc/benchmarks/v8-benchmarks-v5" fork="true"> 299 <jvmarg value="-server"/> 300 <arg line="-opt 0 run.js"/> 301 </java> 302 </target> 303 304 <target name="benchmark-v8-opt9" depends="jar"> 305 <property name="jarfile" location="${dist.dir}/${rhino.jar}"/> 306 <java jar="${jarfile}" dir="testsrc/benchmarks/v8-benchmarks-v5" fork="true"> 307 <jvmarg value="-server"/> 308 <arg line="-opt 9 run.js"/> 309 </java> 310 </target> 311 312 <target name="benchmark-sunspider-opt-1" depends="jar"> 313 <property name="jarfile" location="${dist.dir}/${rhino.jar}"/> 314 <java jar="${jarfile}" dir="testsrc/benchmarks/sunspider-0.9.1" fork="true"> 315 <jvmarg value="-server"/> 316 <arg line="-opt -1 run.js"/> 317 </java> 318 </target> 319 320 <target name="benchmark-sunspider-opt0" depends="jar"> 321 <property name="jarfile" location="${dist.dir}/${rhino.jar}"/> 322 <java jar="${jarfile}" dir="testsrc/benchmarks/sunspider-0.9.1" fork="true"> 323 <jvmarg value="-server"/> 324 <arg line="-opt 0 run.js"/> 325 </java> 326 </target> 327 328 <target name="benchmark-sunspider-opt9" depends="jar"> 329 <property name="jarfile" location="${dist.dir}/${rhino.jar}"/> 330 <java jar="${jarfile}" dir="testsrc/benchmarks/sunspider-0.9.1" fork="true"> 331 <jvmarg value="-server"/> 332 <arg line="-opt 9 run.js"/> 333 </java> 334 </target> 335 336 <target name="help" depends="properties"> 337<echo>The following targets are available with this build file: 338 339 clean remove all compiled classes and copied property files 340 341 compile compile classes and copy all property files 342 into ${classes} directory 343 excluding deprecated code 344 345 compile-all compile all classes and copy all property files 346 into ${classes} directory 347 including deprecated code 348 349 deepclean remove all generated files and directories 350 351 dist create ${dist.file} with full Rhino distribution 352 353 help print this help 354 355 jar create ${rhino.jar} in ${dist.dir} 356 357 smalljar create ${small-rhino.jar} in ${dist.dir} with 358 minimalist set of Rhino classes. See footprint.html 359 from the doc directory for details. 360 361 javadoc generate Rhino API documentation 362 in ${dist.dir}/javadoc 363 364 source-zip create ${dist.source-only-zip} with all Rhino 365 source files necessary to recreate ${dist.file} 366</echo> 367 </target> 368 369</project> 370