This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
example of using ant to drive a gcj build
- From: Adam Megacz <gcj at lists dot megacz dot com>
- To: java at gcc dot gnu dot org
- Date: 03 Nov 2002 15:17:55 -0800
- Subject: example of using ant to drive a gcj build
- Organization: Myself
Here's GCJ.xml, the build file used to build XWT on gcj-supported
targets (Win32, Linux, Solaris) demonstrating the use of gcjh, gcj,
g++, ld, and jikes in a coordinated build.
Note the use of both parallel and serial <apply/>'s -- something make
can't do. The dependency analysis here is very, very fine-grained --
none of jikes, gcjh, gcj, nor ld will ever be executed unless
absolutely necessary.
I've chosen ease of comprehension over compactness here; there's
nothing stoppping you from putting all the flags for each invocation
on a single line (like make). That would probably be a better idea
for a build as complex as libgcj's.
- a
<!-- Copyright 2002 Adam Megacz, see the COPYING file for licensing [GPL] -->
<!--
Subclasses of org.xwt.plat.GCJ should include a .xml file which
sets the following properties, then invokes <ant antfile="src/org/xwt/plat/GCJ.xml"/>
gcc-target - the gcc target name to use (for example, i686-pc-mingw32)
linkflags - extra flags to pass to gcj during the link phase, if any
binaryname - the name to give to the final binary
-->
<project name="GCJ" default="build">
<target name="build">
<echo message='extracting .class -> .h'/>
<taskdef name='gcjh' classname='org.xwt.tasks.GCJHTask'>
<classpath path='bin/'/>
</taskdef>
<gcjh out='bin-${plat}' classpath='bin'/>
<echo message='compiling .java -> .o'/>
<apply failonerror='true' executable='${gcc-path}/bin/${gcc-target}gcj' dest='bin-${plat}'>
<arg value='-fCLASSPATH=bin/'/>
<arg value='-O9'/>
<arg value='-g'/>
<arg value='-c'/>
<srcfile/>
<arg value='-o'/>
<targetfile/>
<fileset dir='src/'>
<include name='org/xwt/*.java'/>
<include name='org/xwt/util/*.java'/>
<include name='org/xwt/plat/GCJ.java'/>
<include name='org/xwt/plat/${subplat}.java'/>
<include name='org/bouncycastle/**/*.java'/>
<include name='org/mozilla/**/*.java'/>
<exclude name='org/xwt/Trap.java'/>
</fileset>
<mapper type='glob' from='*.java' to='*.o'/>
</apply>
<!-- we have to turn off optimization here due to a compiler bug -->
<apply failonerror='true' executable='${gcc-path}/bin/${gcc-target}gcj' dest='bin-${plat}'>
<arg value='-fCLASSPATH=bin/'/>
<arg value='-O0'/>
<arg value='-g'/>
<arg value='-c'/>
<srcfile/>
<arg value='-o'/>
<targetfile/>
<fileset dir='src/'>
<include name='org/xwt/Trap.java'/>
</fileset>
<mapper type='glob' from='*.java' to='*.o'/>
</apply>
<echo message='compiling .cc -> .o'/>
<apply failonerror='true' executable='${gcc-path}/bin/${gcc-target}gcj' dest='bin-${plat}/'>
<arg value='-g'/>
<arg value='-Ibin-${plat}'/>
<arg value='-c'/>
<srcfile/>
<arg value='-o'/>
<targetfile/>
<fileset dir='src/' includes='org/xwt/plat/${subplat}.cc'/>
<mapper type='glob' from='*.cc' to='*-nat.o'/>
</apply>
<echo message='wrapping .xwar -> .o'/>
<apply failonerror='true' executable='${gcc-path}/bin/${gcc-target}gcj' dest='bin-${plat}/'>
<fileset dir='bin/' includes='**/*.xwar'/>
<arg value='--resource'/>
<arg value='org/xwt/builtin.xwar'/>
<arg value='-c'/>
<srcfile/>
<arg value='-o'/>
<targetfile/>
<mapper type='glob' from='*.xwar' to='*.o'/>
</apply>
<echo message='linking .o -> ${binaryname}'/>
<uptodate property="linked" targetfile="bin-${plat}/${binaryname}">
<srcfiles dir="bin-${plat}/" includes="**/*.o" excludes='*.o'/>
</uptodate>
<antcall target="link"/>
</target>
<target name="link" unless="linked">
<apply failonerror='true' executable='${gcc-path}/bin/${gcc-target}gcj' parallel='true'>
<fileset dir='bin-${plat}/' includes='**/*.o' excludes='*.o'/>
<arg value='-fCLASSPATH=${gcc-path}/share/libgcj.jar'/>
<arg value='--main=org.xwt.Main'/>
<arg line='-o bin-${plat}/${binaryname}'/>
<srcfile/>
<arg line='${linkflags}'/>
</apply>
</target>
</project>
--
"Through your rags I see your vanity" -- Socrates