简体   繁体   English

XE4:如何在平台上更改exe输出名称?

[英]XE4: How to change exe output name base on platform?

Simply I need output executable names like MyApp32.exe and MyApp64.exe after compiling my project in Delphi XE4. 在Delphi XE4中编译项目后,我只需要输出可执行文件名,如MyApp32.exe和MyApp64.exe。

I found a directive in the forum which is {$LIBSUFFIX '32'} but it seems it is only for dlls. 我在论坛中发现了一个{$ LIBSUFFIX'32'}的指令,但它似乎只适用于dll。

Any suggestions for executable files? 对可执行文件的任何建议?

Thanks. 谢谢。

The final executable filename always matches the project filename. 最终的可执行文件名始终与项目文件名匹配。 So either create separate projects that share common source code, or else use a Post-Build event to invoke a script that copies and renames the output file to a separate deployment folder after it has been compiled, such as: 因此,要么创建共享公共源代码的单独项目,要么使用Post-Build事件来调用脚本,该脚本在编译后将输出文件复制并重命名为单独的部署文件夹,例如:

copy /B "$(OutputPath)" "C:\Deployment\$(OutputName)$(MySuffix)$(OutputExt)"

Where MySuffix is defined in the Project Options with a different value for each platform: MySuffix在项目选项中定义的位置,每个平台具有不同的值:

MySuffix=32

.

MySuffix=64

By using a separate folder, the debugger still has access to the original un-renamed executable for debugging and testing. 通过使用单独的文件夹,调试器仍然可以访问原始的未重命名的可执行文件以进行调试和测试。

The way I handle this is that I have a single project with multiple targets: 32/64 bit, debug/release, etc. Each of those targets is output to a separate directory. 我处理这个的方式是我有一个包含多个目标的项目:32/64位,调试/发布等。每个目标都输出到一个单独的目录。 For example, Win64\\Release . 例如, Win64\\Release

When I prepare the files needed for deployment and installation, I rename the executables at that point. 当我准备部署和安装所需的文件时,我在那时重命名可执行文件。 And this renaming is needed because I deploy 32 and 64 bit versions to the same directory. 并且需要重命名,因为我将32位和64位版本部署到同一目录。 Naturally this is all automated. 当然,这都是自动化的。

Remy's approach of renaming the output file as a post-build action has the downside that the debugger won't be able to locate an executable. Remy将输出文件重命名为构建后操作的方法具有调试器无法找到可执行文件的缺点。

The philosophy is to fit in with the development environment when working with files that will be used by the IDE. 在处理IDE将使用的文件时,理念是适应开发环境。 But then when it comes to deployment, you are free to rename files, re-organise them into a different folder structure etc. that better suits your deployment needs. 但是当涉及到部署时,您可以自由地重命名文件,将它们重新组织成不同的文件夹结构等,以更好地满足您的部署需求。

Simple trick allow it: 简单的技巧允许它:

Go to Project Settings->Application and in field "Target file extensions" add unique suffix for every configuration. 转到项目设置 - >应用程序,在“目标文件扩展名”字段中为每个配置添加唯一后缀。

eg 例如

Debug 32 bit: debug32.exe  
Debug 64 bit: debug64.exe  
Release 32 bit: 32.exe  
Release 64 bit: 64.exe 

Output for project with name "ProjectName": 项目名称为“ProjectName”的输出:

ProjectName.debug32.exe  
ProjectName.debug64.exe  
ProjectName.32.exe  
ProjectName.64.exe

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM