You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Paul Richards <pa...@gmail.com> on 2008/04/23 12:55:50 UTC

Setting path to MSVC compiler with cctask

Hi,
I'm trying to use cpptasks-1.0b5 with Ant 1.7.0 on a C++ a project
that must be built with MSVC in both 32-bit and 64-bit flavours.  With
MSVC this means we must build the project with two different versions
of "cl.exe".

I can't put both on my PATH, and so I'd like to specify in my Ant
build script the correct version of the cl.exe compiler for cctask to
use each time.


Attempt #1 (failure):

>From what I can tell I can't set the environment on the fly in Ant.
For example I tried the following code before my cc task, and this
didn't work.
    <property environment="env"/>
    <property name="env.Path" value="${env.Path};C:\Program Files
(x86)\Microsoft Visual Studio 8\VC\bin"/>
The cc task fails to find cl.exe if I try this.


Attempt #2 (success):

My next option is to set the PATH using Ant's exec task in a recursive
call to "ant".  This works but doesn't seem very elegant:
    <property environment="env"/>
    <target name="compile-1">
        <exec executable="cmd">
            <arg line="/c ant.bat compile-2"/>
            <env key="Path" value="${env.Path};C:\Program Files
(x86)\Microsoft Visual Studio 8\VC\bin"/>
        </exec>
    </target>
    <target name="compile-2">
        <cc ...>...</cc>
    </target>
As my build.xml grows larger I'm sure this will cause pain when debugging.


So my question is how to specify the path to cl.exe neatly?  Can the
path to cl.exe be specified manually to cctask?  Does Ant support
calling itself in a neater way that doesn't require spawning a new
shell?



-- 
Paul Richards

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


Re: Setting path to MSVC compiler with cctask

Posted by Paul Richards <pa...@gmail.com>.
2008/4/23 Steve Loughran <st...@apache.org>:
> Paul Richards wrote:
>
> > Hi,
> > I'm trying to use cpptasks-1.0b5 with Ant 1.7.0 on a C++ a project
> > that must be built with MSVC in both 32-bit and 64-bit flavours.  With
> > MSVC this means we must build the project with two different versions
> > of "cl.exe".
> >
> > I can't put both on my PATH, and so I'd like to specify in my Ant
> > build script the correct version of the cl.exe compiler for cctask to
> > use each time.
> >
> >
> > Attempt #1 (failure):
> >
> > From what I can tell I can't set the environment on the fly in Ant.
> > For example I tried the following code before my cc task, and this
> > didn't work.
> >    <property environment="env"/>
> >    <property name="env.Path" value="${env.Path};C:\Program Files
> > (x86)\Microsoft Visual Studio 8\VC\bin"/>
> > The cc task fails to find cl.exe if I try this.
> >
> >
> >
>
>  Is there any way to set env variables inside the <cc> task?
>


The cc task does allow me to set env blocks but they are only used to
set the environment of the newly spawned cl.exe, and aren't used to
help find cl.exe itself.  So the cc task's own env blocks don't help
me.



-- 
Paul Richards

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


Re: Setting path to MSVC compiler with cctask

Posted by Steve Loughran <st...@apache.org>.
Paul Richards wrote:
> Hi,
> I'm trying to use cpptasks-1.0b5 with Ant 1.7.0 on a C++ a project
> that must be built with MSVC in both 32-bit and 64-bit flavours.  With
> MSVC this means we must build the project with two different versions
> of "cl.exe".
> 
> I can't put both on my PATH, and so I'd like to specify in my Ant
> build script the correct version of the cl.exe compiler for cctask to
> use each time.
> 
> 
> Attempt #1 (failure):
> 
> From what I can tell I can't set the environment on the fly in Ant.
> For example I tried the following code before my cc task, and this
> didn't work.
>     <property environment="env"/>
>     <property name="env.Path" value="${env.Path};C:\Program Files
> (x86)\Microsoft Visual Studio 8\VC\bin"/>
> The cc task fails to find cl.exe if I try this.
> 
> 

Is there any way to set env variables inside the <cc> task?

-- 
Steve Loughran                  http://www.1060.org/blogxter/publish/5
Author: Ant in Action           http://antbook.org/

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


Re: Setting path to MSVC compiler with cctask

Posted by Dominique Devienne <dd...@gmail.com>.
On Wed, Apr 23, 2008 at 5:55 AM, Paul Richards <pa...@gmail.com> wrote:
>  So my question is how to specify the path to cl.exe neatly?  Can the
>  path to cl.exe be specified manually to cctask?

Not that I remember.

> Does Ant support  calling itself in a neater way that
> doesn't require spawning a new shell?

No, not in a nice way, but you can encapsulate it once in a macro possibly.

Regarding your issue, I don't put cl.exe or VC in my path, and used
the .bat supplied with Visual Studio before invoking Ant. But that's a
manual step, or a .bat one, i.e. not integrated in Ant. --DD

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