In Delphi 7, can I set up 'Debug' and 'Release' modes?
Asked Answered
G

4

13

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

Garrek answered 6/10, 2008 at 20:56 Comment(0)
Q
15

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.

Quebec answered 6/10, 2008 at 22:16 Comment(1)
As per idefixpack.de/blog/downloads version 2.4.2 also supports Delphi 7, while 1.6.1 was created in between, too.Refuel
Q
6

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!

Queer answered 6/10, 2008 at 21:5 Comment(3)
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!Mirellamirelle
It doesn't work for me, which .dof option should I modify? The symbol {$IFDEF DEBUG} is already defined in Delphi7 but I can't use it, should I define it manually?Miniaturist
It seems DEBUG symbol doesn't work with older Delphi, as @Deltics said here: https://mcmap.net/q/556820/-delphi-if-debug-equivalentMiniaturist
C
2

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.
Companion answered 6/10, 2008 at 21:5 Comment(0)
S
1

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
Saturable answered 6/10, 2008 at 21:7 Comment(1)
The feature was added in Delphi 2007 and improved in Delphi 2009 so that build configurations "inherit" from a common base configuration.Pneumatic

© 2022 - 2024 — McMap. All rights reserved.