blob: f5305c343d7080ba09e306149915f2f15fa08bda [file] [log] [blame]
<!--
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
-->
<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_DATE" pattern="yyyy-MM-dd--HH-mm-ss" timezone="GMT"/>
</tstamp>
<condition property="BUILD_VERSION" value="${WEINRE_VERSION}-${BUILD_DATE}">
<matches pattern=".*pre$" string="${WEINRE_VERSION}"/>
</condition>
<condition property="BUILD_VERSION" value="${WEINRE_VERSION}">
<not>
<matches pattern=".*pre$" string="${WEINRE_VERSION}"/>
</not>
</condition>
<!-- ============================================================
do a clean build
============================================================ -->
<target name="build-clean" depends="clean,build">
</target>
<!-- ============================================================
main entry point
============================================================ -->
<target name="build" depends="build-dev">
<antcall target="build-doc"/>
<antcall target="build-archives"/>
<echo>full ant build completed successfully</echo>
</target>
<!-- ============================================================
clean
============================================================ -->
<target name="clean">
<delete dir="${OUT}"/>
<delete dir="${TMP}"/>
<delete dir="${WEB}"/>
<delete dir="${CACHED}"/>
</target>
<!-- ============================================================
development-time build
============================================================ -->
<target name="build-dev">
<fail>
<condition>
<not>
<resourceexists>
<file file="personal.properties"/>
</resourceexists>
</not>
</condition>
The file 'personal.properties' was not found; create one based on 'sample.personal.properties'.
</fail>
<echo>building version ${BUILD_VERSION}</echo>
<mkdir dir="${OUT}"/>
<delete includeemptydirs="true">
<fileset dir="${OUT}" includes="**/*" excludes="build-done.txt"/>
</delete>
<property
name = "build-info-text"
value = "weinre build ${BUILD_VERSION} by ${BUILDER}"
/>
<echo file="${OUT}/build-info.txt" message="${build-info-text}"/>
<antcall target="build-web"/>
<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"/>
<echo file="${OUT}/build-done.txt" message="${build-info-text} is finished!"/>
</target>
<!-- ============================================================
check for personal properties
============================================================ -->
<target name="check-personal-properties" unless="personal.properties.exists">
</target>
<!-- ============================================================
basic web resources
============================================================ -->
<target name="build-web">
<delete dir="${WEB}" />
<mkdir dir="${WEB}" />
<delete dir="${TMP}" />
<mkdir dir="${TMP}" />
<echo message="compiling CoffeeScript modules"/>
<mkdir dir="${TMP}/modules/weinre/client" />
<mkdir dir="${TMP}/modules/weinre/common" />
<mkdir dir="${TMP}/modules/weinre/target" />
<echo message="compiling CoffeeScript files in: ${PROJECT_WEB}/modules/weinre/client"/>
<exec executable="sh" failonerror="true" failifexecutionfails="true">
<arg value="-c"/>
<arg value="../${PROJECT_SERVER}/node_modules/.bin/coffee --compile --bare --output ${TMP}/modules/weinre/client ../${PROJECT_WEB}/modules/weinre/client/*.coffee"/>
</exec>
<echo message="compiling CoffeeScript files in: ${PROJECT_WEB}/modules/weinre/common"/>
<exec executable="sh" failonerror="true" failifexecutionfails="true">
<arg value="-c"/>
<arg value="../${PROJECT_SERVER}/node_modules/.bin/coffee --compile --bare --output ${TMP}/modules/weinre/common ../${PROJECT_WEB}/modules/weinre/common/*.coffee"/>
</exec>
<echo message="compiling CoffeeScript files in: ${PROJECT_WEB}/modules/weinre/target"/>
<exec executable="sh" failonerror="true" failifexecutionfails="true">
<arg value="-c"/>
<arg value="../${PROJECT_SERVER}/node_modules/.bin/coffee --compile --bare --output ${TMP}/modules/weinre/target ../${PROJECT_WEB}/modules/weinre/target/*.coffee"/>
</exec>
<echo message="transportd-izing modules"/>
<exec executable="python" failonerror="true" failifexecutionfails="true">
<arg file="scripts/module2amd.py"/>
<arg value="--quiet"/>
<arg value="--out"/>
<arg file="${WEB}"/>
<arg file="${TMP}/modules"/>
</exec>
<copy todir="${WEB}">
<fileset file="../${PROJECT_WEB}/modjewel.js"/>
</copy>
<!--
<copy todir="${WEB}">
<fileset file="${VENDOR}/json2/json2.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="${BUILD_VERSION}"/>
<filter token="BUILD_DATE" value="${BUILD_DATE}"/>
</filterset>
</copy>
<echo message="building package.json"/>
<copy file="package.json.template" tofile="../${PROJECT_SERVER}/package.json" overwrite="true">
<filterset>
<filter token="WEINRE_VERSION" value="${BUILD_VERSION}"/>
</filterset>
</copy>
</target>
<!-- ============================================================
documentation
============================================================ -->
<target name="build-doc">
<mkdir dir="${WEB}/doc" />
<copy todir="${WEB}/doc" file="${OUT}/build-info.txt"/>
<build-html name="Building" title="Building" oDir="${WEB}/doc" iDir="../${PROJECT_DOC}"/>
<build-html name="Home" title="Home" oDir="${WEB}/doc" iDir="../${PROJECT_DOC}"/>
<build-html name="Installing" title="Installing" oDir="${WEB}/doc" iDir="../${PROJECT_DOC}"/>
<build-html name="License" title="License" oDir="${WEB}/doc" iDir="../${PROJECT_DOC}"/>
<build-html name="Running" title="Running" oDir="${WEB}/doc" iDir="../${PROJECT_DOC}"/>
<build-html name="MultiUser" title="Muli-User" oDir="${WEB}/doc" iDir="../${PROJECT_DOC}"/>
<build-html name="Security" title="Security" oDir="${WEB}/doc" iDir="../${PROJECT_DOC}"/>
<build-html name="UserInterface" title="User Interface" oDir="${WEB}/doc" iDir="../${PROJECT_DOC}"/>
<build-html name="ChangeLog" title="ChangeLog" oDir="${WEB}/doc" iDir="../${PROJECT_DOC}"/>
<copy file="${WEB}/doc/Home.html" tofile="${WEB}/doc/index.html"/>
<copy todir="${WEB}/doc/images" file="../${PROJECT_WEB}/images/weinre-icon-64x64.png"/>
<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>
<delete dir="${WEB}/doc/images/orig" />
</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="WeinreExtraClientCommands" oDir="${CACHED}/json-idl" iDir="../${PROJECT_SERVER}/interfaces"/>
<simple-idl2json name="WeinreExtraTargetEvents" 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="${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 archives
============================================================ -->
<target name="build-archives">
<!-- =================================== -->
<delete dir="${OUT}/archives"/>
<mkdir dir="${OUT}/archives"/>
<delete dir="${OUT}/files"/>
<delete dir="${OUT}/files/weinre-node"/>
<mkdir dir="${OUT}/files/weinre-node"/>
<copy todir="${OUT}/files/weinre-node" file="${OUT}/build-info.txt"/>
<copy todir="${OUT}/files/weinre-node" file="../LICENSE"/>
<copy todir="${OUT}/files/weinre-node" file="../NOTICE"/>
<copy todir="${OUT}/files/weinre-node">
<fileset dir="../${PROJECT_SERVER}"/>
</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-node-${BUILD_VERSION}.zip"/>
<arg value="weinre-node"/>
</exec>
<exec executable="tar" dir="${OUT}/files">
<arg value="-czf"/>
<arg value="../archives/weinre-node-${BUILD_VERSION}.tar.gz"/>
<arg value="weinre-node"/>
</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" file="../LICENSE"/>
<copy todir="${OUT}/files/weinre-doc" file="../NOTICE"/>
<copy todir="${OUT}/files/weinre-doc">
<fileset dir="${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_VERSION}.zip"/>
<arg value="weinre-doc"/>
</exec>
<!-- =================================== -->
<delete dir="${OUT}/files/weinre-src"/>
<mkdir dir="${OUT}/files/weinre-src"/>
<exec executable="git" dir="..">
<arg value="archive"/>
<arg value="--format=zip"/>
<arg value="--prefix=weinre-src/"/>
<arg value="--output=${PROJECT_BUILD}/${TMP}/weinre-src.zip"/>
<arg value="HEAD"/>
</exec>
<exec executable="unzip" dir="${OUT}/files">
<arg value="-q"/>
<arg value="../../${TMP}/weinre-src.zip"/>
</exec>
<copy todir="${OUT}/files/weinre-src" file="${OUT}/build-info.txt" />
<!-- 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_VERSION}.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="title"/>
<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="@{title}"/>
</replacetokens>
</filterchain>
</concat>
<echo>generated @{oDir}/@{name}.html</echo>
</sequential>
</macrodef>
<!-- ============================================================ -->
</project>