views:

429

answers:

2

Hi,

Is it possible to add build events only for a specific build configuration in Delphi 2007 ?

I use 2007 but would be interested in what you can do in 2009 also.

Cheers Sam

+3  A: 

No.

You can have (resource) compiler settings for each build configuration in Delphi 2009. But this does not apply to the other settings.

You can fake it, but it takes some time:

  1. In the prebuild, delete the conf*.dcu files.
  2. Define DEBUG for the debug configuration.
  3. Add the following to the project file:

Code:

uses
  ..
{$IFDEF DEBUG}
  confDebug,
{$ELSE}
  confRelease,
{$ENDIF}
  ..
  1. Now let the post build step check for the existence of confDebug.dcu or confRelease.dcu to find which build configuration is used.

It is a bit cumbersome, but you can do what you want.

Gamecat
Short answer: "no". Longer answer: "yes". :-)
Wouter van Nifterick
There is a difference between a solution and a hack. But maybe I'm a nitpick ;-).
Gamecat
Thanks Gamecat. Not a nice solution, i'm suprised delphi doesn't support different build events based on cofigurations but thanks very much for the information.
SamH
@samhowley, codegear is busy processing the backlog of the borland "lack of attention" period. I have hope that features like this are fixed in future versions. (Their plan was to fix about 100 minor anoyances).
Gamecat
+2  A: 

Yes!

As you can have separate defines in each build configuration. You can check your project defines for conditional build processing.

I use something like that:

echo $(DEFINES) | find "RELEASE"> nul
if not errorlevel 1 goto
release

echo $(DEFINES) | find "DEBUG" > nul
if not errorlevel 1 goto debug

goto end

:release
echo Processing RELEASE Build:
...
goto end

:debug
echo Processing DEBUG Build:
..
goto end

:end
bhe
This works and is a lot easier than the first solution accepted. Note that it should read "if not errorlevel 1 goto release" on one line, but aside from that it works as advertised.
moz