How can I automatically provide a .exe unique name at compile time?

I want the exe name of the application indicated by "ProgramExeName + version number" at compile time (for example: Filename18190.exe, Filename18191.exe ...) - so the exe name will never be the same. Given that I have a version number placed in the str variable, how do I automatically add this number to the exe name that is currently built? Tx

(Note: I want the renaming to be done at compile time, not after processing)

+4
source share
5 answers

There are several directives for managing the binary file name {$EXT string} , {$LIBPREFIX 'string'} , {$LIBSUFFIX 'string'} , {$LIBVERSION 'string'} (btw, the compiler has nothing with generating binary output code , this is done using the linker). None of them are dynamic, so you need to write the necessary values โ€‹โ€‹immediately before creating the project (a good job for the OpenToolAPI wizard in the IDE).

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

+3
source

If it should be executed by the compiler, then no, Delphi just won't do it. The name exe is the name of the project. Run the batch file after the build (I suppose delphi will let you do this later) and rename the file to the position you need. You may need to create a separate helper program to extract the assembly number from program resources so that you can use it in the name.

+1
source

the file name is created automatically from the project file, you cannot change it. But look at post-build events, maybe you can find something that will change the file name after a successful build

+1
source

You can write the batch file / makefile / Rakefile / anything that runs the compilation steps, and then just rename it according to the system time or something like that. Your question is a bit vague, so it's hard to say for sure, but that's a thought.

0
source

There is no way in Delphi to do this for regular executables. For packages, there is a LIB suffix option that can probably be used to do what you want, but that won't help you.

Hm, thinking about this, it may be possible to write an IDE addon that uses the ToolsAPI to save the project with a different name each time you build. As a result, you will get as many project files as there are executable files. I do not know if this can be done.

0
source

All Articles