开发者

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

开发者 https://www.devze.com 2023-01-20 00:55 出处:网络
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 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 automatic开发者_开发问答ally append this number to the exe name currently built? Tx

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


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


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.


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


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消