Question on ant build tool

sydras

Skilled
Folks I've a question on ant. Can I use ant to compile .c files? I understand ant to be a pure java build tool. But does that mean that it is simply written in java or does it mean that it can only compile java files I don't know.

Can anyone please shed some light on this?
 
Not that I have much experience with it but you can use Ant to build anything really. For java you use the <javac> tags in the Ant build XML and for others like C (C++, .NET, Unix/Windows, documentation generation etc) you could use the <exec> tag to invoke the right platform executable like "make" for windows/unix.

You need to setup makefiles etc of course but the same build xml can build your entire product with code, docs, packaging etc...
 
I don't find a lot of information on ant usage with with .c or .cpp files. Is ant the best option for compiling .c and .cpp files?

The reason we're considering ant is because we have a combination of .cpp and .java files for our application. What would be the best compile tool to compile such an application?
 
We too have a combination of languages and also across platforms (Linux, Solaris, Windows etc) and Ant works well.

What would be the best compile tool? Ant is a build tool, for compile tool, you're stuck with the JDK's "javac" program and for C/C++ you would use Visual Studio's command line tools like msbuild.exe, vcbuild.exe (read up on their documentation on how to invoke them via command line), for Unix you'll most likely use GCC in combination with "make" and makefiles...
 
Sorry, I meant best "build" tool besides Ant. Also, how do I get gcc for windows? I'm trying cpptasks as S@ndeep suggested but it seems to rely on gcc internally.
 
mingw or cygwin are two options to use gcc on windows. mingw comes with QTCreator, if you dont want to download and unzip different files to get mingw.
 
You can easily use ant for building C/C++ projects. You need to use the exec tag for this purpose where you can specify the command to be run. It can be gcc or g++ or make(in case you are invoking make file; which is the norm), or any other command for that matter.
See the following example build.xml contents:
-----------------------------------------------------------------
<?xml version="1.0"?>
<project name="Firstproject" default="build" basedir=".">
<target name="clean">
<exec executable="rm">
<arg value="hello_world"/>
<arg value="*.o"/>
</exec>
<!-- <exec executable="ls">
<arg value="-l"/>
</exec>-->
</target>
<target name="build" depends="clean">
<exec executable ="g++" failonerror="true">
<arg value="-g"/>
<arg value="hello_world.cpp"/>
<arg value="-o"/>
<arg value="hello_world"/>
</exec>
</target>
</project>
------------------------------------------------------------------------
Hope it helps...:hap2:
 
Back
Top