ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stephen Touset <>
Subject RE: New to ant, having some problems
Date Wed, 15 Oct 2003 16:32:18 GMT
Well, that would have worked, save one small detail. It seems, after
closer inspection, that compilerarg quotes its value if it detects
spaces. Thus, it would send "-Wall -ansi -pedantic -ggdb", etc. to
gcc/g++ (with quotes), which causes them to ignore the flags. Since this
nullifies the approach where the ${cctargetflags} property is set to the
appropriate flagset, I had to go back to my old method. Now, instead of
using a property container for all the flags, I simply have a lot of
<compilerarg value="blah" if="${release}> statements. I also noticed a
debug option for <compiler>, which enables debugging options. So I opted
to use <compiler debug="${debug}"> instead of the -ggdb gcc flag.

On Wed, 2003-10-15 at 03:51, Harkness, David wrote:
> Stephen Touset <> once said:
> > First off, I'm sure there's a way to easily debug a build.xml
> > file [...]
> Other than ant -debug, -v[erbose] and <echo>, I know of no other
> options.
> > Next is that my approach seems rather "hackish". There
> > doesn't seem to be an easy way to set compiler options based
> > upon the target called.
> The method you chose is how I've seen others do the same thing. I strive
> to avoid <antcall> and stick to the dependencies, setting properties as
> you've done. I also tend to favor using a property (set in a developer's
> for stickiness or as -D<property>=<value> on the
> command line over exploding targets. My reasoning? If you're creating
> multiple targets that set properties to be used later, why not just skip
> that and set the properties? You can always wrap the whole thing with a
> shell script to change
>   ant build
> with
>   build -d
> > My current solution is to have the release
> > and debug targets call a setrelease and setdebug target,
> > respectively, before going into the build. These set a
> > "release" or "debug" property, and antcall my build target,
> > inheriting properties. 
> I modified your build.xml slightly (full file attached). Mainly,
> setrelease and setdebug both set the same property (cctargetflags) to be
> used by <cc> in the build target. This removes the if-logic from the
> <compilerarg>s. Also, I replaced the <antcall>s with dependencies.
> Side note: can you specify multiple <compilerarg>s and it will just tack
> them all on there? I haven't used <cc> before, but if you still have
> trouble you might want to verify that.
> Changed lines are marked with *. Some lines were removed (see full
> file).
> *	<target name="release" depends="setrelease,build,link"/>
> *	<target name="debug" depends="setdebug,build,link"/>
> 	<target name="setrelease">
> *		<property name="cctargetflags"
> value="${ccreleaseflags}"/>
> 	</target>
> 	<target name="setdebug">
> *		<property name="cctargetflags" value="${ccdebugflags}"/>
> 	</target>
> 	<target name="build">
> +		<echo message="Flags: ${cctargetflags}"/>
> 		<mkdir dir="${builddir}"/>
> 		<cc objdir="${builddir}" outtype="shared">
> 			<compilerarg value="${ccflags}"/>
> *			<compilerarg value="${cctargetflags}"/>
> 			<compiler name="gcc">
> There's an <echo> in there for sanity, and both targets work for me. ;)
> Good luck!
> David Harkness
> Sr. Software Engineer
> Sony Pictures Digital Networks
> (310) 482-4756
> ______________________________________________________________________
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:
Stephen Touset <>

View raw message