views:

1671

answers:

4

In most modern IDEs, you can have Debug and Release build configurations, and you can quickly switch between them.

In Delphi 7, this does not seem to be possible. I have to go to Project Settings and toggle optimization and all the debug information stuff manually.

It would be great if there was a plugin or some such that handled this for me.

Does anyone know of one? Any other suggestions?

Edit: I can't upgrade to Delphi 2007 or 2009 as we have a large Delphi 7 codebase which would have to be converted. I agree that would be the best solution in theory though :P

+3  A: 

I don't know of any build-configurations plugin for Delphi 7, but you could however simulate this;

Just apply an include-file in every unit of your project(s) (which is a smart thing to do anyways) and let it adjust itself to one single define, like this :

--- ExampleIncludeFile.inc ---

{$IFDEF DEBBUG}

{$OPTIMIZATION OFF}
{$RANGECHECKING ON}
// etc

{$ELSE}

{$OPTIMIZATION ON}
{$RANGECHECKING OFF}

{$ENDIF}


Now, if you add DEBUG to the Compiler defines in your .dof project settings, you'll get a Debug-build, and if you remove it, you get a release build. Other setups are entirely possible too ofcourse.

Delphi 2005 does have Build Configurations embedded in the Project Manager (Release and Debug only), and Delphi 2009 add even more to this, with nice little things like 'Option sets' and custom 'Configurations' (that you could even mark as Default for all new projects). Give it a look, it's a really great product!

PatrickvL
I'm using these as compiler flags (think thats the right term for it), so that all my print to file logic isn't included in production builds Thanks!
nomad311
+1  A: 

Not directly in Delphi 7, but you have options:

  • Wrap the compiler directives for all the changes (debug, optimization, etc.) inside a user defined compiler directive, and then set a compiler directive to change between debug and release.
  • Additionally you can use FinalBuilder or other similar build tools to create builds that use different settings.
  • Delphi 2005 has this functionality added. So upgrade to Delphi 2007 or 2009 and get it built in. They are both very stable versions with a lot of new features.
Jim McKeeth
+1  A: 

This feature was added only in Delphi 2009.

For older versions of Delphi you can write two copies of .cfg file, one with debug options and one with release options, and compile your program calling dcc32.exe from within a batch file.

Something like this:

rem release.bat
copy release.cfg myprog.cfg
dcc32 -B myprog.dpr

rem debug.bat
copy debug.cfg myprog.cfg
dcc32 -B myprog.dpr
Giacomo Degli Esposti
The feature was added in Delphi 2007 and improved in Delphi 2009 so that build configurations "inherit" from a common base configuration.
Bruce McGee
+9  A: 

You can very easily add project configurations, similar to what other IDEs offer, using Andreas Hausladen's great DDevExtensions IDE expert. Just make sure to download the 1.6 version from the link I mentioned, since later versions only work with Delphi 2009. The 1.6 version works with any Delphi version between 5 and 2007, inclusive.

The expert adds a submenu under the Project menu, in case you can't find it at first.

Mihai Limbășan