You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by cowwoc <co...@bbs.darktech.org> on 2008/08/16 06:13:31 UTC

Dynamic "depends" for debug/release builds

Hi,

I've got Java code that makes use of JNI so my build process is slightly
different depending on whether debug or release is being built. I'd like to
define the following ant target:

<target name="dist" depends="compile.${config}"/>
<target name="compile.debug"/>
<target name="compile.release/>

where config = debug or release. When I tried this Ant complained
"compile.${config}" does not exist in this config. If I use <antcall> the
target gets invoked just fine but then any properties declared by the target
get lost when the call returns.

Can someone please suggest a clean/simple way to do this?

Thank you,
Gili
-- 
View this message in context: http://www.nabble.com/Dynamic-%22depends%22-for-debug-release-builds-tp19008604p19008604.html
Sent from the Ant - Users mailing list archive at Nabble.com.


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


Re: Dynamic "depends" for debug/release builds

Posted by David Weintraub <qa...@gmail.com>.
Have your "dist" task first depend upon a "config-test". The only
purpose of the "config-test" task is to look at the value of ${config}
and see if it is set to "debug". If it is, you set a flag called
"is.debug". Then, you can use the "if" and "unless parameters of the
<target> task to see if this is a debug or release.

<!-- Default target: Must test whether this is a debug or release build -->
<!-- by looking at the value of ${config}. Then, either run the
compile-debug -->
<!-- or the compile-release tasks, but not both.  -->
<target name="dist"
    depends="config-test,compile-debug,compile-release>
<blah, blah, blah/>
</target>

<!-- Test to see whether this is a debug or release type of build -->
<target name="config-test">
   <condition property="is.debug">
        <equals arg1="${config}" arg2="debug"/>
   </condition>
</target>

<!-- Run either the compile-debug or compile-release, but not both -->
<target name=compile-debug
    if="is.debug">
    <blah, blah, blah/>
</target>

<target name=compile-release
   unless="is.debug">
   <blah, blah, blah>
</target>

--
David Weintraub
qazwart@gmail.com



On Sat, Aug 16, 2008 at 12:13 AM, cowwoc <co...@bbs.darktech.org> wrote:
>
> Hi,
>
> I've got Java code that makes use of JNI so my build process is slightly
> different depending on whether debug or release is being built. I'd like to
> define the following ant target:
>
> <target name="dist" depends="compile.${config}"/>
> <target name="compile.debug"/>
> <target name="compile.release/>
>
> where config = debug or release. When I tried this Ant complained
> "compile.${config}" does not exist in this config. If I use <antcall> the
> target gets invoked just fine but then any properties declared by the target
> get lost when the call returns.
>
> Can someone please suggest a clean/simple way to do this?
>
> Thank you,
> Gili
> --
> View this message in context: http://www.nabble.com/Dynamic-%22depends%22-for-debug-release-builds-tp19008604p19008604.html
> Sent from the Ant - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> 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: Dynamic "depends" for debug/release builds

Posted by cowwoc <co...@bbs.darktech.org>.
Thanks guys ;)

Gili


Dominique Devienne-2 wrote:
> 
> On Fri, Aug 15, 2008 at 11:13 PM, cowwoc <co...@bbs.darktech.org> wrote:
>> I've got Java code that makes use of JNI so my build process is slightly
>> different depending on whether debug or release is being built. I'd like
>> to
>> define the following ant target:
>>
>> <target name="dist" depends="compile.${config}"/>
>> <target name="compile.debug"/>
>> <target name="compile.release/>
>>
>> where config = debug or release. When I tried this Ant complained
>> "compile.${config}" does not exist in this config. If I use <antcall> the
>> target gets invoked just fine but then any properties declared by the
>> target
>> get lost when the call returns.
>>
>> Can someone please suggest a clean/simple way to do this?
> 
> Something along the lines of:
> 
> <target name="dist" depends="compile"/>
> <target name="compile" depends="-compile, compile.debug,
> compile.release"/>
> <target name="-compile">
>   <condition property="debug.config">
>     <equals arg1="debug" arg2="${config}" />
>   </condition>
>   <condition property="release.config">
>     <equals arg1="release" arg2="${config}" />
>   </condition>
> </target>
> <target name="compile.debug" if="debug.config"/>
> <target name="compile.release" if="release.config"/>
> 
> This scales to more configs. If you have only two configs, a single
> var and if/unless would do.
> This is all on top of my head, so actual syntax may need to be corrected.
> --DD
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Dynamic-%22depends%22-for-debug-release-builds-tp19008604p19019433.html
Sent from the Ant - Users mailing list archive at Nabble.com.


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


Re: Dynamic "depends" for debug/release builds

Posted by Dominique Devienne <dd...@gmail.com>.
On Fri, Aug 15, 2008 at 11:13 PM, cowwoc <co...@bbs.darktech.org> wrote:
> I've got Java code that makes use of JNI so my build process is slightly
> different depending on whether debug or release is being built. I'd like to
> define the following ant target:
>
> <target name="dist" depends="compile.${config}"/>
> <target name="compile.debug"/>
> <target name="compile.release/>
>
> where config = debug or release. When I tried this Ant complained
> "compile.${config}" does not exist in this config. If I use <antcall> the
> target gets invoked just fine but then any properties declared by the target
> get lost when the call returns.
>
> Can someone please suggest a clean/simple way to do this?

Something along the lines of:

<target name="dist" depends="compile"/>
<target name="compile" depends="-compile, compile.debug, compile.release"/>
<target name="-compile">
  <condition property="debug.config">
    <equals arg1="debug" arg2="${config}" />
  </condition>
  <condition property="release.config">
    <equals arg1="release" arg2="${config}" />
  </condition>
</target>
<target name="compile.debug" if="debug.config"/>
<target name="compile.release" if="release.config"/>

This scales to more configs. If you have only two configs, a single
var and if/unless would do.
This is all on top of my head, so actual syntax may need to be corrected. --DD

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