Hello Nant-Team,

I am building c++ libraries and my project directory layout is:
  
  /root
    default.build     <build script>
    /src              <source files>
    /interm           <intermediate directory>
      *.obj
    /lib              <lib aka output directory>
      *.lib
      *.pdb

The idea is to put the directory tree (without the intermediate
directory) on a network share
and be able to compile/debug dependant projects on different machines.
Currently I'm using the following snippet to compile the c++ files,
create a PDB file and create
a lib file which are placed in ./lib:

  <target name="build_lib">
  
    <property name="intermdir"     value="${intermediate}/${targetext}"
/>
    <property name="targetname"    value="${targetprefix}${targetext}"
/>
    
    <mkdir dir="${intermdir}" />
  
    <!--
          !!! Nant combines 'objectfile' and 'pdbfile' automatically
with 'outputdir' !!!
          Therefore we have to place outputdir on a directory that is
above the intermediate directory (intermdir)
          AND the lib directory.
          Aditionally to denote a directory we have to specify a '/" at
the end of the objectfile attribute value.
    -->
    <cl outputdir='.' objectfile='${intermdir}/' options='${cpp_flags}'
pdbfile='lib\${targetname}.PDB'>
      <sources refid="sourcefiles" />
    </cl>

    <lib output="./lib/${targetname}.lib">
      <sources>
        <include name="${intermdir}\*.obj"/>
      </sources>
    </lib>
    
  </target>

This works for me, but unlike documented the Nant cl task prefixes the
values used to specify "pdbfile" (/Fd) and "objectfile" (/Fo) params
with the value from the "outputdir" attribute. For "objectfile" this may
be OK. But this behaviour
with "pdbfile" forced me to take the root directory as outputdir for the
cl-task.
In other cases it would be impossible to specify output directory and
intermediate directory to be on different pathes/drives.

Another (related) hack (because it depends on cl.exe) is the necessary
append of '/' to the objectfile attribute 
in case you compile multiple files.

In my opinion
 - outputdir  should specify where the target files (.obj) are placed
 - objectfile should specify the target .obj file. Using this attribute
when more than one sourcefile 
              is specified issues an error.
 - pdbfile    should specify the PDB file independant of the value of
outputdir

with this changes the above cl-task could be written as

    <cl outputdir='${intermdir}' options='${cpp_flags}'
pdbfile='lib\${targetname}.PDB'>
      <sources refid="sourcefiles" />
    </cl>

IMHO the current behaviour is not flexible enough. 
What do you think ?


Klaus Oberhofer

------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com
_______________________________________________
NAnt-users mailing list
NAnt-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nant-users

Reply via email to