views:

144

answers:

5

I want the exe name of an application given 'ProgramExeName + version number' at compilation time (exemple: Filename18190.exe, Filename18191.exe...) - so the exe name is never the same. Considering i have the version number put in a str variable, how to automatically append this number to the exe name currently built? Tx

(Note: i want the renaming be done at compilation time, not manipulated after)

A: 

You could write a batch file / makefile / Rakefile / whatever that runs the compile steps and then just renames it according to the system time or something like that. Your question is a little vague, so it's hard to say precisely, but it's a thought.

iand675
I'm using Delphi. I want the name given when compilation is done. Probably by some IDE hack done when exe is created ?
volvox
I'm not entirely clear why it *must* be done by the IDE. Is there a particular reason?
iand675
@iand675 Debugging (as in the IDE debugger actually attaching to the executable once it runs) could be a reason.
Paul-Jan
no particular reason and many... i just wonder why this could not be done since it could be very usefull (ex: just having a different name at each built... :)
volvox
@volwox: It wouldn't be useful at all. If you want to save the file after every build, use a post build event to copy the latest version of the project to a new file. That both leaves the executable name the same as the project name for debugging, and gives you a copy with a unique name after each build.
Ken White
+1  A: 

If it must be done by the compiler, then no, Delphi simply wont do that. The name of the exe is the name of the project. Run a batch file after the build (I believe later delphi's let you do this) and rename the file to whatever you want. You may need to create a seperate helper program to extract the build number from the program's resources so that you can use that in the name.

GrandmasterB
thanks - see my comment @ joe mayer below
volvox
+1  A: 

the filename is generated automatically from the project file, you can't change that. But look at post build events, maybe you can figure out something that changes the filename after a successful build

Joe Meyer
THis might be the point. Where is this post build event in the process of building the file (at the point exe gets its name from the project name). May be then we could append some text (such as version number)
volvox
The post build event fires after the entire build is complete, which means the finished executable (with the same name as the project file) is already on the disk.
Ken White
A: 

There is no way to do that in Delphi for normal executables. For packages there is the LIB suffix option, which could probably be manipulated to do what you want but that won't help you.

Hm, thinking about it, maybe it would be possible to write an IDE addon that uses the ToolsAPI to save the project with a different name every time you do a build. You would end up with as many project files as executables. I don't know whether it can be done.

dummzeuch
+1  A: 

There are several directives to manipulate the filename of output binary {$EXT string}, {$LIBPREFIX 'string'}, {$LIBSUFFIX 'string'}, {$LIBVERSION 'string'} (btw, compiler have nothing with with forming output binary, this done by linker). Neither of them is dynamic, so you HAVE to write desired values right before building your project (good job for OpenToolAPI wizard in the IDE).

The other possibility is post-build activity which extracts version number (for example: VERSION_INFO) from PE binary and renames the file accordingly