ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Harkness, David" <DHarkn...@sonypictures.com>
Subject RE: New to ant, having some problems
Date Wed, 15 Oct 2003 07:51:36 GMT
Stephen Touset <mailto:stephen@touset.org> 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
build.properties 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 -Dcc.target=debug

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

Mime
View raw message