如何正确配置跨平台Delphi XE2项目?
现在我有 2 个平台(Mac 和 Win32)和 2 个配置(调试和发布)。整个事情都在SVN下。
这是构建输出的布局:
.\App\$(Platform)\$(Config)
代码被分成几个文件夹并位于此处:
.\Code\MyProject.dpr
.\Code\Common\
.\Code\Forms\
.\Code\Source\
常见数据文件位于此处:
.\Data\ custom data files (dlls, textures, models, etc.)
虽然该方案有某些缺陷,我需要解决这些缺陷,但我不知道如何改进。我只想在 SVN 的 Data 文件夹下有一组数据文件,但我需要在构建时自动将其复制到 .\App\$(Platform)\$(Config)
路径(注意,某些数据文件对于两个平台都是通用的,但有些则不是)。有没有办法设置构建过程来复制文件,就像部署和 PAServer 一样?或者,我可以将数据文件的路径设置为 ..\..\Data
,但这对我来说看起来很奇怪。
也许还有一些我不知道的其他选项,或者项目布局可以完全改变?您将如何设置项目结构并构建跨平台编译?
Right now I have 2 platforms (Mac and Win32) and 2 configs (Debug ans Release). Whole thing is under SVN.
Here is layout for build output:
.\App\$(Platform)\$(Config)
The code is split into few folders and located here:
.\Code\MyProject.dpr
.\Code\Common\
.\Code\Forms\
.\Code\Source\
Common data files are here:
.\Data\ custom data files (dlls, textures, models, etc.)
This scheme has certain flaws though, which I need to resolve, but I don't know how to make it better. I want to have only one set of data files in SVN under Data folder, but I need to have it copied to .\App\$(Platform)\$(Config)
paths automatically on build (note, certain data files are common for both platforms, but some are not). Is there a way to setup build process to copy the files, like it does with Deployment and PAServer? Alternatively I could setup paths to Data files as ..\..\Data
, but that looks weird to me.
Maybe there are some other options I'm not aware of, or project layout could be changed completely? How would you setup the project structure and build for cross-platform compiling?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用构建后操作。
从项目选项 |构建活动 |构建后事件 |命令
进一步阅读
创建构建事件
Delphi 中的构建前和构建后自动化
Use the Post Build actions.
From Project Options | Build Events | Post Build Events | Commands
Further reading at
Creating Build Events
Pre and Post-Build Automation in Delphi
好的,这是一篇旧文章,但这就是我在 Delphi 中所做的(在 Visual Studio 中也类似),以解决在不同文件夹中具有不同平台/配置输出可执行文件但有一组通用数据的问题。我有一个功能可以去除“子”文件夹部分,然后我的应用程序始终可以访问这些文件夹根目录中的通用数据(在您的情况下为 .\App)。当然,您可以根据需要向函数 ProjectPath 添加更多平台和配置:
Ok, this is an old post, but this is what I do in Delphi (and similarly in Visual Studio) to get around this problem of having the different platform/config output executables in different folders, but a common set of data. I have a function to strip off the "sub" folder parts, then my app can always access the common data in the root of these folders (in your case .\App). Of course you can add further platforms and configs to the function ProjectPath as required: