ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dominique Devienne <DDevie...@lgc.com>
Subject RE: How can i...
Date Thu, 23 May 2002 15:46:25 GMT
As Conor pointed out, ant-contrib's <cpp> task compiles C/C++ code in a
cross-platform manner, and I've heard good things about it (not used it
though).

As for compiling VC++ projects from ANT (in a very non-cross-platform manner
of course ;-), I do that simply using the msdev.exe command line interface:

    <property name="msdev.exe" value="msdev.exe" />
    <exec executable="${msdev.exe}"
          dir="${src}/com/acme/"
          vmlauncher="true"
          failonerror="true">

      <arg value="/USEENV" />
      <arg value="com_acme.dsp" />
      <arg value="/MAKE" />
      <arg value="com_acme - ${configuration}" />
      <arg value="/BUILD" />

      <env key="Path"    path="${visual-studio.PATH}" />
      <env key="LIB"     path="${visual-studio.LIB}" />
      <env key="INCLUDE" path="${visual-studio.INCLUDE}" />

      <env key="JAVA_HOME" file="${java-dev-kit.home}" />

    </exec>

You can even call cl.exe directly if you want (in a very ad-hoc way, to
compile a very simple JNI native dll in this case):

  <target name="-dll">
    <!-- msvs env -->
    <path id="PATH">
      <pathelement location="${env.MSVS_HOME}/Common/MSDev98/Bin" />
      <pathelement location="${env.MSVS_HOME}/Common/Tools" />
      <pathelement location="${env.MSVS_HOME}/VC98/bin" />
    </path>
    <property name="PATH" refid="PATH" />

    <path id="LIB">
      <pathelement location="${env.MSVS_HOME}/VC98/mfc/lib" />
      <pathelement location="${env.MSVS_HOME}/VC98/lib" />
    </path>
    <property name="LIB" refid="LIB" />

    <path id="INCLUDE">
      <pathelement location="${env.MSVS_HOME}/VC98/include" />
      <pathelement location="${env.MSVS_HOME}/VC98/mfc/include" />
      <pathelement location="${env.MSVS_HOME}/VC98/atl/include" />
      <pathelement location="${env.JAVA_HOME}/include" />
      <pathelement location="${env.JAVA_HOME}/include/win32" />
    </path>
    <property name="INCLUDE" refid="INCLUDE" />

    <!-- compile -->
    <echo message="Compiling" />
    <apply executable="${env.MSVS_HOME}/VC98/Bin/cl.exe"
           dir="${-dlldir}"
           parallel="true"
           vmlauncher="true">
      <env key="Path"    path="${env.Path};${PATH}" />
      <env key="LIB"     path="${LIB}" />
      <env key="INCLUDE" path="${INCLUDE}" />
      <arg line="/nologo /GX /MD /DWIN32 /c" />
      <fileset dir="${-dlldir}" includes="*.cpp" />
    </apply>

    <!-- link -->
    <echo message="Linking" />
    <apply executable="${env.MSVS_HOME}/VC98/Bin/cl.exe"
           dir="${-dlldir}"
           parallel="true"
           vmlauncher="true">
      <env key="Path"    path="${env.Path};${PATH}" />
      <env key="LIB"     path="${LIB}" />
      <env key="INCLUDE" path="${INCLUDE}" />
      <arg line="/nologo /MD /LD" />
      <arg value="/Fe${bin}/${-dllname}" />
      <fileset dir="${-dlldir}" includes="*.obj" />
    </apply>
  </target>

But ant-contrib's <cpp> task seems to be the way of the future, and I plan
to use it eventually. --DD


-----Original Message-----
From: Brown, Michael [mailto:Michael_Brown@jdedwards.com] 
Sent: Thursday, May 23, 2002 9:41 AM
To: 'Ant Users List'
Subject: RE: How can i...

Arshad,

1. Is there any way to compile C or C++ file using ant ? I believe it can be
done, but there is alot of work there.  It would take some custom tasks and
I don't know if we can handle as much as products like VC++ and Borland
handles under the covers.

I am trying to determine if this is possible, also.  This is not easily
accomplished at this time.  We are using ant to compile java solutions, but
have not found an easy way to do the C and C++ compiles.  I never recieved a
reply when I asked this question weeks ago.  I don't think there will be a
clean way to accomplish this with ant.  It just doesn't seem to fit into the
scope of ant's focus and goals.  If you feel differently after looking into
the documentation and using ant, pleas let me know.  Feel free to contact me
directly.  

Mike 

-----Original Message-----
From: arshad_btsl@airtelindia.com [mailto:arshad_btsl@airtelindia.com]
Sent: Wednesday, May 22, 2002 10:48 PM
To: ant-user@jakarta.apache.org
Subject: How can i...


Hi,

1. Is there any way to compile C or C++ file using ant ?

2. If its not there then can it be incorporated into this tool so that we
just only require C/C++ compiler which will work in tandem ?

This way we can make this utility universally accepted for almost
everything.

If you don't have any idea then please forward this mail to the concerned
person if you know.

Thanks
Arshad


--
To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>

--
To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>

--
To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>


Mime
View raw message