blob: 621925ed6da1684fbc92243c58484ba3097af576 [file] [log] [blame]
<!--
* weinre is available under *either* the terms of the modified BSD license *or* the
* MIT License (2008). See http://opensource.org/licenses/alphabetical for full text.
*
* Copyright (c) 2010, 2011 IBM Corporation
-->
<project name="build" default="build" basedir=".">
<!-- ============================================================
set properties
============================================================ -->
<property file="personal.properties" />
<property file="build.properties" />
<property file="vendor.properties" />
<!-- hint: override in your personal.properties -->
<property name="BUILDER" value="The Unknown Builder"/>
<basename property="ant.file.basename" file="${ant.file}"/>
<available property="VENDOR_FOUND" file="${VENDOR}"/>
<tstamp>
<format property="TSTAMP_STARTED" pattern="HH:mm:ss"/>
</tstamp>
<tstamp>
<format property="BUILD_NUMBER_DATE" pattern="yyyy-MM-dd--HH-mm-ss" timezone="GMT"/>
</tstamp>
<property name="BUILD_NUMBER" value="${WEINRE_VERSION}build-${BUILD_NUMBER_DATE}"/>
<!-- ============================================================
main entry point
============================================================ -->
<target name="build" depends="build-dev">
<antcall target="build-jar"/>
<antcall target="build-ui-jar"/>
<antcall target="build-application-mac"/>
<antcall target="build-archives"/>
<echo>full ant build completed successfully</echo>
</target>
<!-- ============================================================
clean
============================================================ -->
<target name="clean">
<delete dir="${OUT}"/>
<mkdir dir="${OUT}"/> <!-- this is an Eclipse source folder! -->
<delete dir="${TMP}"/>
<delete dir="${CACHED}"/>
<delete dir="${VENDOR}"/>
</target>
<!-- ============================================================
development-time build
============================================================ -->
<target name="build-dev">
<delete dir="${OUT}"/>
<mkdir dir="${OUT}"/>
<property
name = "build-info-text"
value = "weinre build ${BUILD_NUMBER} by ${BUILDER}"
/>
<echo file="${OUT}/build-info.txt" message="${build-info-text}"/>
<antcall target="build-vendor"/>
<antcall target="compile-java"/>
<antcall target="build-web"/>
<antcall target="build-doc"/>
<antcall target="build-json-idl"/>
<antcall target="build-client"/>
<antcall target="build-target"/>
<tstamp>
<format property="TSTAMP_FINISHED" pattern="HH:mm:ss"/>
</tstamp>
<property name="MESSAGE_FINISHED" value="at ${TSTAMP_FINISHED} for ${ant.file}:build-dev"/>
<antcall target="finished"/>
<antcall target="finished-growl"/>
</target>
<!-- ============================================================
compile java code
============================================================ -->
<target name="compile-java" if="USE_JAVAC">
<delete dir="../${PROJECT_SERVER}/bin"/>
<mkdir dir="../${PROJECT_SERVER}/bin"/>
<javac
srcdir = "../${PROJECT_SERVER}/src"
destdir = "../${PROJECT_SERVER}/bin"
debug = "true"
verbose = "false"
includeAntRuntime = "false"
>
<classpath path="../${PROJECT_BUILD}/vendor/cli/commons-cli.jar"/>
<classpath path="../${PROJECT_BUILD}/vendor/jetty/jetty.jar"/>
<classpath path="../${PROJECT_BUILD}/vendor/json4j/json4j.jar"/>
<classpath path="../${PROJECT_BUILD}/vendor/jetty/servlet-api.jar"/>
<compilerarg value="-Xlint"/>
</javac>
<delete dir="../${PROJECT_APPLICATION}/bin"/>
<mkdir dir="../${PROJECT_APPLICATION}/bin"/>
<javac
srcdir = "../${PROJECT_APPLICATION}/src"
destdir = "../${PROJECT_APPLICATION}/bin"
debug = "true"
verbose = "false"
includeAntRuntime = "false"
>
<classpath path="../${PROJECT_SERVER}/bin"/>
<classpath path="../${PROJECT_BUILD}/vendor/json4j/json4j.jar"/>
<classpath path="../${PROJECT_BUILD}/vendor/swt/cocoa-macosx-x86_64/swt.jar"/>
<compilerarg value="-Xlint"/>
</javac>
</target>
<!-- ============================================================
build vendor libs
============================================================ -->
<target name="build-vendor" unless="VENDOR_FOUND">
<ant antfile="get-vendor.xml"/>
</target>
<!-- ============================================================
basic web resources
============================================================ -->
<target name="build-web">
<delete dir="${WEB}" />
<mkdir dir="${WEB}" />
<delete dir="${TMP}" />
<mkdir dir="${TMP}" />
<echo message="compiling scoop modules"/>
<exec executable="python" failonerror="true" failifexecutionfails="true">
<arg file="vendor/scooj/scoopc.py"/>
<arg value="--out"/>
<arg file="${TMP}/modules"/>
<arg file="../${PROJECT_WEB}/modules"/>
</exec>
<copy todir="${TMP}/modules">
<fileset file="${VENDOR}/scooj/scooj.js"/>
</copy>
<echo message="transportd-izing modules"/>
<exec executable="python" failonerror="true" failifexecutionfails="true">
<arg file="vendor/modjewel/module2transportd.py"/>
<arg value="--quiet"/>
<arg value="--out"/>
<arg file="${WEB}"/>
<arg file="${TMP}/modules"/>
</exec>
<copy todir="${WEB}">
<fileset file="${VENDOR}/modjewel/modjewel-require.js"/>
</copy>
<copy todir="${WEB}">
<fileset dir="../${PROJECT_WEB}">
<exclude name="versions.js"/>
<exclude name="common/**/*"/>
<exclude name="bin/**/*"/>
<include name="**/*.js"/>
<include name="**/*.css"/>
<include name="**/*.html"/>
<include name="**/*.png"/>
</fileset>
</copy>
<echo message="building InjectedScript.js"/>
<echo
file = "${WEB}/weinre/target/InjectedScript.js"
message = "var injectedScriptConstructor = ${line.separator}"
/>
<concat
destfile = "${WEB}/weinre/target/InjectedScript.js"
append = "true"
>
<fileset file="${VENDOR}/webkit/WebCore/inspector/InjectedScriptSource.js"/>
</concat>
<echo message="building versions.js"/>
<copy todir="${WEB}">
<fileset dir="../${PROJECT_WEB}">
<include name="versions.js"/>
</fileset>
<filterset>
<filter token="WEINRE_VERSION" value="${WEINRE_VERSION}"/>
<filter token="BUILD_NUMBER" value="${BUILD_NUMBER}"/>
<filter token="BUILD_NUMBER_DATE" value="${BUILD_NUMBER_DATE}"/>
<filter token="CLI_VERSION" value="${CLI_VERSION}"/>
<filter token="JSON4J_VERSION" value="${JSON4J_VERSION}"/>
<filter token="WEBKIT_VERSION" value="${WEBKIT_VERSION}"/>
<filter token="SWT_VERSION" value="${SWT_VERSION}"/>
<filter token="JETTY_VERSION" value="${JETTY_VERSION}"/>
<filter token="SCOOJ_VERSION" value="${SCOOJ_VERSION}"/>
<filter token="MODJEWEL_VERSION" value="${MODJEWEL_VERSION}"/>
<filter token="JAVAX_SERVLET_VERSION" value="${JAVAX_SERVLET_VERSION}"/>
<filter token="JAVAX_SERVLET_VERSION_IMPL" value="${JAVAX_SERVLET_VERSION_IMPL}"/>
</filterset>
</copy>
<echo message="building add-css-properties.js"/>
<exec executable="python" failonerror="true" failifexecutionfails="true">
<arg file="scripts/build-css-properties.py"/>
<arg value="vendor/webkit/WebCore/CSSPropertyNames.in"/>
<arg value="${WEB}/add-css-properties.js"/>
</exec>
</target>
<!-- ============================================================
documentation
============================================================ -->
<target name="build-doc">
<mkdir dir="${WEB}/doc" />
<copy todir="${WEB}/doc" file="${OUT}/build-info.txt"/>
<build-html name="Building" oDir="${WEB}/doc" iDir="../${PROJECT_DOC}"/>
<build-html name="Home" oDir="${WEB}/doc" iDir="../${PROJECT_DOC}"/>
<build-html name="Installing" oDir="${WEB}/doc" iDir="../${PROJECT_DOC}"/>
<build-html name="License" oDir="${WEB}/doc" iDir="../${PROJECT_DOC}"/>
<build-html name="Running" oDir="${WEB}/doc" iDir="../${PROJECT_DOC}"/>
<build-html name="Security" oDir="${WEB}/doc" iDir="../${PROJECT_DOC}"/>
<build-html name="TestDrive" oDir="${WEB}/doc" iDir="../${PROJECT_DOC}"/>
<build-html name="ChangeLog" oDir="${WEB}/doc" iDir="../${PROJECT_DOC}"/>
<move file="${WEB}/doc/Home.html" tofile="${WEB}/doc/index.html"/>
<copy todir="${WEB}/doc/css"> <fileset dir="../${PROJECT_DOC}/css"/> </copy>
<copy todir="${WEB}/doc/images"> <fileset dir="../${PROJECT_DOC}/images"/> </copy>
<copy todir="${WEB}/doc/scripts"> <fileset dir="../${PROJECT_DOC}/scripts"/> </copy>
</target>
<!-- ============================================================
convert IDL to JSON (cached)
============================================================ -->
<target name="build-json-idl">
<uptodate property="JSON_IDL_UPTODATE" targetfile="${CACHED}/json-idl/all-json-idls.js">
<srcfiles dir="../${PROJECT_SERVER}/interfaces" includes="*.idl"/>
<srcfiles dir="${VENDOR}/WebKit/WebCore/inspector" includes="*.idl"/>
</uptodate>
<antcall target="build-json-idl-fresh"/>
<copy todir="${WEB}/interfaces"> <fileset dir="${CACHED}/json-idl"/></copy>
</target>
<!-- ============================================================
convert IDL to JSON (slow part)
============================================================ -->
<target name="build-json-idl-fresh" unless="JSON_IDL_UPTODATE">
<delete dir="${CACHED}/json-idl"/>
<mkdir dir="${CACHED}/json-idl"/>
<simple-idl2json name="WeinreClientCommands" oDir="${CACHED}/json-idl" iDir="../${PROJECT_SERVER}/interfaces"/>
<simple-idl2json name="WeinreClientEvents" oDir="${CACHED}/json-idl" iDir="../${PROJECT_SERVER}/interfaces"/>
<simple-idl2json name="WeinreTargetCommands" oDir="${CACHED}/json-idl" iDir="../${PROJECT_SERVER}/interfaces"/>
<simple-idl2json name="WeinreTargetEvents" oDir="${CACHED}/json-idl" iDir="../${PROJECT_SERVER}/interfaces"/>
<simple-idl2json name="InjectedScriptHost" oDir="${CACHED}/json-idl" iDir="${VENDOR}/WebKit/WebCore/inspector"/>
<simple-idl2json name="Inspector" oDir="${CACHED}/json-idl" iDir="${VENDOR}/WebKit/WebCore/inspector">
<arg value="--anyType"/>
<arg value="Value"/>
</simple-idl2json>
<simple-idl2json name="InspectorFrontendHost" oDir="${CACHED}/json-idl" iDir="${VENDOR}/WebKit/WebCore/inspector">
<arg value="--anyType"/>
<arg value="MouseEvent"/>
</simple-idl2json>
<exec executable="python" failonerror="true" failifexecutionfails="true">
<arg file="scripts/collect-all-json-idl.py"/>
<arg file="${CACHED}/json-idl/all-json-idls.js"/>
<arg file="${CACHED}/json-idl"/>
</exec>
<exec executable="python" failonerror="true" failifexecutionfails="true">
<arg file="scripts/collect-all-json-idl.py"/>
<arg value="-min"/>
<arg file="${CACHED}/json-idl/all-json-idls-min.js"/>
<arg file="${CACHED}/json-idl"/>
</exec>
</target>
<!-- ============================================================
build the web/target files
============================================================ -->
<target name="build-target">
<mkdir dir="${WEB}/target"/>
<exec executable="python" failonerror="true" failifexecutionfails="true">
<arg file="scripts/build-target-scripts.py"/>
<arg file="../${PROJECT_WEB}/demo/weinre-demo-pieces.html"/>
<arg file="${WEB}"/>
<arg file="${WEB}/target"/>
</exec>
</target>
<!-- ============================================================
build the web/client files
============================================================ -->
<target name="build-client">
<copy todir="${WEB}/client/nls/English.lproj">
<fileset file="${VENDOR}/WebKit/WebCore/English.lproj/localizedStrings.js"/>
</copy>
<copy todir="${WEB}/client">
<fileset dir="${VENDOR}/WebKit/WebCore/inspector/front-end"/>
</copy>
<exec executable="python" failonerror="true" failifexecutionfails="true">
<arg file="scripts/build-client-html.py"/>
<arg file="${WEB}"/>
</exec>
</target>
<!-- ============================================================
build the main jar
============================================================ -->
<target name="build-jar">
<jar destfile="${OUT}/weinre.jar">
<manifest>
<attribute name="Built-By" value="${ant.file.basename} - ${ant.project.name}"/>
<attribute name="Main-Class" value="weinre.server.Main"/>
</manifest>
<fileset file="${OUT}/build-info.txt"/>
<zipfileset src="${VENDOR}/jetty/jetty.jar">
<exclude name="about*.html"/>
<exclude name="META-INF/**/*"/>
</zipfileset>
<zipfileset src="${VENDOR}/jetty/servlet-api.jar">
<exclude name="META-INF/**/*"/>
</zipfileset>
<zipfileset src="${VENDOR}/cli/commons-cli.jar">
<exclude name="META-INF/**/*"/>
</zipfileset>
<zipfileset src="${VENDOR}/json4j/json4j.jar">
<exclude name="META-INF/**/*"/>
</zipfileset>
<fileset dir="../${PROJECT_SERVER}/bin"/>
<zipfileset dir="${WEB}" prefix="web"/>
</jar>
<delete dir="../${PROJECT_SERVER_ANDROID}/lib"/>
<mkdir dir="../${PROJECT_SERVER_ANDROID}/lib"/>
<copy file="${OUT}/weinre.jar" todir="../${PROJECT_SERVER_ANDROID}/lib"/>
</target>
<!-- ============================================================
build the ui jar
============================================================ -->
<target name="build-ui-jar">
<fileset dir="../${PROJECT_APPLICATION}/bin"/>
<jar destfile="${OUT}/weinre-ui.jar">
<manifest>
<attribute name="Built-By" value="${ant.file.basename} - ${ant.project.name}"/>
<attribute name="Main-Class" value="weinre.application.GUIMain"/>
</manifest>
<fileset file="${OUT}/build-info.txt"/>
<fileset dir="../${PROJECT_APPLICATION}/bin"/>
<zipfileset src="${VENDOR}/swt/cocoa-macosx-x86_64/swt.jar">
<exclude name="META-INF/**/*"/>
</zipfileset>
</jar>
</target>
<!-- ============================================================
build the mac application
============================================================ -->
<target name="build-application-mac">
<delete dir="${OUT}/applications/mac"/>
<mkdir dir="${OUT}/applications/mac/weinre.app"/>
<copy todir="${OUT}/applications/mac/weinre.app">
<fileset dir="../${PROJECT_APPLICATION}/resources/macosx/weinre.app">
<exclude name="**/Info.plist"/>
</fileset>
</copy>
<copy todir="${OUT}/applications/mac/weinre.app">
<fileset dir="../${PROJECT_APPLICATION}/resources/macosx/weinre.app">
<include name="**/Info.plist"/>
</fileset>
<filterset>
<filter token="VERSION" value="${WEINRE_VERSION}"/>
</filterset>
</copy>
<chmod file="${OUT}/applications/mac/weinre.app/Contents/MacOS/launcher" perm="+x"/>
<copy todir="${OUT}/applications/mac/weinre.app/Contents/MacOS" file="${OUT}/weinre.jar" />
<copy todir="${OUT}/applications/mac/weinre.app/Contents/MacOS" file="${OUT}/weinre-ui.jar"/>
<copy todir="${OUT}/applications/mac/weinre.app/Contents/Resources" file="${OUT}/build-info.txt"/>
</target>
<!-- ============================================================
build the archives
============================================================ -->
<target name="build-archives">
<!-- =================================== -->
<delete dir="${OUT}/archives"/>
<mkdir dir="${OUT}/archives"/>
<delete dir="${OUT}/files"/>
<delete dir="${OUT}/files/weinre-jar"/>
<mkdir dir="${OUT}/files/weinre-jar"/>
<copy todir="${OUT}/files/weinre-jar" file="${OUT}/build-info.txt"/>
<copy todir="${OUT}/files/weinre-jar" file="${OUT}/weinre.jar"/>
<!-- ant's zip task doesn't preserve permission bits -->
<exec executable="zip" dir="${OUT}/files">
<arg value="-q"/>
<arg value="-r"/>
<arg value="../archives/weinre-jar-${BUILD_NUMBER}.zip"/>
<arg value="weinre-jar"/>
</exec>
<!-- =================================== -->
<delete dir="${OUT}/files/weinre-mac"/>
<mkdir dir="${OUT}/files/weinre-mac"/>
<copy todir="${OUT}/files/weinre-mac" file="${OUT}/build-info.txt" />
<copy todir="${OUT}/files/weinre-mac">
<fileset dir="${OUT}/applications/mac"/>
</copy>
<chmod file="${OUT}/files/weinre-mac/weinre.app/Contents/MacOS/launcher" perm="+x"/>
<!-- ant's zip task doesn't preserve permission bits -->
<exec executable="zip" dir="${OUT}/files">
<arg value="-q"/>
<arg value="-r"/>
<arg value="../archives/weinre-mac-${BUILD_NUMBER}.zip"/>
<arg value="weinre-mac"/>
</exec>
<!-- =================================== -->
<delete dir="${OUT}/files/weinre-doc"/>
<mkdir dir="${OUT}/files/weinre-doc"/>
<copy todir="${OUT}/files/weinre-doc" file="${OUT}/build-info.txt" />
<copy todir="${OUT}/files/weinre-doc">
<fileset dir="${OUT}/web/doc"/>
</copy>
<!-- ant's zip task doesn't preserve permission bits -->
<exec executable="zip" dir="${OUT}/files">
<arg value="-q"/>
<arg value="-r"/>
<arg value="../archives/weinre-doc-${BUILD_NUMBER}.zip"/>
<arg value="weinre-doc"/>
</exec>
<!-- =================================== -->
<delete dir="${OUT}/files/weinre-src"/>
<mkdir dir="${OUT}/files/weinre-src"/>
<copy todir="${OUT}/files/weinre-src" file="${OUT}/build-info.txt" />
<copy todir="${OUT}/files/weinre-src/weinre.application"> <fileset dir="../weinre.application" excludes="**/bin/"/></copy>
<copy todir="${OUT}/files/weinre-src/weinre.build"> <fileset dir="../weinre.build" excludes="**/bin/, **/out/, **/cached/, **/vendor/, **/tmp/"/></copy>
<copy todir="${OUT}/files/weinre-src/weinre.doc"> <fileset dir="../weinre.doc" excludes="**/bin/"/></copy>
<copy todir="${OUT}/files/weinre-src/weinre.server"> <fileset dir="../weinre.server" excludes="**/bin/"/></copy>
<copy todir="${OUT}/files/weinre-src/weinre.web"> <fileset dir="../weinre.web" excludes="**/bin/"/></copy>
<!-- ant's zip task doesn't preserve permission bits -->
<exec executable="zip" dir="${OUT}/files">
<arg value="-q"/>
<arg value="-r"/>
<arg value="../archives/weinre-src-${BUILD_NUMBER}.zip"/>
<arg value="weinre-src"/>
</exec>
<!-- =================================== -->
<delete dir="${OUT}/files"/>
</target>
<!-- ============================================================
done!
============================================================ -->
<target name="finished">
<echo>ant completed successfully ${MESSAGE_FINISHED}</echo>
</target>
<!-- ============================================================
done! via growl
============================================================ -->
<target name="finished-growl" if="USE_GROWL">
<exec os="Mac OS X" executable="growlnotify">
<arg value="-m"/>
<arg value="${MESSAGE_FINISHED}"/>
<arg value="ant completed successfully"/>
</exec>
</target>
<!-- ============================================================
macro to compile IDL to JSON
============================================================ -->
<macrodef name="simple-idl2json">
<attribute name="name"/>
<attribute name="iDir"/>
<attribute name="oDir"/>
<element name="args" optional="true" implicit="true"/>
<sequential>
<exec executable="python" failonerror="true" failifexecutionfails="true">
<arg file="scripts/simple-idl2json.py"/>
<args/>
<arg value="--validate"/>
<arg file="@{iDir}/@{name}.idl"/>
<arg file="@{oDir}/@{name}.json"/>
</exec>
</sequential>
</macrodef>
<!-- ============================================================
macro to compile HTML
============================================================ -->
<macrodef name="build-html">
<attribute name="name"/>
<attribute name="iDir"/>
<attribute name="oDir"/>
<element name="args" optional="true" implicit="true"/>
<sequential>
<delete file="@{oDir}/@{name}.html"/>
<concat destfile="@{oDir}/@{name}.html">
<filelist dir="@{iDir}" files="boilerplate-header.html.txt"/>
<filelist dir="@{iDir}" files="@{name}.body.html"/>
<filelist dir="@{iDir}" files="boilerplate-trailer.html.txt"/>
<filterchain>
<replacetokens>
<token key="PAGE_NAME" value="@{name}"/>
</replacetokens>
</filterchain>
</concat>
<echo>generated @{oDir}/@{name}.html</echo>
</sequential>
</macrodef>
<!-- ============================================================ -->
</project>