You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by jason heddings <ja...@heddings.com> on 2006/05/13 03:19:38 UTC

compiler References in task

Hello-

I have the following build file and I'm not sure what I'm missing:

<project name="MyProj" default="build" basedir=".">
  <taskdef resource="cpptasks.tasks" classpath="./Tools/Ant/cpptasks.jar" />
  <typedef resource="cpptasks.types" classpath="./Tools/Ant/cpptasks.jar" />

  <compiler id="my-compiler" name="msvc">
    <defineset define="_DEBUG" />
  </compiler>

  <target name="build">
    <cc subsystem="console" outtype="executable" outfile="hello">
      <compiler refid="my-compiler" />
      <fileset dir="." includes="*.c" />
    </cc>
  </target>
</project>

When I try to run this, I get an error saying:
build.xml:12: my-compiler doesn't denote a ProcessorDef

This is my first attempt to factor out the compiler types, so thanks for
your patience :)

--jah



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


Re: compiler References in task

Posted by Dominique Devienne <dd...@gmail.com>.
> You need to make sure that they are loaded by the same classloader;
> giving them the same path doesnt guarantee this, and once in separate
> classloaders, the tasks cannot cast the reference to the types they expect.
>
> <classpath id="cpptasks.classpath" path="./Tools/Ant/cpptasks.jar" />
>
> <taskdef resource="cpptasks.tasks" classpathref="cpptasks.classpath"  />
> <typedef resource="cpptasks.types" classpathref="cpptasks.classpath"  />

Or drop cpptasks.jar in ANT_HOME/lib, and use XML namespaces with the
auto-magic antlib:net.sf.antcontrib.cpptasks URI, which I bind to the
cc prefix. I can then do <cc:compiler>, <cc:linker>, <cc:cc>, etc...
--DD

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


RE: compiler References in task

Posted by jason heddings <ja...@heddway.com>.
That did it, thanks!

I ended up using the antlib.xml to get the definitions in the same import...

Thanks,
--jah 

-----Original Message-----
From: Steve Loughran [mailto:stevel@apache.org] 
Sent: Monday, 15 May, 2006 03:49
To: Ant Users List
Subject: Re: compiler References in <cc> task

jason heddings wrote:
> Hello-
> 
> I have the following build file and I'm not sure what I'm missing:
> 
> <project name="MyProj" default="build" basedir=".">
>   <taskdef resource="cpptasks.tasks" classpath="./Tools/Ant/cpptasks.jar"
/>
>   <typedef resource="cpptasks.types" classpath="./Tools/Ant/cpptasks.jar"
/>

You need to make sure that they are loaded by the same classloader; 
giving them the same path doesnt guarantee this, and once in separate 
classloaders, the tasks cannot cast the reference to the types they expect.

<classpath id="cpptasks.classpath" path="./Tools/Ant/cpptasks.jar" />

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



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





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


Re: compiler References in task

Posted by Steve Loughran <st...@apache.org>.
jason heddings wrote:
> Hello-
> 
> I have the following build file and I'm not sure what I'm missing:
> 
> <project name="MyProj" default="build" basedir=".">
>   <taskdef resource="cpptasks.tasks" classpath="./Tools/Ant/cpptasks.jar" />
>   <typedef resource="cpptasks.types" classpath="./Tools/Ant/cpptasks.jar" />

You need to make sure that they are loaded by the same classloader; 
giving them the same path doesnt guarantee this, and once in separate 
classloaders, the tasks cannot cast the reference to the types they expect.

<classpath id="cpptasks.classpath" path="./Tools/Ant/cpptasks.jar" />

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



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