Sample build.xml

Help
Ben
2004-06-16
2004-06-16
  • Ben
    Ben
    2004-06-16

    I'm completely new to ANT and the use of the cpptask.  Can someone please post a generic .xml to compile something?  I cannot find a sample anywhere and it would be amazingly helpful.

    Thanks!

     
    • Curt Arnold
      Curt Arnold
      2004-06-16

      There are a couple in the samples directory.  If you download cppunit 1.9.14 from http://sf.net/projects/cppunit and then copy samples/cppunit.ant into the cppunit base directory as build.xml, you can then build cppunit for GCC, MSVC, Borland etc.

       
      • Ben
        Ben
        2004-06-16

        I'm confused - which isn't hard to do =)

        I saw those examples before, but they are a bit too complex since I am so new to this.  I just wanted a simple example such as what is shown below, but with the <cc> tags filled in.  I'm using Microsoft's compiler and linker now, but any would at least move me in the right direction.

        <project name="HelloWorld" default="compile" basedir=".">
            <description>
                simple 'Hello World' build file
            </description>
          <!-- set global properties for this build -->
          <property name="src" location="src"/>
          <property name="build" location="bin"/>

          <taskdef resource="cpptasks.tasks"/>
          <typedef resource="cpptasks.types"/>

          <target name="init">
            <!-- Create the time stamp -->
            <tstamp/>
            <!-- Create the build directory structure used by compile -->
            <mkdir dir="${build}"/>
          </target>

          <target name="compile" depends="init"
                description="compile the source " >
            <cc>
               .....
            </cc>
          </target>

          <target name="clean"
                description="clean up" >
            <!-- Delete the ${build} and ${dist} directory trees -->
            <delete dir="${build}"/>
            <delete dir="${dist}"/>
          </target>
        </project>

         
        • Curt Arnold
          Curt Arnold
          2004-06-16

          I think this is as small as you can go.  This will compile and link src/*.c and src/*.cpp using microsoft toolchain to produce hello.exe in the bin directory.

          <cc name="msvc" outfile="${build}/hello">
               <fileset dir="${src}" includes="*.c *.cpp"/>
          </cc>

           
          • Ben
            Ben
            2004-06-16

            Thanks - that's what I wanted.  I already pieced one together and posted it as a reply to my original.

            Thanks for your help!  Hopefully, this thread will help some one else in the future.

             
    • Ben
      Ben
      2004-06-16

      This is what I was looking for.  This works on my system using Microsoft's compiler/linker.  Hope this helps other people.  Granted, this is my first attempt, so it isn't pretty, but hey, we all start some where!

      <project name="HelloWorld" default="compile" basedir=".">
          <description>
              simple 'Hello World' build file
          </description>
        <!-- set global properties for this build -->
        <property name="src" location="src"/>
        <property name="build" location="bin"/>

        <taskdef resource="cpptasks.tasks"/>
        <typedef resource="cpptasks.types"/>

        <target name="init">
          <!-- Create the time stamp -->
          <tstamp/>
          <!-- Create the build directory structure used by compile -->
          <mkdir dir="${build}"/>
        </target>

        <target name="compile" depends="init" description="compile the source " >
            <cc name="msvc" objdir="${build}" link="executable" outfile="${build}/Hello" >
              <compilerarg location="start" value="-GX" />
              <fileset dir="${src}" includes="hello.cpp" />
              <linker name="msvc" />
            </cc>
        </target>

        <target name="clean"
              description="clean up" >
          <!-- Delete the ${build} and ${dist} directory trees -->
          <delete dir="${build}"/>
          <delete dir="${dist}"/>
        </target>
      </project>