2002/05/16 04:08:01
[org.ibex.core.git] / build.xml
1 <project name="xwt" default="run" basedir=".">
2
3     <!-- required so that libgcj.jar doesn't interfere with non-gcj compilation -->
4     <property name="build.sysclasspath" value="first"/>
5
6     <property name="gcc-path" value="/usr/local/gcc"/>
7     <property name="build.compiler" value="jikes"/>
8     <property environment="env"/>
9
10     <!-- the hostname of a cygwin machine running sshd; used for running Win32 binaries -->
11     <property name="cygwin-host" value="vmware"/>
12
13     <!-- a path on ${cygwin-host} which maps to the root of this XWT tree; usually exported from the build machine using samba -->
14     <property name="cygwin-path" value="z:/xwt"/>
15
16     <!-- set up our classpath -->
17     <path id="classpath">
18         <pathelement path="${envCLASSPATH}"/>
19         <pathelement path="bin/"/>
20         <fileset dir="www/webapps/lib">
21             <include name="**/*.jar"/>
22         </fileset>
23         <fileset dir="lib">
24             <include name="**/*.jar"/>
25         </fileset>
26     </path>
27
28     <!-- purges binaries we've built -->
29     <target name="clean">
30         <bash>
31             find . -name \*\~ | xargs rm -f
32             find . -name \#\*\# | xargs rm -f
33             rm -rf bin-* bin xwt/html/dist/
34         </bash>
35     </target>
36
37     <!-- creates javadoc documentation -->
38     <target name="genjavadoc" unless="javadoc_ok">
39        <javadoc sourcepath="src" destdir="www/html/javadoc/" package="yes" protected="no" packagenames="org.xwt.*"/>
40     </target>
41
42     <!-- creates javasrc documentation -->
43     <target name="genjavasrc" unless="javasrc_ok">
44        <java classname="javasrc.app.JavaSrc" fork="yes">
45            <classpath refid="classpath"/>
46            <jvmarg value="-Doutdir=www/html/javasrc/"/>
47            <arg value="src/org/xwt/"/>
48        </java>
49     </target>
50
51     <!-- compiles all .java files into .class files; all other tasks predepend on this since they need the <taskdef/>'s -->
52     <target name="compile">
53         <mkdir dir="bin/"/>
54         <echo message="compiling  .java -> .class"/>
55         <javac destdir="bin/" deprecation="no">
56             <src path="src/"/>
57             <include name="**/*.java"/>
58             <classpath>
59                 <!-- don't EVER include the following line anywhere else; it causes really bizarre errors -->
60                 <pathelement location="${gcc-path}/share/libgcj.jar"/>
61                 <path refid="classpath"/>
62             </classpath>
63         </javac>
64         <taskdef name="bash" classname="org.xwt.tasks.BashTask">
65             <classpath path="bin/"/>
66         </taskdef>
67     </target>
68
69     <target name="build" depends="compile">
70         <mkdir dir="www/html/dist/"/>
71         <ant dir="." antfile="src/org/xwt/plat/${plat}.xml" target="build"/>
72     </target>
73
74     <target name="run" depends="compile,build">
75         <ant dir="." antfile="src/org/xwt/plat/${plat}.xml" target="run"/>
76     </target>
77
78     <!-- rebuild the www/ area -->
79     <target name="staging">
80         <property name="staging-flag" value="-Dstaging"/>
81         <property name="host" value="xwt-staging.org"/>
82         <antcall target="really-push"/>
83     </target>
84
85     <target name="production">
86         <mkdir dir="www/html/javadoc/"/>
87         <mkdir dir="www/html/javasrc/"/>
88         <uptodate property="javadoc_ok" targetfile="www/html/javadoc/index.html">
89             <srcfiles dir= "src/" includes="**/*.java"/>
90         </uptodate>
91         <uptodate property="javasrc_ok" targetfile="www/html/javasrc/index.html">
92             <srcfiles dir= "src/" includes="**/*.java"/>
93         </uptodate>
94         <antcall target="genjavadoc"/>
95         <antcall target="genjavasrc"/>
96         <property name="staging-flag" value=""/>
97         <property name="host" value="xwt.org"/>
98         <antcall target="really-push"/>
99     </target>
100
101     <target name="newbuild" depends="compile">
102         <taskdef name="build-id" classname="org.xwt.tasks.BuildIdTask">
103             <classpath path="bin/"/>
104         </taskdef>
105         <build-id/>
106         <bash> cvs commit -m "automatically updated build-id via org.xwt.tasks.BuildIdTask" build.properties </bash>
107         <property file="build.properties"/>
108         
109         <mkdir dir="www/html/dist/"/>
110
111         <!-- rebuild distributions -->
112         <property name="plat" value="Win32"/>
113         <ant dir="." antfile="src/org/xwt/plat/Win32.xml" target="build"/>
114         <ant dir="." antfile="src/org/xwt/plat/Win32.xml" target="dist"/>
115         <property name="plat" value="Java2"/>
116         <ant dir="." antfile="src/org/xwt/plat/Java12.xml" target="build"/>
117         <ant dir="." antfile="src/org/xwt/plat/Java12.xml" target="dist"/>
118 <!--
119         <property name="plat" value="Linux"/>
120         <ant dir="." antfile="src/org/xwt/plat/Linux.xml" target="build"/>
121         <ant dir="." antfile="src/org/xwt/plat/Linux.xml" target="dist"/>
122 -->
123         <!-- sign stuff -->
124         <bash> /home/megacz/bin/sign/sign ${build-id} </bash>
125     </target>
126
127     <!-- required packages: bind, apache, libapache-mod-ssl, libapache-mod-jk, sshd, rsync, j2sdk, tomcat, gnuchess -->
128     <target name="really-push" depends="compile">
129
130         <!-- update demo xwars -->
131         <zip update="true" zipfile="www/html/demo.xwar" basedir="src" includes="org/xwt/demo/**,xwt/standard/**,org/xwt/themes/**"/>
132         <zip update="true" zipfile="www/html/demo.xwar" basedir="src/org/xwt/demo/" includes="main.xwt"/>
133         <zip update="true" zipfile="www/html/chess.xwar" basedir="src" includes="org/xwt/chess/**,xwt/standard/**,org/xwt/themes/**"/>
134         <zip update="true" zipfile="www/html/chess.xwar" basedir="src/org/xwt/chess/" includes="main.xwt"/>
135         <zip update="true" zipfile="www/html/mail.xwar" basedir="src"
136              includes="org/xwt/mail/**,xwt/standard/**,org/xwt/themes/**,org/gimp/tigert/**,org/xwt/fonts/**"
137              excludes="org/xwt/mail/main.xwt"
138              />
139         <zip update="true" zipfile="www/html/mail.xwar" basedir="src/org/xwt/mail/" includes="main.xwt"/>
140         <zip update="true" zipfile="www/html/k5.xwar" basedir="src" includes="xwt/**,org/xwt/themes/**,org/gimp/**,org/xwt/x5t/**"/>
141         <zip update="true" zipfile="www/html/k5.xwar" basedir="src/org/xwt/x5t/" includes="main.xwt"/>
142
143         <mkdir dir="www/webapps/classes/"/>
144         <copy todir="www/webapps/classes/">
145             <fileset dir="bin/" includes="org/xwt/server/**"/>
146         </copy>
147
148         <bash>
149             # throw on the prefix/suffix where needed
150             for A in `find www/html -name \*.html_`
151             do (cat www/html/prefix.html; cat $A; cat www/html/suffix.html; cat "$A"_ 2>/dev/null; cat www/html/tagline.html) > `echo $A | sed s/_\$//g`
152             done
153         </bash>
154
155         <bash host="root@${host}">
156             # first, clone the currently running copy of xwt, so we can use rsync to save bandwidth
157             rm -rf /xwt-new
158             mkdir -p /xwt
159             mkdir -p /xwt-new
160             cd /xwt
161             tar cf - . | tar xf - -C /xwt-new
162         </bash>
163
164         <bash>
165             # tidy up and rsync our changes
166             find www/html -name \*~ | xargs rm -f
167             rsync -Pv --delete --exclude=html/dist/\* -rze ssh www/ root@${host}:/xwt-new/www/
168             rsync -u -Pv -rze ssh www/html/dist/ root@${host}:/xwt-new/www/html/dist/
169         </bash>
170
171         <bash host="root@${host}">
172             # stop services
173             /sbin/start-stop-daemon --stop --pidfile /var/log/xwt/apache.pid --exec /usr/sbin/apache
174             /sbin/start-stop-daemon --stop --pidfile /var/log/xwt/tomcat.pid --user www-data
175
176             rm -rf /xwt-`date +%d-%b-%H:%M`
177             mv /xwt /xwt-`date +%d-%b-%H:%M`
178             mv /xwt-new /xwt
179             find /xwt-* -prune -type d -mtime +10 | xargs rm -rf
180
181             mkdir /var/log/xwt &amp;>/dev/null
182             chown www-data /var/log/xwt/
183             
184             ln -s /xwt/www/webapps /xwt/www/webapps/ROOT
185             ln -s /xwt/www/webapps /xwt/www/webapps/WEB-INF
186             ln -s /xwt/www/launch  /xwt/www/launch/ROOT
187             ln -s /xwt/www/launch  /xwt/www/launch/WEB-INF
188             
189             export JAVA_HOME=/usr/lib/j2sdk1.3
190             export CLASSPATH=$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/tools.jar:/usr/share/tomcat/classes:/usr/share/tomcat/lib/tomcat.jar
191
192             touch /var/log/xwt/tomcat.log
193             chown www-data /var/log/xwt/tomcat.log
194
195             test ${host} == "xwt-staging.org" &amp;&amp; echo -e "User-agent: *\nDisallow: /\n" > /xwt/www/html/robots.txt
196
197             /sbin/start-stop-daemon \
198                 --start --pidfile /var/log/xwt/tomcat.pid --make-pidfile --chuid www-data --exec \
199                     /usr/lib/j2sdk1.3/bin/java -- -server -Dtomcat.home=/usr/share/tomcat -Xmx500M \
200                     org.apache.tomcat.startup.Main -config /xwt/www/etc/server.xml start \
201                 >> /var/log/xwt/tomcat.log 2>&amp;1 &amp;
202
203             /sbin/start-stop-daemon --start --pidfile /var/log/xwt/apache.pid --exec /usr/sbin/apache -- -f /xwt/www/etc/httpd.conf ${staging-flag}
204         </bash>
205     </target>
206
207
208 </project>
209
210
211        <!-- old javago optimization code - - reintegrate at some point
212           lib/javago.`uname` -threshold 300 -not-inline-constructor -not-use-invokespecial org/xwt/Box.class
213           lib/javago.`uname` -threshold 300 -not-inline-constructor -not-use-invokespecial org/xwt/Box.class
214           lib/javago.`uname` -threshold 200 -not-inline-constructor -not-use-invokespecial org/xwt/Surface.class
215           lib/javago.`uname` -threshold 50 -not-inline-constructor -not-use-invokespecial org/xwt/GetPutHandler*
216           lib/javago.`uname` -threshold 200 -not-inline-constructor -not-use-invokespecial org/xwt/util/DirtyList.class
217        -->