8

is it possible to setup (ideally from GUI) the Build Configuration to automatically add suffixes to the output files according to the target platform ?

I mean, I will have for instance library project named Project and I would like to get

Project.dll - when I build the project for 32-bit platform
Project64.dll - when I build the project for 64-bit platform

Thank you

Martin Reiner
  • 2,167
  • 2
  • 20
  • 34
  • So far as I know the only thing you can change is the extension with `{$E}` – David Heffernan Dec 14 '11 at 16:09
  • Unfortunately {$E} places the value behind the extension dot, so using `{$E 64.dll}` would build me something like `Project.64.dll` what is not so good :( – Martin Reiner Dec 14 '11 at 16:17
  • Yes, I realise that it's not what you want. Sorry for not being clear on that point. So far as I know that's the only option you have available. My solution is to use post build scripts to rename the file. – David Heffernan Dec 14 '11 at 16:20
  • @DavidHeffernan Thanks, I've been thinking about renaming script for post build event, but is it absolutely safe to rename the output files ? I don't know much about PE headers and the things around. – Martin Reiner Dec 14 '11 at 16:59
  • Yes it is absolutely fine to rename the output file. PE headers has no dependency on the file name. – David Heffernan Dec 14 '11 at 17:02
  • @DavidHeffernan Thanks for the info. So, post this as the answer and I will accept it. Anyway, I'm wondering why so important thing isn't supported by the Delphi build configuration. – Martin Reiner Dec 14 '11 at 17:20
  • 4
    To achieve project64.dll you can specify the Library Suffix `64` in Project Options. – Ondrej Kelle Dec 14 '11 at 17:48
  • 1
    @TOndrej does this only work for packages and libraries, or can it work for apps too? – David Heffernan Dec 14 '11 at 18:52

2 Answers2

13

Funnily enough I was trying to do the exact same thing yesterday for the executable file of my app. I reached the conclusion that it is not possible to change the name of the output file. The only way you can influence the output file's name is with the {$E} directive but that just controls the extension of the output which is not what you want.

Update

Thanks to @TOndrej for pointing out the $LIBSUFFIX directive. This does not appear to be modifiable via the IDE project options for libraries, although there is such support for packages. However, it does indeed work when included in the source code of your package. Include this in your library .dpr file.

{$IFDEF WIN64}
  {$LIBSUFFIX '64'}
{$ENDIF}

This does not have any effect for projects that produce executables (i.e. VCL apps, services etc.) and so I believe the only solution in those cases is a post-build action.

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
3

You could also use a build event to rename the executable. In the post build event in project options, you could do something like this:

ren $(OUTPUTPATH) $(OUTPUTNAME)$(Platform).exe

That would give you something like:

ExampleProgramWin64.exe

or

ExampleProgramWin32.exe

It does mean that you can't debug it though, since the IDE doesn't know it's been renamed, so maybe doing a copy is more appropriate.

copy $(OUTPUTPATH) $(OUTPUTDIR)\$(OUTPUTNAME)$(Platform).exe
Nat
  • 5,414
  • 26
  • 38