Delphi 2007 (or 2009) build events tied to build configurations?
-
22-08-2019 - |
Question
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
Solution
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:
- In the prebuild, delete the conf*.dcu files.
- Define DEBUG for the debug configuration.
- Add the following to the project file:
Code:
uses
..
{$IFDEF DEBUG}
confDebug,
{$ELSE}
confRelease,
{$ENDIF}
..
- 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.
OTHER TIPS
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
When using XE, I narrowed it down to something even simpler, if you're interested:
goto $(Config)
:Release
compil32 /cc f:\dev\MyProject\Installer\MyProject.iss"
etc.
:Debug
That builds my installer only when I set the Build Configuration to Release. If you wanted to get fancier, you could call Jenkins and let it take over the pre-release tasks. In Delphi 10.x, you don't need this trick anymore.